his_api_controller.go 1.6MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004
  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/comfirm/upload", &HisApiController{}, "get:Get4102")
  135. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  136. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  137. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  138. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  139. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  140. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  141. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  142. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  143. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  144. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  145. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  146. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  147. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  148. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  149. //库盘和变更
  150. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  151. //删除库盘和变更
  152. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  153. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  154. //药品变更
  155. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  156. beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  157. beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  158. beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  159. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  160. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  161. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  162. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  163. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  164. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  165. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  166. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  167. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  168. beego.Router("/api/changedrug/five", &HisApiController{}, "get:ChangeDrugFive")
  169. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  170. beego.Router("/api/delete_xs_bg_three", &HisApiController{}, "get:DeleteXSandBGThree")
  171. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  172. }
  173. func (c *HisApiController) Get3201() {
  174. adminUser := c.GetAdminUserInfo()
  175. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  176. 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)
  177. var response Response
  178. if err := json.Unmarshal([]byte(result), &response); err != nil {
  179. fmt.Println("Error decoding JSON:", err)
  180. return
  181. }
  182. }
  183. func (c *HisApiController) TestNet() {
  184. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  185. //return
  186. c.ServeSuccessJSON(map[string]interface{}{
  187. "msg": "成功",
  188. })
  189. }
  190. func (c *HisApiController) Get3508() {
  191. admin_user_id, _ := c.GetInt64("admin_user_id")
  192. drug_id, _ := c.GetInt64("id")
  193. start_time := c.GetString("start_time")
  194. end_time := c.GetString("end_time")
  195. adminUser := c.GetAdminUserInfo()
  196. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  197. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  198. drug, _ := service.GetDrugByID(drug_id)
  199. var struct3508 models.Struct3508
  200. struct3508.OrgName = miConfig.OrgName
  201. struct3508.FixmedinsCode = miConfig.Code
  202. struct3508.AccessKey = miConfig.AccessKey
  203. struct3508.Opter = curRoles.UserName
  204. struct3508.RequestUrl = miConfig.Url
  205. struct3508.Url = miConfig.Url
  206. struct3508.AppId = miConfig.Cainfo
  207. struct3508.AppSecret = miConfig.AppSecret
  208. struct3508.Enckey = miConfig.EncKey
  209. struct3508.SignKey = miConfig.SignKey
  210. struct3508.SecretKey = miConfig.SecretKey
  211. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  212. struct3508.Begndate = start_time
  213. struct3508.Enddate = end_time
  214. result1, result2, _ := service.FJyb3508(struct3508)
  215. saveLog(result1, result2, "3508", "3508")
  216. var res models.Result3508
  217. var respJSON2 map[string]interface{}
  218. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  219. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  221. return
  222. }
  223. userJSONBytes2, _ := json.Marshal(respJSON2)
  224. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  225. utils.ErrorLog("解析失败:%v", err)
  226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  227. return
  228. }
  229. if res.Infcode == -1 {
  230. c.ServeSuccessJSON(map[string]interface{}{
  231. "failed_code": -10,
  232. "msg": res.ErrMsg,
  233. })
  234. } else {
  235. c.ServeSuccessJSON(map[string]interface{}{
  236. "info": res.Output,
  237. })
  238. }
  239. }
  240. func (c *HisApiController) Get3509() {
  241. admin_user_id, _ := c.GetInt64("admin_user_id")
  242. drug_id, _ := c.GetInt64("id")
  243. start_time := c.GetString("start_time")
  244. end_time := c.GetString("end_time")
  245. adminUser := c.GetAdminUserInfo()
  246. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  247. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  248. drug, _ := service.GetDrugByID(drug_id)
  249. var struct3508 models.Struct3509
  250. struct3508.OrgName = miConfig.OrgName
  251. struct3508.FixmedinsCode = miConfig.Code
  252. struct3508.AccessKey = miConfig.AccessKey
  253. struct3508.Opter = curRoles.UserName
  254. struct3508.RequestUrl = miConfig.Url
  255. struct3508.Url = miConfig.Url
  256. struct3508.AppId = miConfig.Cainfo
  257. struct3508.AppSecret = miConfig.AppSecret
  258. struct3508.Enckey = miConfig.EncKey
  259. struct3508.SignKey = miConfig.SignKey
  260. struct3508.SecretKey = miConfig.SecretKey
  261. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  262. struct3508.Begndate = start_time
  263. struct3508.Enddate = end_time
  264. result1, result2, _ := service.FJyb3509(struct3508)
  265. saveLog(result1, result2, "3509", "3509")
  266. var res models.Result3509
  267. var respJSON2 map[string]interface{}
  268. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  271. return
  272. }
  273. userJSONBytes2, _ := json.Marshal(respJSON2)
  274. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  275. utils.ErrorLog("解析失败:%v", err)
  276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  277. return
  278. }
  279. if res.Infcode == -1 {
  280. c.ServeSuccessJSON(map[string]interface{}{
  281. "failed_code": -10,
  282. "msg": res.ErrMsg,
  283. })
  284. } else {
  285. c.ServeSuccessJSON(map[string]interface{}{
  286. "info": res.Output,
  287. })
  288. }
  289. }
  290. func (c *HisApiController) Get3510() {
  291. admin_user_id, _ := c.GetInt64("admin_user_id")
  292. drug_id, _ := c.GetInt64("id")
  293. start_time := c.GetString("start_time")
  294. end_time := c.GetString("end_time")
  295. adminUser := c.GetAdminUserInfo()
  296. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  297. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  298. drug, _ := service.GetDrugByID(drug_id)
  299. var struct3508 models.Struct3510
  300. struct3508.FixmedinsCode = miConfig.Code
  301. struct3508.OrgName = miConfig.OrgName
  302. struct3508.AccessKey = miConfig.AccessKey
  303. struct3508.Opter = curRoles.UserName
  304. struct3508.RequestUrl = miConfig.Url
  305. struct3508.Url = miConfig.Url
  306. struct3508.AppId = miConfig.Cainfo
  307. struct3508.AppSecret = miConfig.AppSecret
  308. struct3508.Enckey = miConfig.EncKey
  309. struct3508.SignKey = miConfig.SignKey
  310. struct3508.SecretKey = miConfig.SecretKey
  311. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  312. struct3508.Begndate = start_time
  313. struct3508.Enddate = end_time
  314. result1, result2, _ := service.FJyb3510(struct3508)
  315. saveLog(result1, result2, "3510", "3510")
  316. var res models.Result3510
  317. var respJSON2 map[string]interface{}
  318. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  319. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  321. return
  322. }
  323. userJSONBytes2, _ := json.Marshal(respJSON2)
  324. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  325. utils.ErrorLog("解析失败:%v", err)
  326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  327. return
  328. }
  329. if res.Infcode == -1 {
  330. c.ServeSuccessJSON(map[string]interface{}{
  331. "failed_code": -10,
  332. "msg": res.ErrMsg,
  333. })
  334. } else {
  335. c.ServeSuccessJSON(map[string]interface{}{
  336. "info": res.Output,
  337. })
  338. }
  339. }
  340. func (c *HisApiController) Get3511() {
  341. admin_user_id, _ := c.GetInt64("admin_user_id")
  342. drug_id, _ := c.GetInt64("id")
  343. start_time := c.GetString("start_time")
  344. end_time := c.GetString("end_time")
  345. adminUser := c.GetAdminUserInfo()
  346. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  347. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  348. drug, _ := service.GetDrugByID(drug_id)
  349. var struct3508 models.Struct3511
  350. struct3508.FixmedinsCode = miConfig.Code
  351. struct3508.OrgName = miConfig.OrgName
  352. struct3508.AccessKey = miConfig.AccessKey
  353. struct3508.Opter = curRoles.UserName
  354. struct3508.RequestUrl = miConfig.Url
  355. struct3508.Url = miConfig.Url
  356. struct3508.AppId = miConfig.Cainfo
  357. struct3508.AppSecret = miConfig.AppSecret
  358. struct3508.Enckey = miConfig.EncKey
  359. struct3508.SignKey = miConfig.SignKey
  360. struct3508.SecretKey = miConfig.SecretKey
  361. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  362. struct3508.Begndate = start_time
  363. struct3508.Enddate = end_time
  364. result1, result2, _ := service.FJyb3511(struct3508)
  365. saveLog(result1, result2, "3511", "3511")
  366. var res models.Result3511
  367. var respJSON2 map[string]interface{}
  368. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  371. return
  372. }
  373. userJSONBytes2, _ := json.Marshal(respJSON2)
  374. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  375. utils.ErrorLog("解析失败:%v", err)
  376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  377. return
  378. }
  379. if res.Infcode == -1 {
  380. c.ServeSuccessJSON(map[string]interface{}{
  381. "failed_code": -10,
  382. "msg": res.ErrMsg,
  383. })
  384. } else {
  385. c.ServeSuccessJSON(map[string]interface{}{
  386. "info": res.Output,
  387. })
  388. }
  389. }
  390. func (c *HisApiController) Get3512() {
  391. admin_user_id, _ := c.GetInt64("admin_user_id")
  392. drug_id, _ := c.GetInt64("id")
  393. start_time := c.GetString("start_time")
  394. end_time := c.GetString("end_time")
  395. adminUser := c.GetAdminUserInfo()
  396. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  397. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  398. drug, _ := service.GetDrugByID(drug_id)
  399. var struct3508 models.Struct3512
  400. struct3508.FixmedinsCode = miConfig.Code
  401. struct3508.OrgName = miConfig.OrgName
  402. struct3508.AccessKey = miConfig.AccessKey
  403. struct3508.Opter = curRoles.UserName
  404. struct3508.RequestUrl = miConfig.Url
  405. struct3508.Url = miConfig.Url
  406. struct3508.AppId = miConfig.Cainfo
  407. struct3508.AppSecret = miConfig.AppSecret
  408. struct3508.Enckey = miConfig.EncKey
  409. struct3508.SignKey = miConfig.SignKey
  410. struct3508.SecretKey = miConfig.SecretKey
  411. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  412. struct3508.Begndate = start_time
  413. struct3508.Enddate = end_time
  414. result1, result2, _ := service.FJyb3512(struct3508)
  415. saveLog(result1, result2, "3512", "3512")
  416. var res models.Result3512
  417. var respJSON2 map[string]interface{}
  418. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  419. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  421. return
  422. }
  423. userJSONBytes2, _ := json.Marshal(respJSON2)
  424. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  425. utils.ErrorLog("解析失败:%v", err)
  426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  427. return
  428. }
  429. if res.Infcode == -1 {
  430. c.ServeSuccessJSON(map[string]interface{}{
  431. "failed_code": -10,
  432. "msg": res.ErrMsg,
  433. })
  434. } else {
  435. c.ServeSuccessJSON(map[string]interface{}{
  436. "info": res.Output,
  437. })
  438. }
  439. }
  440. func (c *HisApiController) Get3513() {
  441. admin_user_id, _ := c.GetInt64("admin_user_id")
  442. drug_id, _ := c.GetInt64("id")
  443. start_time := c.GetString("start_time")
  444. end_time := c.GetString("end_time")
  445. adminUser := c.GetAdminUserInfo()
  446. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  447. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  448. drug, _ := service.GetDrugByID(drug_id)
  449. var struct3508 models.Struct3513
  450. struct3508.FixmedinsCode = miConfig.Code
  451. struct3508.OrgName = miConfig.OrgName
  452. struct3508.AccessKey = miConfig.AccessKey
  453. struct3508.Opter = curRoles.UserName
  454. struct3508.RequestUrl = miConfig.Url
  455. struct3508.Url = miConfig.Url
  456. struct3508.AppId = miConfig.Cainfo
  457. struct3508.AppSecret = miConfig.AppSecret
  458. struct3508.Enckey = miConfig.EncKey
  459. struct3508.SignKey = miConfig.SignKey
  460. struct3508.SecretKey = miConfig.SecretKey
  461. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  462. struct3508.Begndate = start_time
  463. struct3508.Enddate = end_time
  464. result1, result2, _ := service.FJyb3513(struct3508)
  465. saveLog(result1, result2, "3513", "3513")
  466. var res models.Result3513
  467. var respJSON2 map[string]interface{}
  468. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  469. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  471. return
  472. }
  473. userJSONBytes2, _ := json.Marshal(respJSON2)
  474. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  475. utils.ErrorLog("解析失败:%v", err)
  476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  477. return
  478. }
  479. if res.Infcode == -1 {
  480. c.ServeSuccessJSON(map[string]interface{}{
  481. "failed_code": -10,
  482. "msg": res.ErrMsg,
  483. })
  484. } else {
  485. c.ServeSuccessJSON(map[string]interface{}{
  486. "info": res.Output,
  487. })
  488. }
  489. }
  490. func (c *HisApiController) Get35081() {
  491. admin_user_id, _ := c.GetInt64("admin_user_id")
  492. drug_id, _ := c.GetInt64("id")
  493. //start_time := c.GetString("start_time")
  494. //end_time := c.GetString("end_time")
  495. page, _ := c.GetInt("page")
  496. adminUser := c.GetAdminUserInfo()
  497. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  498. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  499. drug, _ := service.GetDrugByID(drug_id)
  500. var struct3508 models.Struct35081
  501. struct3508.FixmedinsCode = miConfig.Code
  502. struct3508.OrgName = miConfig.OrgName
  503. struct3508.AccessKey = miConfig.AccessKey
  504. struct3508.Opter = curRoles.UserName
  505. struct3508.RequestUrl = miConfig.Url
  506. struct3508.Url = miConfig.Url
  507. struct3508.AppId = miConfig.Cainfo
  508. struct3508.AppSecret = miConfig.AppSecret
  509. struct3508.Enckey = miConfig.EncKey
  510. struct3508.SignKey = miConfig.SignKey
  511. struct3508.SecretKey = miConfig.SecretKey
  512. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  513. struct3508.PageNum = page
  514. struct3508.PageSize = 10
  515. result1, result2, _ := service.FJyb35081(struct3508)
  516. saveLog(result1, result2, "35081", "35081")
  517. var res models.Result35081
  518. var respJSON2 map[string]interface{}
  519. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  520. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  522. return
  523. }
  524. userJSONBytes2, _ := json.Marshal(respJSON2)
  525. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  526. utils.ErrorLog("解析失败:%v", err)
  527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  528. return
  529. }
  530. if res.Infcode == -1 {
  531. c.ServeSuccessJSON(map[string]interface{}{
  532. "failed_code": -10,
  533. "msg": res.ErrMsg,
  534. })
  535. } else {
  536. c.ServeSuccessJSON(map[string]interface{}{
  537. "info": res.Output,
  538. })
  539. }
  540. }
  541. func (c *HisApiController) Get35082() {
  542. admin_user_id, _ := c.GetInt64("admin_user_id")
  543. drug_id, _ := c.GetInt64("id")
  544. //start_time := c.GetString("start_time")
  545. //end_time := c.GetString("end_time")
  546. page, _ := c.GetInt("page")
  547. adminUser := c.GetAdminUserInfo()
  548. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  549. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  550. drug, _ := service.GetDrugByID(drug_id)
  551. var struct3508 models.Struct35082
  552. struct3508.FixmedinsCode = miConfig.Code
  553. struct3508.OrgName = miConfig.OrgName
  554. struct3508.AccessKey = miConfig.AccessKey
  555. struct3508.Opter = curRoles.UserName
  556. struct3508.RequestUrl = miConfig.Url
  557. struct3508.Url = miConfig.Url
  558. struct3508.AppId = miConfig.Cainfo
  559. struct3508.AppSecret = miConfig.AppSecret
  560. struct3508.Enckey = miConfig.EncKey
  561. struct3508.SignKey = miConfig.SignKey
  562. struct3508.SecretKey = miConfig.SecretKey
  563. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  564. struct3508.PageNum = page
  565. struct3508.PageSize = 10
  566. result1, result2, _ := service.FJyb35082(struct3508)
  567. saveLog(result1, result2, "35082", "35082")
  568. var res models.Result35082
  569. var respJSON2 map[string]interface{}
  570. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  573. return
  574. }
  575. userJSONBytes2, _ := json.Marshal(respJSON2)
  576. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  577. utils.ErrorLog("解析失败:%v", err)
  578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  579. return
  580. }
  581. if res.Infcode == -1 {
  582. c.ServeSuccessJSON(map[string]interface{}{
  583. "failed_code": -10,
  584. "msg": res.ErrMsg,
  585. })
  586. } else {
  587. c.ServeSuccessJSON(map[string]interface{}{
  588. "info": res.Output,
  589. })
  590. }
  591. }
  592. func (c *HisApiController) FJ3501AND3502() {
  593. ids := c.GetString("ids")
  594. admin_user_id, _ := c.GetInt64("admin_user_id")
  595. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  596. id_arr := strings.Split(ids, ",")
  597. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  598. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  599. //库盘
  600. var errs []string
  601. for _, drug := range drugs {
  602. if drug.IsPc == 0 {
  603. var res2 ResultSix
  604. var res3 ResultSix
  605. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  606. var struct3501 models.Struct3501
  607. struct3501.Code = miConfig.Code
  608. struct3501.OrgName = miConfig.OrgName
  609. struct3501.AccessKey = miConfig.AccessKey
  610. struct3501.Opter = roles.UserName
  611. struct3501.RequestUrl = miConfig.Url
  612. struct3501.Url = miConfig.Url
  613. struct3501.AppId = miConfig.Cainfo
  614. struct3501.AppSecret = miConfig.AppSecret
  615. struct3501.Enckey = miConfig.EncKey
  616. struct3501.SignKey = miConfig.SignKey
  617. struct3501.SecretKey = miConfig.SecretKey
  618. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  619. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  620. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  621. struct3501.RxFlag = "1"
  622. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  623. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  624. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  625. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  626. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  627. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  628. struct3501.FixmedinsBchno = number
  629. struct3501.DrugTracCodg = drug.DrugCode
  630. memo := make(map[string]interface{})
  631. memo["pric"] = drug.Price
  632. bytesData, _ := json.Marshal(memo)
  633. struct3501.Memo = string(bytesData)
  634. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  635. result1, result2, _ := service.FJyb3501(struct3501)
  636. saveLog(result1, result2, "3501", "3501")
  637. //saveLog(result, requestLog, "2201", "挂号")
  638. var respJSON2 map[string]interface{}
  639. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  640. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  642. return
  643. }
  644. userJSONBytes2, _ := json.Marshal(respJSON2)
  645. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  646. utils.ErrorLog("解析失败:%v", err)
  647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  648. return
  649. }
  650. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  651. data := make(map[string]interface{})
  652. data["struct_3501s"] = struct3501
  653. client := &http.Client{}
  654. bytesData, _ := json.Marshal(data)
  655. var req *http.Request
  656. if miConfig.MdtrtareaAdmvs == "320921" {
  657. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  658. } else {
  659. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  660. }
  661. resp, _ := client.Do(req)
  662. defer resp.Body.Close()
  663. body, ioErr := ioutil.ReadAll(resp.Body)
  664. if ioErr != nil {
  665. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  666. }
  667. var respJSON map[string]interface{}
  668. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  669. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  671. return
  672. }
  673. var resSix10265 ResultSix10265 //1101结果
  674. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  675. result, _ := json.Marshal(respJSON)
  676. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  677. utils.ErrorLog("解析失败:%v", err)
  678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  679. return
  680. }
  681. res2.InfRefmsgid = resSix10265.InfRefmsgid
  682. res2.Output = resSix10265.Output
  683. res2.ErrMsg = resSix10265.ErrMsg
  684. res2.Cainfo = resSix10265.Cainfo
  685. res2.WarnMsg = resSix10265.WarnMsg
  686. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  687. res2.Infcode = infocode
  688. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  689. data := make(map[string]interface{})
  690. data["struct_3501s"] = struct3501
  691. client := &http.Client{}
  692. bytesData, _ := json.Marshal(data)
  693. var req *http.Request
  694. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  695. resp, _ := client.Do(req)
  696. defer resp.Body.Close()
  697. body, ioErr := ioutil.ReadAll(resp.Body)
  698. if ioErr != nil {
  699. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  700. }
  701. var respJSON map[string]interface{}
  702. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  705. return
  706. }
  707. var resSix10265 ResultSix10265 //1101结果
  708. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  709. result, _ := json.Marshal(respJSON)
  710. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  711. utils.ErrorLog("解析失败:%v", err)
  712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  713. return
  714. }
  715. res2.InfRefmsgid = resSix10265.InfRefmsgid
  716. res2.Output = resSix10265.Output
  717. res2.ErrMsg = resSix10265.ErrMsg
  718. res2.Cainfo = resSix10265.Cainfo
  719. res2.WarnMsg = resSix10265.WarnMsg
  720. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  721. res2.Infcode = infocode
  722. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  723. data := make(map[string]interface{})
  724. data["struct_3501s"] = struct3501
  725. client := &http.Client{}
  726. bytesData, _ := json.Marshal(data)
  727. var req *http.Request
  728. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  729. resp, _ := client.Do(req)
  730. defer resp.Body.Close()
  731. body, ioErr := ioutil.ReadAll(resp.Body)
  732. if ioErr != nil {
  733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  734. }
  735. var respJSON map[string]interface{}
  736. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  737. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  739. return
  740. }
  741. var resSix10265 ResultSix10265 //1101结果
  742. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  743. result, _ := json.Marshal(respJSON)
  744. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  745. utils.ErrorLog("解析失败:%v", err)
  746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  747. return
  748. }
  749. res2.InfRefmsgid = resSix10265.InfRefmsgid
  750. res2.Output = resSix10265.Output
  751. res2.ErrMsg = resSix10265.ErrMsg
  752. res2.Cainfo = resSix10265.Cainfo
  753. res2.WarnMsg = resSix10265.WarnMsg
  754. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  755. res2.Infcode = infocode
  756. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  757. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  758. saveLog(result1, result2, "3501", "3501")
  759. //saveLog(result, requestLog, "2201", "挂号")
  760. var respJSON2 map[string]interface{}
  761. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  764. return
  765. }
  766. userJSONBytes2, _ := json.Marshal(respJSON2)
  767. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  768. utils.ErrorLog("解析失败:%v", err)
  769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  770. return
  771. }
  772. }
  773. if res2.Infcode != -1 {
  774. drug.IsPc = 1
  775. drug.Bchno = number
  776. drug.PcDate = time.Now().Unix()
  777. err := service.SaveW(drug)
  778. if err == nil {
  779. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  780. var struct3502 models.Struct3502
  781. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  782. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  783. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  784. struct3502.FixmedinsCode = miConfig.Code
  785. struct3502.Code = miConfig.Code
  786. struct3502.RxFlag = "0"
  787. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  788. struct3502.OrgName = miConfig.OrgName
  789. struct3502.Opter = roles.UserName
  790. struct3502.AccessKey = miConfig.AccessKey
  791. struct3502.RequestUrl = miConfig.Url
  792. struct3502.SecretKey = miConfig.SecretKey
  793. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  794. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  795. struct3502.Url = miConfig.Url
  796. struct3502.AppId = miConfig.Cainfo
  797. struct3502.AppSecret = miConfig.AppSecret
  798. struct3502.Enckey = miConfig.EncKey
  799. struct3502.SignKey = miConfig.SignKey
  800. struct3502.SecretKey = miConfig.SecretKey
  801. struct3502.DrugTracCodg = drug.DrugCode
  802. struct3502.Memo = ""
  803. struct3502.InvChgType = "108"
  804. struct3502.FixmedinsBchno = bg_number
  805. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  806. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  807. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  808. result11, result22, _ := service.FJyb3502(struct3502)
  809. saveLog(result11, result22, "3502", "3502")
  810. var respJSON3 map[string]interface{}
  811. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  814. return
  815. }
  816. userJSONBytes3, _ := json.Marshal(respJSON3)
  817. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  818. utils.ErrorLog("解析失败:%v", err)
  819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  820. return
  821. }
  822. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  823. data := make(map[string]interface{})
  824. data["struct_3502s"] = struct3502
  825. client := &http.Client{}
  826. bytesData, _ := json.Marshal(data)
  827. var req *http.Request
  828. if miConfig.MdtrtareaAdmvs == "320921" {
  829. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  830. } else {
  831. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  832. }
  833. resp, _ := client.Do(req)
  834. defer resp.Body.Close()
  835. body, ioErr := ioutil.ReadAll(resp.Body)
  836. if ioErr != nil {
  837. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  838. }
  839. var respJSON map[string]interface{}
  840. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  841. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  843. return
  844. }
  845. var resSix10265 ResultSix10265 //1101结果
  846. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  847. result, _ := json.Marshal(respJSON)
  848. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  849. utils.ErrorLog("解析失败:%v", err)
  850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  851. return
  852. }
  853. res3.InfRefmsgid = resSix10265.InfRefmsgid
  854. res3.Output = resSix10265.Output
  855. res3.ErrMsg = resSix10265.ErrMsg
  856. res3.Cainfo = resSix10265.Cainfo
  857. res3.WarnMsg = resSix10265.WarnMsg
  858. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  859. res3.Infcode = infocode
  860. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  861. data := make(map[string]interface{})
  862. data["struct_3502s"] = struct3502
  863. client := &http.Client{}
  864. bytesData, _ := json.Marshal(data)
  865. var req *http.Request
  866. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  867. resp, _ := client.Do(req)
  868. defer resp.Body.Close()
  869. body, ioErr := ioutil.ReadAll(resp.Body)
  870. if ioErr != nil {
  871. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  872. }
  873. var respJSON map[string]interface{}
  874. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  875. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  877. return
  878. }
  879. var resSix10265 ResultSix10265 //1101结果
  880. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  881. result, _ := json.Marshal(respJSON)
  882. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  883. utils.ErrorLog("解析失败:%v", err)
  884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  885. return
  886. }
  887. res3.InfRefmsgid = resSix10265.InfRefmsgid
  888. res3.Output = resSix10265.Output
  889. res3.ErrMsg = resSix10265.ErrMsg
  890. res3.Cainfo = resSix10265.Cainfo
  891. res3.WarnMsg = resSix10265.WarnMsg
  892. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  893. res3.Infcode = infocode
  894. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  895. data := make(map[string]interface{})
  896. data["struct_3501s"] = struct3501
  897. client := &http.Client{}
  898. bytesData, _ := json.Marshal(data)
  899. var req *http.Request
  900. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  901. resp, _ := client.Do(req)
  902. defer resp.Body.Close()
  903. body, ioErr := ioutil.ReadAll(resp.Body)
  904. if ioErr != nil {
  905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  906. }
  907. var respJSON map[string]interface{}
  908. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  909. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  911. return
  912. }
  913. var resSix10265 ResultSix10265 //1101结果
  914. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  915. result, _ := json.Marshal(respJSON)
  916. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  917. utils.ErrorLog("解析失败:%v", err)
  918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  919. return
  920. }
  921. res2.InfRefmsgid = resSix10265.InfRefmsgid
  922. res2.Output = resSix10265.Output
  923. res2.ErrMsg = resSix10265.ErrMsg
  924. res2.Cainfo = resSix10265.Cainfo
  925. res2.WarnMsg = resSix10265.WarnMsg
  926. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  927. res2.Infcode = infocode
  928. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  929. result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  930. saveLog(result11, result22, "3502", "3502")
  931. var respJSON3 map[string]interface{}
  932. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  933. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  935. return
  936. }
  937. userJSONBytes3, _ := json.Marshal(respJSON3)
  938. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  939. utils.ErrorLog("解析失败:%v", err)
  940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  941. return
  942. }
  943. }
  944. if res3.Infcode == -1 {
  945. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  946. c.ServeSuccessJSON(map[string]interface{}{
  947. "failed_code": -10,
  948. "msg": res3.ErrMsg,
  949. })
  950. } else {
  951. drug.IsBg = 1
  952. drug.BgBchno = bg_number
  953. service.SaveW(drug)
  954. }
  955. }
  956. } else {
  957. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  958. }
  959. }
  960. //变更
  961. }
  962. if len(errs) == 0 {
  963. c.ServeSuccessJSON(map[string]interface{}{
  964. "msg": "盘存变更成功",
  965. })
  966. } else {
  967. c.ServeSuccessJSON(map[string]interface{}{
  968. "failed_code": -10,
  969. "msg": errs,
  970. })
  971. }
  972. }
  973. func (c *HisApiController) DeletePCandBG() {
  974. ids := c.GetString("ids")
  975. id_arr := strings.Split(ids, ",")
  976. admin_user_id, _ := c.GetInt64("admin_user_id")
  977. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  978. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  979. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  980. var err []string
  981. for _, item := range drugs {
  982. if item.IsPc == 1 && item.IsBg == 1 {
  983. var res FJ3507Result
  984. var res2 FJ3507Result
  985. var struct3507 models.Struct3507
  986. struct3507.FixmedinsBchno = item.Bchno
  987. struct3507.InvDataType = "1"
  988. struct3507.Opter = roles.UserName
  989. struct3507.OrgName = miConfig.OrgName
  990. struct3507.AccessKey = miConfig.AccessKey
  991. struct3507.RequestUrl = miConfig.Url
  992. struct3507.FixmedinsCode = miConfig.Code
  993. struct3507.Code = miConfig.Code
  994. struct3507.SecretKey = miConfig.SecretKey
  995. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  996. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  997. struct3507.Url = miConfig.Url
  998. struct3507.AppId = miConfig.Cainfo
  999. struct3507.AppSecret = miConfig.AppSecret
  1000. struct3507.Enckey = miConfig.EncKey
  1001. struct3507.SignKey = miConfig.SignKey
  1002. struct3507.SecretKey = miConfig.SecretKey
  1003. if miConfig.MdtrtareaAdmvs == "350500" {
  1004. result, result1, _ := service.FJyb3507(struct3507)
  1005. saveLog(result, result1, "3507", "3507")
  1006. var respJSON2 map[string]interface{}
  1007. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1008. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1010. return
  1011. }
  1012. userJSONBytes2, _ := json.Marshal(respJSON2)
  1013. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1014. utils.ErrorLog("解析失败:%v", err)
  1015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1016. return
  1017. }
  1018. } else {
  1019. data := make(map[string]interface{})
  1020. data["struct_3507s"] = struct3507
  1021. client := &http.Client{}
  1022. bytesData, _ := json.Marshal(data)
  1023. var req *http.Request
  1024. if miConfig.MdtrtareaAdmvs == "320921" {
  1025. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1026. } else {
  1027. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1028. }
  1029. resp, _ := client.Do(req)
  1030. defer resp.Body.Close()
  1031. body, ioErr := ioutil.ReadAll(resp.Body)
  1032. if ioErr != nil {
  1033. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1034. }
  1035. var respJSON map[string]interface{}
  1036. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1037. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1039. return
  1040. }
  1041. var resSix10265 ResultSix10265 //1101结果
  1042. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1043. result, _ := json.Marshal(respJSON)
  1044. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1045. utils.ErrorLog("解析失败:%v", err)
  1046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1047. return
  1048. }
  1049. res.InfRefmsgid = resSix10265.InfRefmsgid
  1050. //res.Output = resSix10265.Output
  1051. res.ErrMsg = resSix10265.ErrMsg
  1052. res.Cainfo = resSix10265.Cainfo
  1053. res.WarnMsg = resSix10265.WarnMsg
  1054. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1055. res.Infcode = infocode
  1056. }
  1057. if res.Infcode == 0 {
  1058. item.IsPc = 0
  1059. err2 := service.SaveW(item)
  1060. if err2 == nil {
  1061. var struct3507_2 models.Struct3507
  1062. struct3507_2.OrgName = miConfig.OrgName
  1063. struct3507_2.AccessKey = miConfig.AccessKey
  1064. struct3507_2.RequestUrl = miConfig.Url
  1065. struct3507_2.Opter = roles.UserName
  1066. struct3507_2.FixmedinsCode = miConfig.Code
  1067. struct3507_2.Code = miConfig.Code
  1068. struct3507_2.SecretKey = miConfig.SecretKey
  1069. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1070. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1071. struct3507_2.Url = miConfig.Url
  1072. struct3507_2.AppId = miConfig.Cainfo
  1073. struct3507_2.AppSecret = miConfig.AppSecret
  1074. struct3507_2.Enckey = miConfig.EncKey
  1075. struct3507_2.SignKey = miConfig.SignKey
  1076. struct3507_2.SecretKey = miConfig.SecretKey
  1077. struct3507_2.FixmedinsBchno = item.BgBchno
  1078. struct3507_2.InvDataType = "2"
  1079. if miConfig.MdtrtareaAdmvs == "350500" {
  1080. result11, result22, _ := service.FJyb3507(struct3507_2)
  1081. saveLog(result11, result22, "3507", "3507")
  1082. var respJSON3 map[string]interface{}
  1083. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1084. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1086. return
  1087. }
  1088. userJSONBytes3, _ := json.Marshal(respJSON3)
  1089. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1090. utils.ErrorLog("解析失败:%v", err)
  1091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1092. return
  1093. }
  1094. } else {
  1095. data := make(map[string]interface{})
  1096. data["struct_3507s"] = struct3507_2
  1097. client := &http.Client{}
  1098. bytesData, _ := json.Marshal(data)
  1099. var req *http.Request
  1100. if miConfig.MdtrtareaAdmvs == "320921" {
  1101. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1102. } else {
  1103. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1104. }
  1105. resp, _ := client.Do(req)
  1106. defer resp.Body.Close()
  1107. body, ioErr := ioutil.ReadAll(resp.Body)
  1108. if ioErr != nil {
  1109. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1110. }
  1111. var respJSON map[string]interface{}
  1112. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1115. return
  1116. }
  1117. var resSix10265 ResultSix10265 //1101结果
  1118. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1119. result, _ := json.Marshal(respJSON)
  1120. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1121. utils.ErrorLog("解析失败:%v", err)
  1122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1123. return
  1124. }
  1125. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1126. //res2.Output = resSix10265.Output
  1127. res2.ErrMsg = resSix10265.ErrMsg
  1128. res2.Cainfo = resSix10265.Cainfo
  1129. res2.WarnMsg = resSix10265.WarnMsg
  1130. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1131. res2.Infcode = infocode
  1132. }
  1133. if res2.Infcode != -1 {
  1134. item.IsBg = 0
  1135. item.Bchno = ""
  1136. item.BgBchno = ""
  1137. item.PcDate = 0
  1138. service.SaveW(item)
  1139. } else {
  1140. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1141. }
  1142. }
  1143. } else {
  1144. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1145. }
  1146. }
  1147. if item.IsPc == 1 && item.IsBg == 0 {
  1148. var res FJ3507Result
  1149. var struct3507 models.Struct3507
  1150. struct3507.FixmedinsBchno = item.Bchno
  1151. struct3507.InvDataType = "1"
  1152. struct3507.Opter = roles.UserName
  1153. struct3507.FixmedinsCode = miConfig.Code
  1154. struct3507.Code = miConfig.Code
  1155. struct3507.OrgName = miConfig.OrgName
  1156. struct3507.AccessKey = miConfig.AccessKey
  1157. struct3507.RequestUrl = miConfig.Url
  1158. struct3507.SecretKey = miConfig.SecretKey
  1159. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1160. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1161. struct3507.Url = miConfig.Url
  1162. struct3507.AppId = miConfig.Cainfo
  1163. struct3507.AppSecret = miConfig.AppSecret
  1164. struct3507.Enckey = miConfig.EncKey
  1165. struct3507.SignKey = miConfig.SignKey
  1166. struct3507.SecretKey = miConfig.SecretKey
  1167. //result, result1, _ := service.FJyb3507(struct3507)
  1168. //saveLog(result, result1, "3507", "3507")
  1169. if miConfig.MdtrtareaAdmvs == "350500" {
  1170. result, result1, _ := service.FJyb3507(struct3507)
  1171. saveLog(result, result1, "3507", "3507")
  1172. var respJSON2 map[string]interface{}
  1173. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1176. return
  1177. }
  1178. userJSONBytes2, _ := json.Marshal(respJSON2)
  1179. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1180. utils.ErrorLog("解析失败:%v", err)
  1181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1182. return
  1183. }
  1184. } else {
  1185. data := make(map[string]interface{})
  1186. data["struct_3507s"] = struct3507
  1187. client := &http.Client{}
  1188. bytesData, _ := json.Marshal(data)
  1189. var req *http.Request
  1190. if miConfig.MdtrtareaAdmvs == "320921" {
  1191. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1192. } else {
  1193. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1194. }
  1195. resp, _ := client.Do(req)
  1196. defer resp.Body.Close()
  1197. body, ioErr := ioutil.ReadAll(resp.Body)
  1198. if ioErr != nil {
  1199. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1200. }
  1201. var respJSON map[string]interface{}
  1202. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1205. return
  1206. }
  1207. var resSix10265 ResultSix10265 //1101结果
  1208. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1209. result, _ := json.Marshal(respJSON)
  1210. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1211. utils.ErrorLog("解析失败:%v", err)
  1212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1213. return
  1214. }
  1215. res.InfRefmsgid = resSix10265.InfRefmsgid
  1216. //res.Output = resSix10265.Output
  1217. res.ErrMsg = resSix10265.ErrMsg
  1218. res.Cainfo = resSix10265.Cainfo
  1219. res.WarnMsg = resSix10265.WarnMsg
  1220. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1221. res.Infcode = infocode
  1222. }
  1223. if res.Infcode == 0 {
  1224. item.IsPc = 0
  1225. item.Bchno = ""
  1226. item.BgBchno = ""
  1227. item.PcDate = 0
  1228. service.SaveW(item)
  1229. } else {
  1230. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1231. }
  1232. }
  1233. if item.IsPc == 0 && item.IsBg == 1 {
  1234. var res FJ3507Result
  1235. var struct3507 models.Struct3507
  1236. struct3507.FixmedinsBchno = item.BgBchno
  1237. struct3507.InvDataType = "2"
  1238. struct3507.Opter = roles.UserName
  1239. struct3507.FixmedinsCode = miConfig.Code
  1240. struct3507.OrgName = miConfig.OrgName
  1241. struct3507.AccessKey = miConfig.AccessKey
  1242. struct3507.RequestUrl = miConfig.Url
  1243. struct3507.SecretKey = miConfig.SecretKey
  1244. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1245. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1246. struct3507.Url = miConfig.Url
  1247. struct3507.AppId = miConfig.Cainfo
  1248. struct3507.AppSecret = miConfig.AppSecret
  1249. struct3507.Enckey = miConfig.EncKey
  1250. struct3507.SignKey = miConfig.SignKey
  1251. struct3507.SecretKey = miConfig.SecretKey
  1252. //result, result1, _ := service.FJyb3507(struct3507)
  1253. //saveLog(result, result1, "3507", "3507")
  1254. if miConfig.MdtrtareaAdmvs == "350500" {
  1255. result, result1, _ := service.FJyb3507(struct3507)
  1256. saveLog(result, result1, "3507", "3507")
  1257. var respJSON2 map[string]interface{}
  1258. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1261. return
  1262. }
  1263. userJSONBytes2, _ := json.Marshal(respJSON2)
  1264. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1265. utils.ErrorLog("解析失败:%v", err)
  1266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1267. return
  1268. }
  1269. } else {
  1270. data := make(map[string]interface{})
  1271. data["struct_3507s"] = struct3507
  1272. client := &http.Client{}
  1273. bytesData, _ := json.Marshal(data)
  1274. var req *http.Request
  1275. if miConfig.MdtrtareaAdmvs == "320921" {
  1276. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1277. } else {
  1278. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1279. }
  1280. resp, _ := client.Do(req)
  1281. defer resp.Body.Close()
  1282. body, ioErr := ioutil.ReadAll(resp.Body)
  1283. if ioErr != nil {
  1284. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1285. }
  1286. var respJSON map[string]interface{}
  1287. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1290. return
  1291. }
  1292. var resSix10265 ResultSix10265 //1101结果
  1293. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1294. result, _ := json.Marshal(respJSON)
  1295. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1296. utils.ErrorLog("解析失败:%v", err)
  1297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1298. return
  1299. }
  1300. res.InfRefmsgid = resSix10265.InfRefmsgid
  1301. //res.Output = resSix10265.Output
  1302. res.ErrMsg = resSix10265.ErrMsg
  1303. res.Cainfo = resSix10265.Cainfo
  1304. res.WarnMsg = resSix10265.WarnMsg
  1305. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1306. res.Infcode = infocode
  1307. }
  1308. if res.Infcode == 0 {
  1309. item.IsBg = 0
  1310. item.Bchno = ""
  1311. item.BgBchno = ""
  1312. item.PcDate = 0
  1313. service.SaveW(item)
  1314. } else {
  1315. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1316. }
  1317. }
  1318. }
  1319. if len(err) == 0 {
  1320. c.ServeSuccessJSON(map[string]interface{}{
  1321. "msg": "删除盘存变更成功",
  1322. })
  1323. } else {
  1324. c.ServeSuccessJSON(map[string]interface{}{
  1325. "failed_code": -10,
  1326. "msg": err,
  1327. })
  1328. }
  1329. }
  1330. func (c *HisApiController) DeleteXSandBG() {
  1331. ids := c.GetString("ids")
  1332. id_arr := strings.Split(ids, ",")
  1333. admin_user_id, _ := c.GetInt64("admin_user_id")
  1334. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1335. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1336. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1337. var err []string
  1338. for _, item := range flows {
  1339. if item.IsSale == 1 && item.IsChange == 1 {
  1340. var res FJ3507Result
  1341. var res2 FJ3507Result
  1342. var struct3507 models.Struct3507
  1343. struct3507.FixmedinsBchno = item.Bchno
  1344. struct3507.InvDataType = "4"
  1345. struct3507.Opter = roles.UserName
  1346. struct3507.OrgName = miConfig.OrgName
  1347. struct3507.AccessKey = miConfig.AccessKey
  1348. struct3507.RequestUrl = miConfig.Url
  1349. struct3507.FixmedinsCode = miConfig.Code
  1350. struct3507.SecretKey = miConfig.SecretKey
  1351. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1352. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1353. struct3507.Url = miConfig.Url
  1354. struct3507.AppId = miConfig.Cainfo
  1355. struct3507.AppSecret = miConfig.AppSecret
  1356. struct3507.Enckey = miConfig.EncKey
  1357. struct3507.SignKey = miConfig.SignKey
  1358. struct3507.SecretKey = miConfig.SecretKey
  1359. //result, result1, _ := service.FJyb3507(struct3507)
  1360. //saveLog(result, result1, "3507", "3507")
  1361. if miConfig.MdtrtareaAdmvs == "350500" {
  1362. result, result1, _ := service.FJyb3507(struct3507)
  1363. saveLog(result, result1, "3507", "3507")
  1364. var respJSON2 map[string]interface{}
  1365. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1368. return
  1369. }
  1370. userJSONBytes2, _ := json.Marshal(respJSON2)
  1371. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1372. utils.ErrorLog("解析失败:%v", err)
  1373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1374. return
  1375. }
  1376. } else {
  1377. data := make(map[string]interface{})
  1378. data["struct_3507s"] = struct3507
  1379. client := &http.Client{}
  1380. bytesData, _ := json.Marshal(data)
  1381. var req *http.Request
  1382. if miConfig.MdtrtareaAdmvs == "320921" {
  1383. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1384. } else {
  1385. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1386. }
  1387. resp, _ := client.Do(req)
  1388. defer resp.Body.Close()
  1389. body, ioErr := ioutil.ReadAll(resp.Body)
  1390. if ioErr != nil {
  1391. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1392. }
  1393. var respJSON map[string]interface{}
  1394. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1397. return
  1398. }
  1399. var resSix10265 ResultSix10265 //1101结果
  1400. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1401. result, _ := json.Marshal(respJSON)
  1402. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1403. utils.ErrorLog("解析失败:%v", err)
  1404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1405. return
  1406. }
  1407. res.InfRefmsgid = resSix10265.InfRefmsgid
  1408. //res.Output = resSix10265.Output
  1409. res.ErrMsg = resSix10265.ErrMsg
  1410. res.Cainfo = resSix10265.Cainfo
  1411. res.WarnMsg = resSix10265.WarnMsg
  1412. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1413. res.Infcode = infocode
  1414. }
  1415. if res.Infcode == 0 {
  1416. item.IsSale = 0
  1417. item.SaleDate = ""
  1418. item.Bchno = ""
  1419. err2 := service.SaveDF(item)
  1420. if err2 == nil {
  1421. var struct3507_2 models.Struct3507
  1422. struct3507_2.OrgName = miConfig.OrgName
  1423. struct3507_2.AccessKey = miConfig.AccessKey
  1424. struct3507_2.RequestUrl = miConfig.Url
  1425. struct3507_2.Opter = roles.UserName
  1426. struct3507_2.FixmedinsCode = miConfig.Code
  1427. struct3507_2.Code = miConfig.Code
  1428. struct3507_2.SecretKey = miConfig.SecretKey
  1429. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1430. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1431. struct3507_2.Url = miConfig.Url
  1432. struct3507_2.AppId = miConfig.Cainfo
  1433. struct3507_2.AppSecret = miConfig.AppSecret
  1434. struct3507_2.Enckey = miConfig.EncKey
  1435. struct3507_2.SignKey = miConfig.SignKey
  1436. struct3507_2.SecretKey = miConfig.SecretKey
  1437. struct3507_2.FixmedinsBchno = item.BgBchno
  1438. struct3507_2.InvDataType = "2"
  1439. if miConfig.MdtrtareaAdmvs == "350500" {
  1440. result11, result22, _ := service.FJyb3507(struct3507_2)
  1441. saveLog(result11, result22, "3507", "3507")
  1442. var respJSON3 map[string]interface{}
  1443. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1444. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1446. return
  1447. }
  1448. userJSONBytes3, _ := json.Marshal(respJSON3)
  1449. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1450. utils.ErrorLog("解析失败:%v", err)
  1451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1452. return
  1453. }
  1454. } else {
  1455. data := make(map[string]interface{})
  1456. data["struct_3507s"] = struct3507_2
  1457. client := &http.Client{}
  1458. bytesData, _ := json.Marshal(data)
  1459. var req *http.Request
  1460. if miConfig.MdtrtareaAdmvs == "320921" {
  1461. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1462. } else {
  1463. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1464. }
  1465. resp, _ := client.Do(req)
  1466. defer resp.Body.Close()
  1467. body, ioErr := ioutil.ReadAll(resp.Body)
  1468. if ioErr != nil {
  1469. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1470. }
  1471. var respJSON map[string]interface{}
  1472. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1475. return
  1476. }
  1477. var resSix10265 ResultSix10265 //1101结果
  1478. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1479. result, _ := json.Marshal(respJSON)
  1480. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1481. utils.ErrorLog("解析失败:%v", err)
  1482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1483. return
  1484. }
  1485. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1486. //res.Output = resSix10265.Output
  1487. res2.ErrMsg = resSix10265.ErrMsg
  1488. res2.Cainfo = resSix10265.Cainfo
  1489. res2.WarnMsg = resSix10265.WarnMsg
  1490. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1491. res2.Infcode = infocode
  1492. }
  1493. if res2.Infcode == 0 {
  1494. item.IsChange = 0
  1495. item.BgBchno = ""
  1496. service.SaveDF2(item)
  1497. } else {
  1498. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1499. }
  1500. }
  1501. } else {
  1502. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1503. }
  1504. }
  1505. if item.IsSale == 2 && item.IsChange == 1 {
  1506. var res FJ3507Result
  1507. var res2 FJ3507Result
  1508. var struct3507 models.Struct3507
  1509. struct3507.FixmedinsBchno = item.Bchno
  1510. struct3507.InvDataType = "4"
  1511. struct3507.Opter = roles.UserName
  1512. struct3507.OrgName = miConfig.OrgName
  1513. struct3507.AccessKey = miConfig.AccessKey
  1514. struct3507.RequestUrl = miConfig.Url
  1515. struct3507.FixmedinsCode = miConfig.Code
  1516. struct3507.Code = miConfig.Code
  1517. struct3507.SecretKey = miConfig.SecretKey
  1518. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1519. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1520. struct3507.Url = miConfig.Url
  1521. struct3507.AppId = miConfig.Cainfo
  1522. struct3507.AppSecret = miConfig.AppSecret
  1523. struct3507.Enckey = miConfig.EncKey
  1524. struct3507.SignKey = miConfig.SignKey
  1525. struct3507.SecretKey = miConfig.SecretKey
  1526. //result, result1, _ := service.FJyb3507(struct3507)
  1527. //saveLog(result, result1, "3507", "3507")
  1528. //
  1529. //var respJSON2 map[string]interface{}
  1530. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1531. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1532. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1533. // return
  1534. //}
  1535. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1536. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1537. // utils.ErrorLog("解析失败:%v", err)
  1538. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1539. // return
  1540. //}
  1541. if miConfig.MdtrtareaAdmvs == "350500" {
  1542. result, result1, _ := service.FJyb3507(struct3507)
  1543. saveLog(result, result1, "3507", "3507")
  1544. var respJSON2 map[string]interface{}
  1545. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1548. return
  1549. }
  1550. userJSONBytes2, _ := json.Marshal(respJSON2)
  1551. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1552. utils.ErrorLog("解析失败:%v", err)
  1553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1554. return
  1555. }
  1556. } else {
  1557. data := make(map[string]interface{})
  1558. data["struct_3507s"] = struct3507
  1559. client := &http.Client{}
  1560. bytesData, _ := json.Marshal(data)
  1561. var req *http.Request
  1562. if miConfig.MdtrtareaAdmvs == "320921" {
  1563. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1564. } else {
  1565. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1566. }
  1567. resp, _ := client.Do(req)
  1568. defer resp.Body.Close()
  1569. body, ioErr := ioutil.ReadAll(resp.Body)
  1570. if ioErr != nil {
  1571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1572. }
  1573. var respJSON map[string]interface{}
  1574. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1577. return
  1578. }
  1579. var resSix10265 ResultSix10265 //1101结果
  1580. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1581. result, _ := json.Marshal(respJSON)
  1582. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1583. utils.ErrorLog("解析失败:%v", err)
  1584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1585. return
  1586. }
  1587. res.InfRefmsgid = resSix10265.InfRefmsgid
  1588. //res.Output = resSix10265.Output
  1589. res.ErrMsg = resSix10265.ErrMsg
  1590. res.Cainfo = resSix10265.Cainfo
  1591. res.WarnMsg = resSix10265.WarnMsg
  1592. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1593. res.Infcode = infocode
  1594. }
  1595. if res.Infcode == 0 {
  1596. item.IsSale = 0
  1597. item.SaleDate = ""
  1598. item.Bchno = ""
  1599. err2 := service.SaveDF(item)
  1600. if err2 == nil {
  1601. var struct3507_2 models.Struct3507
  1602. struct3507_2.OrgName = miConfig.OrgName
  1603. struct3507_2.AccessKey = miConfig.AccessKey
  1604. struct3507_2.RequestUrl = miConfig.Url
  1605. struct3507_2.Opter = roles.UserName
  1606. struct3507_2.FixmedinsCode = miConfig.Code
  1607. struct3507_2.Code = miConfig.Code
  1608. struct3507_2.SecretKey = miConfig.SecretKey
  1609. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1610. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1611. struct3507_2.Url = miConfig.Url
  1612. struct3507_2.AppId = miConfig.Cainfo
  1613. struct3507_2.AppSecret = miConfig.AppSecret
  1614. struct3507_2.Enckey = miConfig.EncKey
  1615. struct3507_2.SignKey = miConfig.SignKey
  1616. struct3507_2.SecretKey = miConfig.SecretKey
  1617. struct3507_2.FixmedinsBchno = item.BgBchno
  1618. struct3507_2.InvDataType = "2"
  1619. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1620. //saveLog(result11, result22, "3507", "3507")
  1621. //var respJSON3 map[string]interface{}
  1622. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1623. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1624. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1625. // return
  1626. //}
  1627. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1628. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1629. // utils.ErrorLog("解析失败:%v", err)
  1630. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1631. // return
  1632. //}
  1633. if miConfig.MdtrtareaAdmvs == "350500" {
  1634. result11, result22, _ := service.FJyb3507(struct3507_2)
  1635. saveLog(result11, result22, "3507", "3507")
  1636. var respJSON3 map[string]interface{}
  1637. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1640. return
  1641. }
  1642. userJSONBytes3, _ := json.Marshal(respJSON3)
  1643. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1644. utils.ErrorLog("解析失败:%v", err)
  1645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1646. return
  1647. }
  1648. } else {
  1649. data := make(map[string]interface{})
  1650. data["struct_3507s"] = struct3507_2
  1651. client := &http.Client{}
  1652. bytesData, _ := json.Marshal(data)
  1653. var req *http.Request
  1654. if miConfig.MdtrtareaAdmvs == "320921" {
  1655. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1656. } else {
  1657. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1658. }
  1659. resp, _ := client.Do(req)
  1660. defer resp.Body.Close()
  1661. body, ioErr := ioutil.ReadAll(resp.Body)
  1662. if ioErr != nil {
  1663. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1664. }
  1665. var respJSON map[string]interface{}
  1666. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1669. return
  1670. }
  1671. var resSix10265 ResultSix10265 //1101结果
  1672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1673. result, _ := json.Marshal(respJSON)
  1674. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1675. utils.ErrorLog("解析失败:%v", err)
  1676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1677. return
  1678. }
  1679. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1680. //res.Output = resSix10265.Output
  1681. res2.ErrMsg = resSix10265.ErrMsg
  1682. res2.Cainfo = resSix10265.Cainfo
  1683. res2.WarnMsg = resSix10265.WarnMsg
  1684. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1685. res2.Infcode = infocode
  1686. }
  1687. if res2.Infcode == 0 {
  1688. item.IsChange = 0
  1689. item.BgBchno = ""
  1690. service.SaveDF2(item)
  1691. } else {
  1692. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1693. }
  1694. }
  1695. } else {
  1696. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1697. }
  1698. }
  1699. if item.IsSale == 1 && item.IsChange == 0 {
  1700. var res FJ3507Result
  1701. var struct3507 models.Struct3507
  1702. struct3507.FixmedinsBchno = item.Bchno
  1703. struct3507.InvDataType = "4"
  1704. struct3507.Opter = roles.UserName
  1705. struct3507.FixmedinsCode = miConfig.Code
  1706. struct3507.Code = miConfig.Code
  1707. struct3507.OrgName = miConfig.OrgName
  1708. struct3507.AccessKey = miConfig.AccessKey
  1709. struct3507.RequestUrl = miConfig.Url
  1710. struct3507.SecretKey = miConfig.SecretKey
  1711. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1712. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1713. struct3507.Url = miConfig.Url
  1714. struct3507.AppId = miConfig.Cainfo
  1715. struct3507.AppSecret = miConfig.AppSecret
  1716. struct3507.Enckey = miConfig.EncKey
  1717. struct3507.SignKey = miConfig.SignKey
  1718. struct3507.SecretKey = miConfig.SecretKey
  1719. //result, result1, _ := service.FJyb3507(struct3507)
  1720. //saveLog(result, result1, "3507", "3507")
  1721. //
  1722. //var respJSON3 map[string]interface{}
  1723. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1724. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1725. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1726. // return
  1727. //}
  1728. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1729. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1730. // utils.ErrorLog("解析失败:%v", err)
  1731. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1732. // return
  1733. //}
  1734. if miConfig.MdtrtareaAdmvs == "350500" {
  1735. result, result1, _ := service.FJyb3507(struct3507)
  1736. saveLog(result, result1, "3507", "3507")
  1737. var respJSON2 map[string]interface{}
  1738. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1741. return
  1742. }
  1743. userJSONBytes2, _ := json.Marshal(respJSON2)
  1744. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1745. utils.ErrorLog("解析失败:%v", err)
  1746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1747. return
  1748. }
  1749. } else {
  1750. data := make(map[string]interface{})
  1751. data["struct_3507s"] = struct3507
  1752. client := &http.Client{}
  1753. bytesData, _ := json.Marshal(data)
  1754. var req *http.Request
  1755. if miConfig.MdtrtareaAdmvs == "320921" {
  1756. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1757. } else {
  1758. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1759. }
  1760. resp, _ := client.Do(req)
  1761. defer resp.Body.Close()
  1762. body, ioErr := ioutil.ReadAll(resp.Body)
  1763. if ioErr != nil {
  1764. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1765. }
  1766. var respJSON map[string]interface{}
  1767. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1770. return
  1771. }
  1772. var resSix10265 ResultSix10265 //1101结果
  1773. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1774. result, _ := json.Marshal(respJSON)
  1775. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1776. utils.ErrorLog("解析失败:%v", err)
  1777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1778. return
  1779. }
  1780. res.InfRefmsgid = resSix10265.InfRefmsgid
  1781. //res.Output = resSix10265.Output
  1782. res.ErrMsg = resSix10265.ErrMsg
  1783. res.Cainfo = resSix10265.Cainfo
  1784. res.WarnMsg = resSix10265.WarnMsg
  1785. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1786. res.Infcode = infocode
  1787. }
  1788. if res.Infcode == 0 {
  1789. item.IsSale = 0
  1790. item.SaleDate = ""
  1791. service.SaveDF(item)
  1792. } else {
  1793. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1794. }
  1795. }
  1796. if item.IsSale == 2 && item.IsChange == 0 {
  1797. var res FJ3507Result
  1798. var struct3507 models.Struct3507
  1799. struct3507.FixmedinsBchno = item.Bchno
  1800. struct3507.InvDataType = "4"
  1801. struct3507.Opter = roles.UserName
  1802. struct3507.FixmedinsCode = miConfig.Code
  1803. struct3507.Code = miConfig.Code
  1804. struct3507.OrgName = miConfig.OrgName
  1805. struct3507.AccessKey = miConfig.AccessKey
  1806. struct3507.RequestUrl = miConfig.Url
  1807. struct3507.SecretKey = miConfig.SecretKey
  1808. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1809. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1810. struct3507.Url = miConfig.Url
  1811. struct3507.AppId = miConfig.Cainfo
  1812. struct3507.AppSecret = miConfig.AppSecret
  1813. struct3507.Enckey = miConfig.EncKey
  1814. struct3507.SignKey = miConfig.SignKey
  1815. struct3507.SecretKey = miConfig.SecretKey
  1816. //result, result1, _ := service.FJyb3507(struct3507)
  1817. //saveLog(result, result1, "3507", "3507")
  1818. //
  1819. //var respJSON3 map[string]interface{}
  1820. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1821. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1822. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1823. // return
  1824. //}
  1825. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1826. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1827. // utils.ErrorLog("解析失败:%v", err)
  1828. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1829. // return
  1830. //}
  1831. if miConfig.MdtrtareaAdmvs == "350500" {
  1832. result, result1, _ := service.FJyb3507(struct3507)
  1833. saveLog(result, result1, "3507", "3507")
  1834. var respJSON2 map[string]interface{}
  1835. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1838. return
  1839. }
  1840. userJSONBytes2, _ := json.Marshal(respJSON2)
  1841. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1842. utils.ErrorLog("解析失败:%v", err)
  1843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1844. return
  1845. }
  1846. } else {
  1847. data := make(map[string]interface{})
  1848. data["struct_3507s"] = struct3507
  1849. client := &http.Client{}
  1850. bytesData, _ := json.Marshal(data)
  1851. var req *http.Request
  1852. if miConfig.MdtrtareaAdmvs == "320921" {
  1853. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1854. } else {
  1855. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1856. }
  1857. resp, _ := client.Do(req)
  1858. defer resp.Body.Close()
  1859. body, ioErr := ioutil.ReadAll(resp.Body)
  1860. if ioErr != nil {
  1861. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1862. }
  1863. var respJSON map[string]interface{}
  1864. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1867. return
  1868. }
  1869. var resSix10265 ResultSix10265 //1101结果
  1870. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1871. result, _ := json.Marshal(respJSON)
  1872. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1873. utils.ErrorLog("解析失败:%v", err)
  1874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1875. return
  1876. }
  1877. res.InfRefmsgid = resSix10265.InfRefmsgid
  1878. //res.Output = resSix10265.Output
  1879. res.ErrMsg = resSix10265.ErrMsg
  1880. res.Cainfo = resSix10265.Cainfo
  1881. res.WarnMsg = resSix10265.WarnMsg
  1882. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1883. res.Infcode = infocode
  1884. }
  1885. if res.Infcode == 0 {
  1886. item.IsSale = 0
  1887. item.SaleDate = ""
  1888. item.Bchno = ""
  1889. service.SaveDF(item)
  1890. } else {
  1891. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1892. }
  1893. }
  1894. if item.IsSale == 0 && item.IsChange == 1 {
  1895. var res FJ3507Result
  1896. var struct3507 models.Struct3507
  1897. struct3507.FixmedinsBchno = item.BgBchno
  1898. struct3507.InvDataType = "2"
  1899. struct3507.Opter = roles.UserName
  1900. struct3507.FixmedinsCode = miConfig.Code
  1901. struct3507.Code = miConfig.Code
  1902. struct3507.OrgName = miConfig.OrgName
  1903. struct3507.AccessKey = miConfig.AccessKey
  1904. struct3507.RequestUrl = miConfig.Url
  1905. struct3507.SecretKey = miConfig.SecretKey
  1906. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1907. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1908. struct3507.Url = miConfig.Url
  1909. struct3507.AppId = miConfig.Cainfo
  1910. struct3507.AppSecret = miConfig.AppSecret
  1911. struct3507.Enckey = miConfig.EncKey
  1912. struct3507.SignKey = miConfig.SignKey
  1913. struct3507.SecretKey = miConfig.SecretKey
  1914. //result, result1, _ := service.FJyb3507(struct3507)
  1915. //saveLog(result, result1, "3507", "3507")
  1916. //
  1917. //var respJSON3 map[string]interface{}
  1918. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1919. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1920. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1921. // return
  1922. //}
  1923. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1924. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1925. // utils.ErrorLog("解析失败:%v", err)
  1926. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1927. // return
  1928. //}
  1929. if miConfig.MdtrtareaAdmvs == "350500" {
  1930. result, result1, _ := service.FJyb3507(struct3507)
  1931. saveLog(result, result1, "3507", "3507")
  1932. var respJSON2 map[string]interface{}
  1933. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1934. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1936. return
  1937. }
  1938. userJSONBytes2, _ := json.Marshal(respJSON2)
  1939. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1940. utils.ErrorLog("解析失败:%v", err)
  1941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1942. return
  1943. }
  1944. } else {
  1945. data := make(map[string]interface{})
  1946. data["struct_3507s"] = struct3507
  1947. client := &http.Client{}
  1948. bytesData, _ := json.Marshal(data)
  1949. var req *http.Request
  1950. if miConfig.MdtrtareaAdmvs == "320921" {
  1951. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1952. } else {
  1953. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1954. }
  1955. resp, _ := client.Do(req)
  1956. defer resp.Body.Close()
  1957. body, ioErr := ioutil.ReadAll(resp.Body)
  1958. if ioErr != nil {
  1959. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1960. }
  1961. var respJSON map[string]interface{}
  1962. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1963. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1965. return
  1966. }
  1967. var resSix10265 ResultSix10265 //1101结果
  1968. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1969. result, _ := json.Marshal(respJSON)
  1970. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1971. utils.ErrorLog("解析失败:%v", err)
  1972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1973. return
  1974. }
  1975. res.InfRefmsgid = resSix10265.InfRefmsgid
  1976. //res.Output = resSix10265.Output
  1977. res.ErrMsg = resSix10265.ErrMsg
  1978. res.Cainfo = resSix10265.Cainfo
  1979. res.WarnMsg = resSix10265.WarnMsg
  1980. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1981. res.Infcode = infocode
  1982. }
  1983. if res.Infcode == 0 {
  1984. item.IsChange = 0
  1985. item.BgBchno = ""
  1986. service.SaveDF2(item)
  1987. } else {
  1988. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1989. }
  1990. }
  1991. }
  1992. if len(err) == 0 {
  1993. c.ServeSuccessJSON(map[string]interface{}{
  1994. "msg": "删除销售变更成功",
  1995. })
  1996. } else {
  1997. c.ServeSuccessJSON(map[string]interface{}{
  1998. "failed_code": -10,
  1999. "msg": err,
  2000. })
  2001. }
  2002. }
  2003. //func (c *HisApiController) BatchFJ3501AND3502() {
  2004. // //ids := c.GetString("ids")
  2005. // start_time := c.GetString("start_time")
  2006. // end_time := c.GetString("end_time")
  2007. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2008. //
  2009. //
  2010. // timeLayout := "2006-01-02"
  2011. // loc, _ := time.LoadLocation("Local")
  2012. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2013. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2014. //
  2015. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2016. // //id_arr := strings.Split(ids, ",")
  2017. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2018. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2019. // //库盘
  2020. // var errs []string
  2021. // for _, drug := range drugs {
  2022. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2023. // var res2 ResultSix
  2024. // var res3 ResultSix
  2025. //
  2026. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2027. // var struct3501 models.Struct3501
  2028. // struct3501.Code = miConfig.Code
  2029. // struct3501.OrgName = miConfig.OrgName
  2030. // struct3501.AccessKey = miConfig.AccessKey
  2031. // struct3501.Opter = roles.UserName
  2032. // struct3501.RequestUrl = miConfig.Url
  2033. // struct3501.Url = miConfig.Url
  2034. // struct3501.AppId = miConfig.Cainfo
  2035. // struct3501.AppSecret = miConfig.AppSecret
  2036. // struct3501.Enckey = miConfig.EncKey
  2037. // struct3501.SignKey = miConfig.SignKey
  2038. // struct3501.SecretKey = miConfig.SecretKey
  2039. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2040. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2041. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2042. // struct3501.RxFlag = "1"
  2043. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2044. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2045. //
  2046. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2047. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2048. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2049. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2050. // struct3501.FixmedinsBchno = number
  2051. // struct3501.DrugTracCodg = drug.DrugCode
  2052. // memo := make(map[string]interface{})
  2053. // memo["pric"] = drug.Price
  2054. // bytesData, _ := json.Marshal(memo)
  2055. // struct3501.Memo = string(bytesData)
  2056. //
  2057. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2058. //
  2059. // result1, result2, _ := service.FJyb3501(struct3501)
  2060. // saveLog(result1, result2, "3501", "3501")
  2061. // //saveLog(result, requestLog, "2201", "挂号")
  2062. //
  2063. // var respJSON2 map[string]interface{}
  2064. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2065. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2066. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2067. // return
  2068. // }
  2069. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2070. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2071. // utils.ErrorLog("解析失败:%v", err)
  2072. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2073. // return
  2074. // }
  2075. //
  2076. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2077. // data := make(map[string]interface{})
  2078. // data["struct_3501s"] = struct3501
  2079. // client := &http.Client{}
  2080. // bytesData, _ := json.Marshal(data)
  2081. // var req *http.Request
  2082. // if miConfig.MdtrtareaAdmvs == "320921" {
  2083. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2084. // } else {
  2085. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2086. // }
  2087. //
  2088. // resp, _ := client.Do(req)
  2089. // defer resp.Body.Close()
  2090. // body, ioErr := ioutil.ReadAll(resp.Body)
  2091. // if ioErr != nil {
  2092. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2093. // }
  2094. // var respJSON map[string]interface{}
  2095. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2096. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2097. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2098. // return
  2099. // }
  2100. // var resSix10265 ResultSix10265 //1101结果
  2101. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2102. // result, _ := json.Marshal(respJSON)
  2103. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2104. // utils.ErrorLog("解析失败:%v", err)
  2105. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2106. // return
  2107. // }
  2108. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2109. // res2.Output = resSix10265.Output
  2110. // res2.ErrMsg = resSix10265.ErrMsg
  2111. // res2.Cainfo = resSix10265.Cainfo
  2112. // res2.WarnMsg = resSix10265.WarnMsg
  2113. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2114. // res2.Infcode = infocode
  2115. //
  2116. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2117. // data := make(map[string]interface{})
  2118. // data["struct_3501s"] = struct3501
  2119. // client := &http.Client{}
  2120. // bytesData, _ := json.Marshal(data)
  2121. // var req *http.Request
  2122. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2123. // resp, _ := client.Do(req)
  2124. // defer resp.Body.Close()
  2125. // body, ioErr := ioutil.ReadAll(resp.Body)
  2126. // if ioErr != nil {
  2127. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2128. // }
  2129. // var respJSON map[string]interface{}
  2130. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2131. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2132. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2133. // return
  2134. // }
  2135. // var resSix10265 ResultSix10265 //1101结果
  2136. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2137. // result, _ := json.Marshal(respJSON)
  2138. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2139. // utils.ErrorLog("解析失败:%v", err)
  2140. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2141. // return
  2142. // }
  2143. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2144. // res2.Output = resSix10265.Output
  2145. // res2.ErrMsg = resSix10265.ErrMsg
  2146. // res2.Cainfo = resSix10265.Cainfo
  2147. // res2.WarnMsg = resSix10265.WarnMsg
  2148. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2149. // res2.Infcode = infocode
  2150. //
  2151. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2152. // data := make(map[string]interface{})
  2153. // data["struct_3501s"] = struct3501
  2154. // client := &http.Client{}
  2155. // bytesData, _ := json.Marshal(data)
  2156. // var req *http.Request
  2157. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2158. // resp, _ := client.Do(req)
  2159. // defer resp.Body.Close()
  2160. // body, ioErr := ioutil.ReadAll(resp.Body)
  2161. // if ioErr != nil {
  2162. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2163. // }
  2164. // var respJSON map[string]interface{}
  2165. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2166. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2167. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2168. // return
  2169. // }
  2170. // var resSix10265 ResultSix10265 //1101结果
  2171. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2172. // result, _ := json.Marshal(respJSON)
  2173. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2174. // utils.ErrorLog("解析失败:%v", err)
  2175. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2176. // return
  2177. // }
  2178. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2179. // res2.Output = resSix10265.Output
  2180. // res2.ErrMsg = resSix10265.ErrMsg
  2181. // res2.Cainfo = resSix10265.Cainfo
  2182. // res2.WarnMsg = resSix10265.WarnMsg
  2183. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2184. // res2.Infcode = infocode
  2185. //
  2186. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2187. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2188. // saveLog(result1, result2, "3501", "3501")
  2189. // //saveLog(result, requestLog, "2201", "挂号")
  2190. //
  2191. // var respJSON2 map[string]interface{}
  2192. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2193. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2195. // return
  2196. // }
  2197. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2198. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2199. // utils.ErrorLog("解析失败:%v", err)
  2200. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2201. // return
  2202. // }
  2203. //
  2204. // }
  2205. //
  2206. // if res2.Infcode != -1 {
  2207. // drug.IsPc = 1
  2208. // drug.Bchno = number
  2209. // drug.PcDate = time.Now().Unix()
  2210. // err := service.SaveW(drug)
  2211. // if err == nil {
  2212. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2213. // var struct3502 models.Struct3502
  2214. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2215. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2216. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2217. // struct3502.FixmedinsCode = miConfig.Code
  2218. // struct3502.Code = miConfig.Code
  2219. //
  2220. // struct3502.RxFlag = "0"
  2221. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2222. // struct3502.OrgName = miConfig.OrgName
  2223. // struct3502.Opter = roles.UserName
  2224. // struct3502.AccessKey = miConfig.AccessKey
  2225. // struct3502.RequestUrl = miConfig.Url
  2226. // struct3502.SecretKey = miConfig.SecretKey
  2227. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2228. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2229. // struct3502.Url = miConfig.Url
  2230. // struct3502.AppId = miConfig.Cainfo
  2231. // struct3502.AppSecret = miConfig.AppSecret
  2232. // struct3502.Enckey = miConfig.EncKey
  2233. // struct3502.SignKey = miConfig.SignKey
  2234. // struct3502.SecretKey = miConfig.SecretKey
  2235. // struct3502.DrugTracCodg = drug.DrugCode
  2236. //
  2237. // struct3502.Memo = ""
  2238. // struct3502.InvChgType = "108"
  2239. // struct3502.FixmedinsBchno = bg_number
  2240. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2241. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2242. //
  2243. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2244. // result11, result22, _ := service.FJyb3502(struct3502)
  2245. // saveLog(result11, result22, "3502", "3502")
  2246. //
  2247. // var respJSON3 map[string]interface{}
  2248. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2249. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2250. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2251. // return
  2252. // }
  2253. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2254. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2255. // utils.ErrorLog("解析失败:%v", err)
  2256. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2257. // return
  2258. // }
  2259. //
  2260. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2261. // data := make(map[string]interface{})
  2262. // data["struct_3502s"] = struct3502
  2263. // client := &http.Client{}
  2264. // bytesData, _ := json.Marshal(data)
  2265. // var req *http.Request
  2266. // if miConfig.MdtrtareaAdmvs == "320921" {
  2267. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2268. // } else {
  2269. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2270. // }
  2271. //
  2272. // resp, _ := client.Do(req)
  2273. // defer resp.Body.Close()
  2274. // body, ioErr := ioutil.ReadAll(resp.Body)
  2275. // if ioErr != nil {
  2276. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2277. // }
  2278. // var respJSON map[string]interface{}
  2279. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2280. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2281. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2282. // return
  2283. // }
  2284. // var resSix10265 ResultSix10265 //1101结果
  2285. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2286. // result, _ := json.Marshal(respJSON)
  2287. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2288. // utils.ErrorLog("解析失败:%v", err)
  2289. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2290. // return
  2291. // }
  2292. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2293. // res3.Output = resSix10265.Output
  2294. // res3.ErrMsg = resSix10265.ErrMsg
  2295. // res3.Cainfo = resSix10265.Cainfo
  2296. // res3.WarnMsg = resSix10265.WarnMsg
  2297. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2298. // res3.Infcode = infocode
  2299. //
  2300. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2301. //
  2302. // data := make(map[string]interface{})
  2303. // data["struct_3502s"] = struct3502
  2304. // client := &http.Client{}
  2305. // bytesData, _ := json.Marshal(data)
  2306. // var req *http.Request
  2307. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2308. // resp, _ := client.Do(req)
  2309. // defer resp.Body.Close()
  2310. // body, ioErr := ioutil.ReadAll(resp.Body)
  2311. // if ioErr != nil {
  2312. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2313. // }
  2314. // var respJSON map[string]interface{}
  2315. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2316. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2317. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2318. // return
  2319. // }
  2320. // var resSix10265 ResultSix10265 //1101结果
  2321. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2322. // result, _ := json.Marshal(respJSON)
  2323. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2324. // utils.ErrorLog("解析失败:%v", err)
  2325. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2326. // return
  2327. // }
  2328. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2329. // res3.Output = resSix10265.Output
  2330. // res3.ErrMsg = resSix10265.ErrMsg
  2331. // res3.Cainfo = resSix10265.Cainfo
  2332. // res3.WarnMsg = resSix10265.WarnMsg
  2333. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2334. // res3.Infcode = infocode
  2335. //
  2336. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2337. //
  2338. // data := make(map[string]interface{})
  2339. // data["struct_3501s"] = struct3501
  2340. // client := &http.Client{}
  2341. // bytesData, _ := json.Marshal(data)
  2342. // var req *http.Request
  2343. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2344. // resp, _ := client.Do(req)
  2345. // defer resp.Body.Close()
  2346. // body, ioErr := ioutil.ReadAll(resp.Body)
  2347. // if ioErr != nil {
  2348. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2349. // }
  2350. // var respJSON map[string]interface{}
  2351. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2352. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2353. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2354. // return
  2355. // }
  2356. // var resSix10265 ResultSix10265 //1101结果
  2357. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2358. // result, _ := json.Marshal(respJSON)
  2359. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2360. // utils.ErrorLog("解析失败:%v", err)
  2361. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2362. // return
  2363. // }
  2364. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2365. // res2.Output = resSix10265.Output
  2366. // res2.ErrMsg = resSix10265.ErrMsg
  2367. // res2.Cainfo = resSix10265.Cainfo
  2368. // res2.WarnMsg = resSix10265.WarnMsg
  2369. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2370. // res2.Infcode = infocode
  2371. //
  2372. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2373. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2374. // saveLog(result11, result22, "3502", "3502")
  2375. //
  2376. // var respJSON3 map[string]interface{}
  2377. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2378. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2380. // return
  2381. // }
  2382. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2383. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2384. // utils.ErrorLog("解析失败:%v", err)
  2385. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2386. // return
  2387. // }
  2388. // }
  2389. // if res3.Infcode == -1 {
  2390. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2391. // c.ServeSuccessJSON(map[string]interface{}{
  2392. // "failed_code": -10,
  2393. // "msg": res3.ErrMsg,
  2394. // })
  2395. // } else {
  2396. // drug.IsBg = 1
  2397. // drug.BgBchno = bg_number
  2398. // service.SaveW(drug)
  2399. // }
  2400. // }
  2401. // } else {
  2402. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2403. // }
  2404. // }
  2405. // //变更
  2406. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2407. // var res3 ResultSix
  2408. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2409. //
  2410. // var struct3502 models.Struct3502
  2411. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2412. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2413. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2414. // struct3502.FixmedinsCode = miConfig.Code
  2415. // struct3502.Code = miConfig.Code
  2416. //
  2417. // struct3502.Opter = roles.UserName
  2418. // struct3502.RxFlag = "0"
  2419. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2420. // struct3502.OrgName = miConfig.OrgName
  2421. // struct3502.AccessKey = miConfig.AccessKey
  2422. // struct3502.RequestUrl = miConfig.Url
  2423. // struct3502.SecretKey = miConfig.SecretKey
  2424. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2425. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2426. // struct3502.InvChgType = "108"
  2427. // struct3502.DrugTracCodg = drug.DrugCode
  2428. //
  2429. // struct3502.Url = miConfig.Url
  2430. // struct3502.AppId = miConfig.Cainfo
  2431. // struct3502.AppSecret = miConfig.AppSecret
  2432. // struct3502.Enckey = miConfig.EncKey
  2433. // struct3502.SignKey = miConfig.SignKey
  2434. // struct3502.SecretKey = miConfig.SecretKey
  2435. //
  2436. // struct3502.FixmedinsBchno = bg_number
  2437. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2438. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2439. //
  2440. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2441. // result1, result2, _ := service.FJyb3502(struct3502)
  2442. // saveLog(result1, result2, "3502", "3502")
  2443. // var respJSON3 map[string]interface{}
  2444. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2445. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2446. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2447. // return
  2448. // }
  2449. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2450. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2451. // utils.ErrorLog("解析失败:%v", err)
  2452. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2453. // return
  2454. // }
  2455. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2456. // data := make(map[string]interface{})
  2457. // data["struct_3502s"] = struct3502
  2458. // client := &http.Client{}
  2459. // bytesData, _ := json.Marshal(data)
  2460. // var req *http.Request
  2461. // if miConfig.MdtrtareaAdmvs == "320921" {
  2462. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2463. // } else {
  2464. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2465. // }
  2466. // resp, _ := client.Do(req)
  2467. // defer resp.Body.Close()
  2468. // body, ioErr := ioutil.ReadAll(resp.Body)
  2469. // if ioErr != nil {
  2470. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2471. // }
  2472. // var respJSON map[string]interface{}
  2473. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2474. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2475. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2476. // return
  2477. // }
  2478. // var resSix10265 ResultSix10265 //1101结果
  2479. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2480. // result, _ := json.Marshal(respJSON)
  2481. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2482. // utils.ErrorLog("解析失败:%v", err)
  2483. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2484. // return
  2485. // }
  2486. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2487. // res3.Output = resSix10265.Output
  2488. // res3.ErrMsg = resSix10265.ErrMsg
  2489. // res3.Cainfo = resSix10265.Cainfo
  2490. // res3.WarnMsg = resSix10265.WarnMsg
  2491. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2492. // res3.Infcode = infocode
  2493. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2494. //
  2495. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2496. //
  2497. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2498. //
  2499. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2500. //
  2501. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2502. // saveLog(result1, result2, "3501", "3501")
  2503. // //saveLog(result, requestLog, "2201", "挂号")
  2504. //
  2505. // var respJSON2 map[string]interface{}
  2506. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2507. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2508. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2509. // return
  2510. // }
  2511. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2512. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2513. // utils.ErrorLog("解析失败:%v", err)
  2514. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2515. // return
  2516. // }
  2517. //
  2518. // }
  2519. // if res3.Infcode == -1 {
  2520. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2521. // } else {
  2522. // drug.IsBg = 1
  2523. // drug.BgBchno = bg_number
  2524. // service.SaveW(drug)
  2525. // }
  2526. // }
  2527. // }
  2528. //
  2529. // if len(errs) == 0 {
  2530. // c.ServeSuccessJSON(map[string]interface{}{
  2531. // "msg": "盘存变更成功",
  2532. // })
  2533. // } else {
  2534. // c.ServeSuccessJSON(map[string]interface{}{
  2535. // "failed_code": -10,
  2536. // "msg": errs,
  2537. // })
  2538. // }
  2539. //}
  2540. func (c *HisApiController) DeleteXSandBGTwo() {
  2541. patient_id, _ := c.GetInt64("patient_id")
  2542. admin_user_id, _ := c.GetInt64("admin_user_id")
  2543. times := c.GetString("time", "")
  2544. timeLayout := "2006-01-02"
  2545. loc, _ := time.LoadLocation("Local")
  2546. var stime, etime int64
  2547. if times == "" {
  2548. stime, etime = GetNowTime()
  2549. } else {
  2550. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2551. stime = stmp.Unix()
  2552. etime = stime + 86399
  2553. }
  2554. advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2555. var flows []*models.DrugFlow
  2556. for _, item := range advicelist {
  2557. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2558. flows = append(flows, flow...)
  2559. }
  2560. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2561. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2562. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2563. var err []string
  2564. for _, item := range flows {
  2565. if item.IsSale == 1 {
  2566. var res FJ3507Result
  2567. var struct3507 models.Struct3507
  2568. struct3507.FixmedinsBchno = item.Bchno
  2569. struct3507.InvDataType = "4"
  2570. struct3507.Opter = roles.UserName
  2571. struct3507.OrgName = miConfig.OrgName
  2572. struct3507.AccessKey = miConfig.AccessKey
  2573. struct3507.RequestUrl = miConfig.Url
  2574. struct3507.FixmedinsCode = miConfig.Code
  2575. struct3507.SecretKey = miConfig.SecretKey
  2576. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2577. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2578. struct3507.Url = miConfig.Url
  2579. struct3507.AppId = miConfig.Cainfo
  2580. struct3507.AppSecret = miConfig.AppSecret
  2581. struct3507.Enckey = miConfig.EncKey
  2582. struct3507.SignKey = miConfig.SignKey
  2583. struct3507.SecretKey = miConfig.SecretKey
  2584. if miConfig.MdtrtareaAdmvs == "350500" {
  2585. result, result1, _ := service.FJyb3507(struct3507)
  2586. saveLog(result, result1, "3507", "3507")
  2587. var respJSON2 map[string]interface{}
  2588. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2589. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2591. return
  2592. }
  2593. userJSONBytes2, _ := json.Marshal(respJSON2)
  2594. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2595. utils.ErrorLog("解析失败:%v", err)
  2596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2597. return
  2598. }
  2599. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2600. data := make(map[string]interface{})
  2601. data["struct_3507s"] = struct3507
  2602. client := &http.Client{}
  2603. bytesData, _ := json.Marshal(data)
  2604. var req *http.Request
  2605. if miConfig.MdtrtareaAdmvs == "320921" {
  2606. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2607. } else {
  2608. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2609. }
  2610. resp, _ := client.Do(req)
  2611. defer resp.Body.Close()
  2612. body, ioErr := ioutil.ReadAll(resp.Body)
  2613. if ioErr != nil {
  2614. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2615. }
  2616. var respJSON map[string]interface{}
  2617. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2620. return
  2621. }
  2622. var resSix10265 ResultSix10265 //1101结果
  2623. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2624. result, _ := json.Marshal(respJSON)
  2625. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2626. utils.ErrorLog("解析失败:%v", err)
  2627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2628. return
  2629. }
  2630. res.InfRefmsgid = resSix10265.InfRefmsgid
  2631. //res.Output = resSix10265.Output
  2632. res.ErrMsg = resSix10265.ErrMsg
  2633. res.Cainfo = resSix10265.Cainfo
  2634. res.WarnMsg = resSix10265.WarnMsg
  2635. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2636. res.Infcode = infocode
  2637. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2638. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2639. saveLog(result2, result1, "3507", "3507")
  2640. var respJSON2 map[string]interface{}
  2641. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2642. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2644. return
  2645. }
  2646. userJSONBytes2, _ := json.Marshal(respJSON2)
  2647. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2648. utils.ErrorLog("解析失败:%v", err)
  2649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2650. return
  2651. }
  2652. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2653. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2654. saveLog(result2, result1, "3507", "3507")
  2655. var respJSON2 map[string]interface{}
  2656. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2659. return
  2660. }
  2661. userJSONBytes2, _ := json.Marshal(respJSON2)
  2662. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2663. utils.ErrorLog("解析失败:%v", err)
  2664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2665. return
  2666. }
  2667. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2668. result1, result2 := service.Jxyb3507(struct3507)
  2669. saveLog(result2, result1, "3507", "3507")
  2670. var respJSON2 map[string]interface{}
  2671. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2674. return
  2675. }
  2676. userJSONBytes2, _ := json.Marshal(respJSON2)
  2677. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2678. utils.ErrorLog("解析失败:%v", err)
  2679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2680. return
  2681. }
  2682. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2683. result1, result2 := service.AHyb3507(struct3507)
  2684. saveLog(result2, result1, "3507", "3507")
  2685. var respJSON2 map[string]interface{}
  2686. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2687. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2689. return
  2690. }
  2691. userJSONBytes2, _ := json.Marshal(respJSON2)
  2692. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2693. utils.ErrorLog("解析失败:%v", err)
  2694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2695. return
  2696. }
  2697. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2698. data := make(map[string]interface{})
  2699. data["struct_3507s"] = struct3507
  2700. client := &http.Client{}
  2701. bytesData, _ := json.Marshal(data)
  2702. var req *http.Request
  2703. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2704. resp, _ := client.Do(req)
  2705. defer resp.Body.Close()
  2706. body, ioErr := ioutil.ReadAll(resp.Body)
  2707. if ioErr != nil {
  2708. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2709. }
  2710. var respJSON map[string]interface{}
  2711. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2713. }
  2714. var resSix10265 ResultSix10265 //1101结果
  2715. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2716. result, _ := json.Marshal(respJSON)
  2717. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2718. utils.ErrorLog("解析失败:%v", err)
  2719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2720. return
  2721. }
  2722. res.InfRefmsgid = resSix10265.InfRefmsgid
  2723. res.ErrMsg = resSix10265.ErrMsg
  2724. res.Cainfo = resSix10265.Cainfo
  2725. res.WarnMsg = resSix10265.WarnMsg
  2726. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2727. res.Infcode = infocode
  2728. }
  2729. if res.Infcode == 0 {
  2730. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  2731. item.IsSale = 0
  2732. item.SaleDate = ""
  2733. item.Bchno = ""
  2734. service.SaveDF(item)
  2735. } else {
  2736. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2737. }
  2738. }
  2739. }
  2740. c.ServeSuccessJSON(map[string]interface{}{
  2741. "msg": "删除销售数据成功",
  2742. })
  2743. }
  2744. // 删除
  2745. func (c *HisApiController) DeleteXSandBGThree() {
  2746. id, _ := c.GetInt64("id")
  2747. admin_user_id, _ := c.GetInt64("admin_user_id")
  2748. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  2749. var flows []*models.DrugFlow
  2750. for _, item := range advicelist {
  2751. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  2752. flows = append(flows, flow...)
  2753. }
  2754. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2755. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2756. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2757. var err []string
  2758. for _, item := range flows {
  2759. if item.IsSale == 1 {
  2760. var res FJ3507Result
  2761. var struct3507 models.Struct3507
  2762. struct3507.FixmedinsBchno = item.Bchno
  2763. struct3507.InvDataType = "4"
  2764. struct3507.Opter = roles.UserName
  2765. struct3507.OrgName = miConfig.OrgName
  2766. struct3507.AccessKey = miConfig.AccessKey
  2767. struct3507.RequestUrl = miConfig.Url
  2768. struct3507.FixmedinsCode = miConfig.Code
  2769. struct3507.SecretKey = miConfig.SecretKey
  2770. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2771. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2772. struct3507.Url = miConfig.Url
  2773. struct3507.AppId = miConfig.Cainfo
  2774. struct3507.AppSecret = miConfig.AppSecret
  2775. struct3507.Enckey = miConfig.EncKey
  2776. struct3507.SignKey = miConfig.SignKey
  2777. struct3507.SecretKey = miConfig.SecretKey
  2778. if miConfig.MdtrtareaAdmvs == "350500" {
  2779. result, result1, _ := service.FJyb3507(struct3507)
  2780. saveLog(result, result1, "3507", "3507")
  2781. var respJSON2 map[string]interface{}
  2782. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2783. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2785. return
  2786. }
  2787. userJSONBytes2, _ := json.Marshal(respJSON2)
  2788. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2789. utils.ErrorLog("解析失败:%v", err)
  2790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2791. return
  2792. }
  2793. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2794. data := make(map[string]interface{})
  2795. data["struct_3507s"] = struct3507
  2796. client := &http.Client{}
  2797. bytesData, _ := json.Marshal(data)
  2798. var req *http.Request
  2799. if miConfig.MdtrtareaAdmvs == "320921" {
  2800. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2801. } else {
  2802. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2803. }
  2804. resp, _ := client.Do(req)
  2805. defer resp.Body.Close()
  2806. body, ioErr := ioutil.ReadAll(resp.Body)
  2807. if ioErr != nil {
  2808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2809. }
  2810. var respJSON map[string]interface{}
  2811. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2814. return
  2815. }
  2816. var resSix10265 ResultSix10265 //1101结果
  2817. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2818. result, _ := json.Marshal(respJSON)
  2819. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2820. utils.ErrorLog("解析失败:%v", err)
  2821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2822. return
  2823. }
  2824. res.InfRefmsgid = resSix10265.InfRefmsgid
  2825. //res.Output = resSix10265.Output
  2826. res.ErrMsg = resSix10265.ErrMsg
  2827. res.Cainfo = resSix10265.Cainfo
  2828. res.WarnMsg = resSix10265.WarnMsg
  2829. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2830. res.Infcode = infocode
  2831. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2832. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2833. saveLog(result2, result1, "3507", "3507")
  2834. var respJSON2 map[string]interface{}
  2835. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2838. return
  2839. }
  2840. userJSONBytes2, _ := json.Marshal(respJSON2)
  2841. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2842. utils.ErrorLog("解析失败:%v", err)
  2843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2844. return
  2845. }
  2846. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2847. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2848. saveLog(result2, result1, "3507", "3507")
  2849. var respJSON2 map[string]interface{}
  2850. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2851. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2853. return
  2854. }
  2855. userJSONBytes2, _ := json.Marshal(respJSON2)
  2856. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2857. utils.ErrorLog("解析失败:%v", err)
  2858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2859. return
  2860. }
  2861. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2862. result1, result2 := service.Jxyb3507(struct3507)
  2863. saveLog(result2, result1, "3507", "3507")
  2864. var respJSON2 map[string]interface{}
  2865. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2868. return
  2869. }
  2870. userJSONBytes2, _ := json.Marshal(respJSON2)
  2871. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2872. utils.ErrorLog("解析失败:%v", err)
  2873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2874. return
  2875. }
  2876. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2877. result1, result2 := service.AHyb3507(struct3507)
  2878. saveLog(result2, result1, "3507", "3507")
  2879. var respJSON2 map[string]interface{}
  2880. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2883. return
  2884. }
  2885. userJSONBytes2, _ := json.Marshal(respJSON2)
  2886. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2887. utils.ErrorLog("解析失败:%v", err)
  2888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2889. return
  2890. }
  2891. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2892. data := make(map[string]interface{})
  2893. data["struct_3507s"] = struct3507
  2894. client := &http.Client{}
  2895. bytesData, _ := json.Marshal(data)
  2896. var req *http.Request
  2897. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2898. resp, _ := client.Do(req)
  2899. defer resp.Body.Close()
  2900. body, ioErr := ioutil.ReadAll(resp.Body)
  2901. if ioErr != nil {
  2902. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2903. }
  2904. var respJSON map[string]interface{}
  2905. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2906. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2907. }
  2908. var resSix10265 ResultSix10265 //1101结果
  2909. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2910. result, _ := json.Marshal(respJSON)
  2911. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2912. utils.ErrorLog("解析失败:%v", err)
  2913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2914. return
  2915. }
  2916. res.InfRefmsgid = resSix10265.InfRefmsgid
  2917. res.ErrMsg = resSix10265.ErrMsg
  2918. res.Cainfo = resSix10265.Cainfo
  2919. res.WarnMsg = resSix10265.WarnMsg
  2920. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2921. res.Infcode = infocode
  2922. }
  2923. if res.Infcode == 0 {
  2924. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  2925. item.IsSale = 0
  2926. item.SaleDate = ""
  2927. item.Bchno = ""
  2928. service.SaveDF(item)
  2929. } else {
  2930. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2931. }
  2932. }
  2933. }
  2934. c.ServeSuccessJSON(map[string]interface{}{
  2935. "msg": "删除销售数据成功",
  2936. })
  2937. }
  2938. // 获取当天起止时间戳
  2939. func GetNowTime() (int64, int64) {
  2940. t := time.Now()
  2941. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  2942. timesamp := addTime.Unix()
  2943. return timesamp, timesamp + 86399
  2944. }
  2945. func (c *HisApiController) ChangeDrugfour() {
  2946. patient_id, _ := c.GetInt64("patient_id")
  2947. admin_user_id, _ := c.GetInt64("admin_user_id")
  2948. times := c.GetString("time", "")
  2949. timeLayout := "2006-01-02"
  2950. loc, _ := time.LoadLocation("Local")
  2951. var stime, etime int64
  2952. if times == "" {
  2953. stime, etime = GetNowTime()
  2954. } else {
  2955. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2956. stime = stmp.Unix()
  2957. etime = stime + 86399
  2958. }
  2959. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2960. var flows []*models.DrugFlow
  2961. for _, item := range advicelist {
  2962. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2963. flows = append(flows, flow...)
  2964. }
  2965. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2966. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2967. var err []string
  2968. for _, item := range flows {
  2969. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  2970. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2971. if prescription.OrderStatus == 2 {
  2972. if item.IsSale == 0 {
  2973. var res FJ3507Result
  2974. var res3507for10188 FJ3507ResultFor10188
  2975. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  2976. //进行商品销售接口
  2977. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2978. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  2979. var respJSON3 map[string]interface{}
  2980. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  2981. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2983. return
  2984. }
  2985. userJSONBytes3, _ := json.Marshal(respJSON3)
  2986. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2987. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2988. utils.ErrorLog("解析失败:%v", err)
  2989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2990. return
  2991. }
  2992. //if res3507for10188.Infcode
  2993. res.InfRefmsgid = res3507for10188.InfRefmsgid
  2994. //res.Output = resSix10265.Output
  2995. res.ErrMsg = res3507for10188.ErrMsg
  2996. res.Cainfo = res3507for10188.Cainfo
  2997. res.WarnMsg = res3507for10188.WarnMsg
  2998. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2999. res.Infcode = infocode
  3000. } else {
  3001. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3002. utils.ErrorLog("解析失败:%v", err)
  3003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3004. return
  3005. }
  3006. }
  3007. if res.Infcode == 0 {
  3008. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3009. item.IsSale = 1
  3010. item.Bchno = number
  3011. item.SaleDate = time.Now().Format("2006-01-02")
  3012. service.SaveDF(item)
  3013. } else {
  3014. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3015. }
  3016. }
  3017. } else { //还没结,提示用户去结算,并药品追溯上传
  3018. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3019. }
  3020. }
  3021. }
  3022. str := strings.Join(err, " ")
  3023. saveLog(str, str, "3505", "3505自动上传日志")
  3024. c.ServeSuccessJSON(map[string]interface{}{
  3025. "status": "1",
  3026. "msg": err,
  3027. })
  3028. }
  3029. func (c *HisApiController) ChangeDrugFive() {
  3030. id, _ := c.GetInt64("id")
  3031. admin_user_id, _ := c.GetInt64("admin_user_id")
  3032. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  3033. var flows []*models.DrugFlow
  3034. for _, item := range advicelist {
  3035. flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3036. flows = append(flows, flow...)
  3037. }
  3038. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3039. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3040. var err []string
  3041. for _, item := range flows {
  3042. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3043. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3044. if prescription.OrderStatus == 2 {
  3045. if item.IsSale == 0 {
  3046. var res FJ3507Result
  3047. var res3507for10188 FJ3507ResultFor10188
  3048. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3049. //进行商品销售接口
  3050. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3051. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3052. var respJSON3 map[string]interface{}
  3053. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3056. return
  3057. }
  3058. userJSONBytes3, _ := json.Marshal(respJSON3)
  3059. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3060. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3061. utils.ErrorLog("解析失败:%v", err)
  3062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3063. return
  3064. }
  3065. //if res3507for10188.Infcode
  3066. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3067. //res.Output = resSix10265.Output
  3068. res.ErrMsg = res3507for10188.ErrMsg
  3069. res.Cainfo = res3507for10188.Cainfo
  3070. res.WarnMsg = res3507for10188.WarnMsg
  3071. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3072. res.Infcode = infocode
  3073. } else {
  3074. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3075. utils.ErrorLog("解析失败:%v", err)
  3076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3077. return
  3078. }
  3079. }
  3080. if res.Infcode == 0 {
  3081. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3082. item.IsSale = 1
  3083. item.Bchno = number
  3084. item.SaleDate = time.Now().Format("2006-01-02")
  3085. service.SaveDF(item)
  3086. } else {
  3087. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3088. }
  3089. }
  3090. } else { //还没结,提示用户去结算,并药品追溯上传
  3091. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3092. }
  3093. }
  3094. }
  3095. str := strings.Join(err, " ")
  3096. saveLog(str, str, "3505", "3505自动上传日志")
  3097. c.ServeSuccessJSON(map[string]interface{}{
  3098. "status": "1",
  3099. "msg": err,
  3100. })
  3101. }
  3102. //func (c *HisApiController) ChangeDrugfour() {
  3103. // patient_id, _ := c.GetInt64("patient_id")
  3104. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3105. // //id_arr := strings.Split(ids, ",")
  3106. // times := c.GetString("time", "")
  3107. // timeLayout := "2006-01-02"
  3108. // loc, _ := time.LoadLocation("Local")
  3109. // var stime, etime int64
  3110. // if times == "" {
  3111. // stime, etime = GetNowTime()
  3112. // } else {
  3113. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3114. // stime = stmp.Unix()
  3115. // etime = stime + 86399
  3116. // }
  3117. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3118. // var flows []*models.DrugFlow
  3119. // for _, item := range advicelist {
  3120. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3121. // flows = append(flows, flow...)
  3122. // }
  3123. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3124. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3125. // var err []string
  3126. //
  3127. // for _, item := range flows {
  3128. // var res3 ResultSix
  3129. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3130. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3131. // if prescription.OrderStatus == 2 {
  3132. // //已经结算
  3133. // //判断是否已经销售
  3134. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3135. // //是否已经变更 1是 0否
  3136. // if item.IsChange == 0 { //没变更,进行变更操作
  3137. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3138. //
  3139. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3140. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3141. // var respJSON3 map[string]interface{}
  3142. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3143. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3144. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3145. // return
  3146. // }
  3147. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3148. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3149. // utils.ErrorLog("解析失败:%v", err)
  3150. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3151. // return
  3152. // }
  3153. // if res3.Infcode == 0 {
  3154. // item.IsChange = 1
  3155. // item.BgBchno = bg_number
  3156. // service.SaveDF2(item)
  3157. // } else {
  3158. //
  3159. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3160. // }
  3161. // }
  3162. // } else { //没销售,
  3163. // var res FJ3507Result
  3164. // var res3507for10188 FJ3507ResultFor10188
  3165. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3166. //
  3167. // //进行商品销售接口
  3168. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3169. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3170. // var respJSON3 map[string]interface{}
  3171. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3172. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3173. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3174. // return
  3175. // }
  3176. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3177. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3178. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3179. // utils.ErrorLog("解析失败:%v", err)
  3180. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3181. // return
  3182. // }
  3183. // //if res3507for10188.Infcode
  3184. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3185. // //res.Output = resSix10265.Output
  3186. // res.ErrMsg = res3507for10188.ErrMsg
  3187. // res.Cainfo = res3507for10188.Cainfo
  3188. // res.WarnMsg = res3507for10188.WarnMsg
  3189. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3190. // res.Infcode = infocode
  3191. // } else {
  3192. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3193. // utils.ErrorLog("解析失败:%v", err)
  3194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3195. // return
  3196. // }
  3197. //
  3198. // }
  3199. // if res.Infcode == 0 {
  3200. // item.IsSale = 1
  3201. // item.Bchno = number
  3202. // item.SaleDate = time.Now().Format("2006-01-02")
  3203. //
  3204. // err5 := service.SaveDF(item)
  3205. // if err5 == nil {
  3206. // if item.IsChange == 0 { //没变更,进行变更操作
  3207. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3208. //
  3209. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3210. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3211. //
  3212. // var respJSON3 map[string]interface{}
  3213. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3214. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3215. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3216. // return
  3217. // }
  3218. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3219. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3220. // utils.ErrorLog("解析失败:%v", err)
  3221. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3222. // return
  3223. // }
  3224. // //if res3507for10188.Infcode
  3225. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3226. // //res.Output = resSix10265.Output
  3227. // res3.ErrMsg = res3507for10188.ErrMsg
  3228. // res3.Cainfo = res3507for10188.Cainfo
  3229. // res3.WarnMsg = res3507for10188.WarnMsg
  3230. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3231. // res3.Infcode = infocode
  3232. // } else {
  3233. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3234. // utils.ErrorLog("解析失败:%v", err)
  3235. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3236. // return
  3237. // }
  3238. // }
  3239. // if res3.Infcode == 0 {
  3240. // item.IsChange = 1
  3241. // item.BgBchno = bg_number
  3242. // service.SaveDF2(item)
  3243. // } else {
  3244. //
  3245. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3246. // }
  3247. // }
  3248. // }
  3249. // } else {
  3250. //
  3251. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3252. // }
  3253. // }
  3254. //
  3255. // } else { //还没结,提示用户去结算,并药品追溯上传
  3256. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3257. // }
  3258. // }
  3259. // }
  3260. // if len(err) == 0 {
  3261. // c.ServeSuccessJSON(map[string]interface{}{
  3262. // "msg": "销售变更成功",
  3263. // })
  3264. // } else {
  3265. // c.ServeSuccessJSON(map[string]interface{}{
  3266. // "failed_code": -10,
  3267. // "msg": err,
  3268. // })
  3269. // }
  3270. //}
  3271. func (c *HisApiController) ChangeDrug() {
  3272. ids := c.GetString("ids")
  3273. id_arr := strings.Split(ids, ",")
  3274. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3275. admin_user_id, _ := c.GetInt64("admin_user_id")
  3276. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3277. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3278. var err []string
  3279. for _, item := range flows {
  3280. var res3 ResultSix
  3281. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3282. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3283. if prescription.OrderStatus == 2 {
  3284. //已经结算
  3285. //判断是否已经销售
  3286. if item.IsSale == 1 { //是否已经销售,1是 0否
  3287. //是否已经变更 1是 0否
  3288. if item.IsChange == 0 { //没变更,进行变更操作
  3289. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3290. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3291. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3292. var respJSON3 map[string]interface{}
  3293. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3294. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3296. return
  3297. }
  3298. userJSONBytes3, _ := json.Marshal(respJSON3)
  3299. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3300. utils.ErrorLog("解析失败:%v", err)
  3301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3302. return
  3303. }
  3304. if res3.Infcode == 0 {
  3305. item.IsChange = 1
  3306. item.BgBchno = bg_number
  3307. service.SaveDF2(item)
  3308. } else {
  3309. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3310. }
  3311. }
  3312. } else { //没销售,
  3313. var res FJ3507Result
  3314. var res3507for10188 FJ3507ResultFor10188
  3315. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3316. //进行商品销售接口
  3317. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3318. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3319. var respJSON3 map[string]interface{}
  3320. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3323. return
  3324. }
  3325. userJSONBytes3, _ := json.Marshal(respJSON3)
  3326. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3327. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3328. utils.ErrorLog("解析失败:%v", err)
  3329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3330. return
  3331. }
  3332. //if res3507for10188.Infcode
  3333. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3334. //res.Output = resSix10265.Output
  3335. res.ErrMsg = res3507for10188.ErrMsg
  3336. res.Cainfo = res3507for10188.Cainfo
  3337. res.WarnMsg = res3507for10188.WarnMsg
  3338. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3339. res.Infcode = infocode
  3340. } else {
  3341. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3342. utils.ErrorLog("解析失败:%v", err)
  3343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3344. return
  3345. }
  3346. }
  3347. if res.Infcode == 0 {
  3348. item.IsSale = 1
  3349. item.Bchno = number
  3350. item.SaleDate = time.Now().Format("2006-01-02")
  3351. err5 := service.SaveDF(item)
  3352. if err5 == nil {
  3353. if item.IsChange == 0 { //没变更,进行变更操作
  3354. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3355. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3356. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3357. var respJSON3 map[string]interface{}
  3358. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3361. return
  3362. }
  3363. userJSONBytes3, _ := json.Marshal(respJSON3)
  3364. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3365. utils.ErrorLog("解析失败:%v", err)
  3366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3367. return
  3368. }
  3369. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3370. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3371. utils.ErrorLog("解析失败:%v", err)
  3372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3373. return
  3374. }
  3375. //if res3507for10188.Infcode
  3376. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3377. //res.Output = resSix10265.Output
  3378. res3.ErrMsg = res3507for10188.ErrMsg
  3379. res3.Cainfo = res3507for10188.Cainfo
  3380. res3.WarnMsg = res3507for10188.WarnMsg
  3381. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3382. res3.Infcode = infocode
  3383. } else {
  3384. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3385. utils.ErrorLog("解析失败:%v", err)
  3386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3387. return
  3388. }
  3389. }
  3390. if res3.Infcode == 0 {
  3391. item.IsChange = 1
  3392. item.BgBchno = bg_number
  3393. service.SaveDF2(item)
  3394. } else {
  3395. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3396. }
  3397. }
  3398. }
  3399. } else {
  3400. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3401. }
  3402. }
  3403. } else { //还没结算
  3404. var res3507for10188 FJ3507ResultFor10188
  3405. if item.IsChange == 0 { //没变更,进行变更操作
  3406. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3407. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3408. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3409. var respJSON3 map[string]interface{}
  3410. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3411. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3413. return
  3414. }
  3415. userJSONBytes3, _ := json.Marshal(respJSON3)
  3416. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3417. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3418. utils.ErrorLog("解析失败:%v", err)
  3419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3420. return
  3421. }
  3422. //if res3507for10188.Infcode
  3423. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3424. //res.Output = resSix10265.Output
  3425. res3.ErrMsg = res3507for10188.ErrMsg
  3426. res3.Cainfo = res3507for10188.Cainfo
  3427. res3.WarnMsg = res3507for10188.WarnMsg
  3428. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3429. res3.Infcode = infocode
  3430. } else {
  3431. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3432. utils.ErrorLog("解析失败:%v", err)
  3433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3434. return
  3435. }
  3436. }
  3437. if res3.Infcode == 0 {
  3438. item.IsChange = 1
  3439. item.BgBchno = bg_number
  3440. service.SaveDF2(item)
  3441. } else {
  3442. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3443. }
  3444. }
  3445. }
  3446. } else if item.ConsumableType == 7 {
  3447. var res3507for10188 FJ3507ResultFor10188
  3448. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3449. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3450. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3451. //判断是否已经销售
  3452. if item.IsSale == 2 { //是否已经销售,1是 0否
  3453. //是否已经变更 1是 0否
  3454. if item.IsChange == 0 { //没变更,进行变更操作
  3455. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3456. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3457. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3458. var respJSON3 map[string]interface{}
  3459. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3460. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3462. return
  3463. }
  3464. userJSONBytes3, _ := json.Marshal(respJSON3)
  3465. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3466. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3467. utils.ErrorLog("解析失败:%v", err)
  3468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3469. return
  3470. }
  3471. //if res3507for10188.Infcode
  3472. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3473. //res.Output = resSix10265.Output
  3474. res3.ErrMsg = res3507for10188.ErrMsg
  3475. res3.Cainfo = res3507for10188.Cainfo
  3476. res3.WarnMsg = res3507for10188.WarnMsg
  3477. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3478. res3.Infcode = infocode
  3479. } else {
  3480. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3481. utils.ErrorLog("解析失败:%v", err)
  3482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3483. return
  3484. }
  3485. }
  3486. if res3.Infcode == 0 {
  3487. item.IsChange = 1
  3488. item.BgBchno = bg_number
  3489. service.SaveDF2(item)
  3490. } else {
  3491. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3492. }
  3493. }
  3494. } else { //没销售,
  3495. //进行商品销售退货接口
  3496. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3497. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3498. saveLog(result111, result222, "3506", "销售退货")
  3499. var res7 FJ3507Result
  3500. //进行商品销售接口
  3501. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3502. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3503. var respJSON3 map[string]interface{}
  3504. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3507. return
  3508. }
  3509. userJSONBytes3, _ := json.Marshal(respJSON3)
  3510. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3511. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3512. utils.ErrorLog("解析失败:%v", err)
  3513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3514. return
  3515. }
  3516. //if res3507for10188.Infcode
  3517. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3518. //res.Output = resSix10265.Output
  3519. res7.ErrMsg = res3507for10188.ErrMsg
  3520. res7.Cainfo = res3507for10188.Cainfo
  3521. res7.WarnMsg = res3507for10188.WarnMsg
  3522. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3523. res7.Infcode = infocode
  3524. } else {
  3525. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3526. utils.ErrorLog("解析失败:%v", err)
  3527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3528. return
  3529. }
  3530. }
  3531. if res7.Infcode == 0 {
  3532. item.IsSale = 2
  3533. item.SaleDate = item.SaleDate
  3534. item.Bchno = number
  3535. service.SaveDF(item)
  3536. if item.IsChange == 0 { //没变更,进行变更操作
  3537. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3538. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3539. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3540. var respJSON3 map[string]interface{}
  3541. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3542. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3544. return
  3545. }
  3546. userJSONBytes3, _ := json.Marshal(respJSON3)
  3547. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3548. // utils.ErrorLog("解析失败:%v", err)
  3549. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3550. // return
  3551. //}
  3552. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3553. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3554. utils.ErrorLog("解析失败:%v", err)
  3555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3556. return
  3557. }
  3558. //if res3507for10188.Infcode
  3559. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3560. //res.Output = resSix10265.Output
  3561. res3.ErrMsg = res3507for10188.ErrMsg
  3562. res3.Cainfo = res3507for10188.Cainfo
  3563. res3.WarnMsg = res3507for10188.WarnMsg
  3564. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3565. res3.Infcode = infocode
  3566. } else {
  3567. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3568. utils.ErrorLog("解析失败:%v", err)
  3569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3570. return
  3571. }
  3572. }
  3573. if res3.Infcode == 0 {
  3574. item.IsChange = 1
  3575. item.BgBchno = bg_number
  3576. service.SaveDF2(item)
  3577. } else {
  3578. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3579. }
  3580. }
  3581. } else {
  3582. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3583. }
  3584. }
  3585. } else { //还没结算
  3586. if item.IsChange == 0 { //没变更,进行变更操作
  3587. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3588. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3589. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3590. var respJSON3 map[string]interface{}
  3591. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3592. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3594. return
  3595. }
  3596. userJSONBytes3, _ := json.Marshal(respJSON3)
  3597. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3598. // utils.ErrorLog("解析失败:%v", err)
  3599. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3600. // return
  3601. //}
  3602. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3603. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3604. utils.ErrorLog("解析失败:%v", err)
  3605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3606. return
  3607. }
  3608. //if res3507for10188.Infcode
  3609. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3610. //res.Output = resSix10265.Output
  3611. res3.ErrMsg = res3507for10188.ErrMsg
  3612. res3.Cainfo = res3507for10188.Cainfo
  3613. res3.WarnMsg = res3507for10188.WarnMsg
  3614. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3615. res3.Infcode = infocode
  3616. } else {
  3617. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3618. utils.ErrorLog("解析失败:%v", err)
  3619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3620. return
  3621. }
  3622. }
  3623. if res3.Infcode == 0 {
  3624. item.IsChange = 1
  3625. item.BgBchno = bg_number
  3626. service.SaveDF2(item)
  3627. } else {
  3628. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3629. }
  3630. }
  3631. }
  3632. }
  3633. }
  3634. if len(err) == 0 {
  3635. c.ServeSuccessJSON(map[string]interface{}{
  3636. "msg": "销售变更成功",
  3637. })
  3638. } else {
  3639. c.ServeSuccessJSON(map[string]interface{}{
  3640. "failed_code": -10,
  3641. "msg": err,
  3642. })
  3643. }
  3644. }
  3645. func (c *HisApiController) ChangeDrugtwo() {
  3646. //ids := c.GetString("ids")
  3647. //id_arr := strings.Split(ids, ",")
  3648. flows, _ := service.GetNewDrugFlowInfothree123()
  3649. admin_user_id, _ := c.GetInt64("admin_user_id")
  3650. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3651. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3652. var err []string
  3653. for _, item := range flows {
  3654. var res3 ResultSix
  3655. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3656. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3657. if prescription.OrderStatus == 2 {
  3658. //已经结算
  3659. //判断是否已经销售
  3660. //if item.IsSale == 1 { //是否已经销售,1是 0否
  3661. // //是否已经变更 1是 0否
  3662. // if item.IsChange == 0 { //没变更,进行变更操作
  3663. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3664. //
  3665. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3666. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3667. // var respJSON3 map[string]interface{}
  3668. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3669. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3670. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3671. // return
  3672. // }
  3673. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3674. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3675. // utils.ErrorLog("解析失败:%v", err)
  3676. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3677. // return
  3678. // }
  3679. // if res3.Infcode == 0 {
  3680. // item.IsChange = 1
  3681. // item.BgBchno = bg_number
  3682. // service.SaveDF2(item)
  3683. // } else {
  3684. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3685. // }
  3686. // }
  3687. //}
  3688. //else
  3689. { //没销售,
  3690. var res FJ3507Result
  3691. var res3507for10188 FJ3507ResultFor10188
  3692. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3693. //进行商品销售接口
  3694. result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3695. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3696. var respJSON3 map[string]interface{}
  3697. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3700. return
  3701. }
  3702. userJSONBytes3, _ := json.Marshal(respJSON3)
  3703. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3704. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3705. utils.ErrorLog("解析失败:%v", err)
  3706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3707. return
  3708. }
  3709. //if res3507for10188.Infcode
  3710. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3711. //res.Output = resSix10265.Output
  3712. res.ErrMsg = res3507for10188.ErrMsg
  3713. res.Cainfo = res3507for10188.Cainfo
  3714. res.WarnMsg = res3507for10188.WarnMsg
  3715. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3716. res.Infcode = infocode
  3717. } else {
  3718. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3719. utils.ErrorLog("解析失败:%v", err)
  3720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3721. return
  3722. }
  3723. }
  3724. if res.Infcode == 0 {
  3725. item.IsSale = 1
  3726. item.Bchno = number
  3727. item.SaleDate = time.Now().Format("2006-01-02")
  3728. service.SaveDF(item)
  3729. //if err5 == nil {
  3730. // if item.IsChange == 0 { //没变更,进行变更操作
  3731. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3732. //
  3733. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3734. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3735. //
  3736. // var respJSON3 map[string]interface{}
  3737. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3738. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3739. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3740. // return
  3741. // }
  3742. //
  3743. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3744. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3745. // utils.ErrorLog("解析失败:%v", err)
  3746. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3747. // return
  3748. // }
  3749. // //if res3507for10188.Infcode
  3750. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3751. // //res.Output = resSix10265.Output
  3752. // res3.ErrMsg = res3507for10188.ErrMsg
  3753. // res3.Cainfo = res3507for10188.Cainfo
  3754. // res3.WarnMsg = res3507for10188.WarnMsg
  3755. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3756. // res3.Infcode = infocode
  3757. // } else {
  3758. //
  3759. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3760. // utils.ErrorLog("解析失败:%v", err)
  3761. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3762. // return
  3763. // }
  3764. //
  3765. // }
  3766. //
  3767. // if res3.Infcode == 0 {
  3768. // item.IsChange = 1
  3769. // item.BgBchno = bg_number
  3770. // service.SaveDF2(item)
  3771. // } else {
  3772. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3773. // }
  3774. // }
  3775. //}
  3776. } else {
  3777. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3778. }
  3779. }
  3780. } else { //还没结算
  3781. var res3507for10188 FJ3507ResultFor10188
  3782. if item.IsChange == 0 { //没变更,进行变更操作
  3783. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3784. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3785. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3786. var respJSON3 map[string]interface{}
  3787. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3788. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3790. return
  3791. }
  3792. userJSONBytes3, _ := json.Marshal(respJSON3)
  3793. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3794. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3795. utils.ErrorLog("解析失败:%v", err)
  3796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3797. return
  3798. }
  3799. //if res3507for10188.Infcode
  3800. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3801. //res.Output = resSix10265.Output
  3802. res3.ErrMsg = res3507for10188.ErrMsg
  3803. res3.Cainfo = res3507for10188.Cainfo
  3804. res3.WarnMsg = res3507for10188.WarnMsg
  3805. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3806. res3.Infcode = infocode
  3807. } else {
  3808. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3809. utils.ErrorLog("解析失败:%v", err)
  3810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3811. return
  3812. }
  3813. }
  3814. if res3.Infcode == 0 {
  3815. item.IsChange = 1
  3816. item.BgBchno = bg_number
  3817. service.SaveDF2(item)
  3818. } else {
  3819. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3820. }
  3821. }
  3822. }
  3823. }
  3824. //if item.ConsumableType == 7 {
  3825. // var res3507for10188 FJ3507ResultFor10188
  3826. //
  3827. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3828. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3829. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3830. // //判断是否已经销售
  3831. // if item.IsSale == 2 { //是否已经销售,1是 0否
  3832. // //是否已经变更 1是 0否
  3833. // if item.IsChange == 0 { //没变更,进行变更操作
  3834. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3835. //
  3836. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3837. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3838. //
  3839. // var respJSON3 map[string]interface{}
  3840. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3841. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3842. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3843. // return
  3844. // }
  3845. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3846. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3847. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3848. // utils.ErrorLog("解析失败:%v", err)
  3849. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3850. // return
  3851. // }
  3852. // //if res3507for10188.Infcode
  3853. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3854. // //res.Output = resSix10265.Output
  3855. // res3.ErrMsg = res3507for10188.ErrMsg
  3856. // res3.Cainfo = res3507for10188.Cainfo
  3857. // res3.WarnMsg = res3507for10188.WarnMsg
  3858. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3859. // res3.Infcode = infocode
  3860. // } else {
  3861. //
  3862. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3863. // utils.ErrorLog("解析失败:%v", err)
  3864. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3865. // return
  3866. // }
  3867. //
  3868. // }
  3869. // if res3.Infcode == 0 {
  3870. // item.IsChange = 1
  3871. // item.BgBchno = bg_number
  3872. // service.SaveDF2(item)
  3873. // } else {
  3874. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3875. // }
  3876. // }
  3877. // } else { //没销售,
  3878. // //进行商品销售退货接口
  3879. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3880. //
  3881. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3882. // saveLog(result111, result222, "3506", "销售退货")
  3883. // var res7 FJ3507Result
  3884. //
  3885. // //进行商品销售接口
  3886. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3887. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3888. // var respJSON3 map[string]interface{}
  3889. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3890. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3891. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3892. // return
  3893. // }
  3894. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3895. //
  3896. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3897. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3898. // utils.ErrorLog("解析失败:%v", err)
  3899. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3900. // return
  3901. // }
  3902. // //if res3507for10188.Infcode
  3903. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3904. // //res.Output = resSix10265.Output
  3905. // res7.ErrMsg = res3507for10188.ErrMsg
  3906. // res7.Cainfo = res3507for10188.Cainfo
  3907. // res7.WarnMsg = res3507for10188.WarnMsg
  3908. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3909. // res7.Infcode = infocode
  3910. // } else {
  3911. //
  3912. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3913. // utils.ErrorLog("解析失败:%v", err)
  3914. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3915. // return
  3916. // }
  3917. //
  3918. // }
  3919. // if res7.Infcode == 0 {
  3920. // item.IsSale = 2
  3921. // item.SaleDate = item.SaleDate
  3922. // item.Bchno = number
  3923. // service.SaveDF(item)
  3924. // if item.IsChange == 0 { //没变更,进行变更操作
  3925. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3926. //
  3927. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3928. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3929. //
  3930. // var respJSON3 map[string]interface{}
  3931. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3932. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3933. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3934. // return
  3935. // }
  3936. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3937. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3938. // // utils.ErrorLog("解析失败:%v", err)
  3939. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3940. // // return
  3941. // //}
  3942. //
  3943. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3944. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3945. // utils.ErrorLog("解析失败:%v", err)
  3946. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3947. // return
  3948. // }
  3949. // //if res3507for10188.Infcode
  3950. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3951. // //res.Output = resSix10265.Output
  3952. // res3.ErrMsg = res3507for10188.ErrMsg
  3953. // res3.Cainfo = res3507for10188.Cainfo
  3954. // res3.WarnMsg = res3507for10188.WarnMsg
  3955. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3956. // res3.Infcode = infocode
  3957. // } else {
  3958. //
  3959. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3960. // utils.ErrorLog("解析失败:%v", err)
  3961. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3962. // return
  3963. // }
  3964. //
  3965. // }
  3966. // if res3.Infcode == 0 {
  3967. // item.IsChange = 1
  3968. // item.BgBchno = bg_number
  3969. // service.SaveDF2(item)
  3970. // } else {
  3971. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3972. // }
  3973. // }
  3974. // } else {
  3975. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3976. // }
  3977. // }
  3978. // } else { //还没结算
  3979. // if item.IsChange == 0 { //没变更,进行变更操作
  3980. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3981. //
  3982. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3983. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3984. //
  3985. // var respJSON3 map[string]interface{}
  3986. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3987. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3988. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3989. // return
  3990. // }
  3991. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3992. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3993. // // utils.ErrorLog("解析失败:%v", err)
  3994. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3995. // // return
  3996. // //}
  3997. //
  3998. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3999. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4000. // utils.ErrorLog("解析失败:%v", err)
  4001. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4002. // return
  4003. // }
  4004. // //if res3507for10188.Infcode
  4005. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4006. // //res.Output = resSix10265.Output
  4007. // res3.ErrMsg = res3507for10188.ErrMsg
  4008. // res3.Cainfo = res3507for10188.Cainfo
  4009. // res3.WarnMsg = res3507for10188.WarnMsg
  4010. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4011. // res3.Infcode = infocode
  4012. // } else {
  4013. //
  4014. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4015. // utils.ErrorLog("解析失败:%v", err)
  4016. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4017. // return
  4018. // }
  4019. //
  4020. // }
  4021. // if res3.Infcode == 0 {
  4022. // item.IsChange = 1
  4023. // item.BgBchno = bg_number
  4024. // service.SaveDF2(item)
  4025. // } else {
  4026. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4027. // }
  4028. // }
  4029. // }
  4030. //}
  4031. }
  4032. if len(err) == 0 {
  4033. c.ServeSuccessJSON(map[string]interface{}{
  4034. "msg": "销售变更成功",
  4035. })
  4036. } else {
  4037. c.ServeSuccessJSON(map[string]interface{}{
  4038. "failed_code": -10,
  4039. "msg": err,
  4040. })
  4041. }
  4042. }
  4043. func (c *HisApiController) ChangeDrugthree() {
  4044. //ids := c.GetString("ids")
  4045. //id_arr := strings.Split(ids, ",")
  4046. flows, _ := service.GetNewDrugFlowInfothree()
  4047. admin_user_id, _ := c.GetInt64("admin_user_id")
  4048. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4049. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4050. var err []string
  4051. for _, item := range flows {
  4052. var res3 ResultSix
  4053. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4054. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4055. if prescription.OrderStatus == 2 {
  4056. //已经结算
  4057. //判断是否已经销售
  4058. if item.IsSale == 1 { //是否已经销售,1是 0否
  4059. //是否已经变更 1是 0否
  4060. if item.IsChange == 0 { //没变更,进行变更操作
  4061. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4062. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4063. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4064. var respJSON3 map[string]interface{}
  4065. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4066. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4068. return
  4069. }
  4070. userJSONBytes3, _ := json.Marshal(respJSON3)
  4071. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4072. utils.ErrorLog("解析失败:%v", err)
  4073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4074. return
  4075. }
  4076. if res3.Infcode == 0 {
  4077. item.IsChange = 1
  4078. item.BgBchno = bg_number
  4079. service.SaveDF2(item)
  4080. } else {
  4081. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4082. }
  4083. }
  4084. } else { //没销售,
  4085. var res FJ3507Result
  4086. var res3507for10188 FJ3507ResultFor10188
  4087. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4088. //进行商品销售接口
  4089. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4090. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4091. var respJSON3 map[string]interface{}
  4092. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4093. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4095. return
  4096. }
  4097. userJSONBytes3, _ := json.Marshal(respJSON3)
  4098. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4099. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4100. utils.ErrorLog("解析失败:%v", err)
  4101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4102. return
  4103. }
  4104. //if res3507for10188.Infcode
  4105. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4106. //res.Output = resSix10265.Output
  4107. res.ErrMsg = res3507for10188.ErrMsg
  4108. res.Cainfo = res3507for10188.Cainfo
  4109. res.WarnMsg = res3507for10188.WarnMsg
  4110. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4111. res.Infcode = infocode
  4112. } else {
  4113. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4114. utils.ErrorLog("解析失败:%v", err)
  4115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4116. return
  4117. }
  4118. }
  4119. if res.Infcode == 0 {
  4120. item.IsSale = 1
  4121. item.Bchno = number
  4122. item.SaleDate = time.Now().Format("2006-01-02")
  4123. err5 := service.SaveDF(item)
  4124. if err5 == nil {
  4125. if item.IsChange == 0 { //没变更,进行变更操作
  4126. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4127. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4128. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4129. var respJSON3 map[string]interface{}
  4130. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4131. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4133. return
  4134. }
  4135. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4136. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4137. utils.ErrorLog("解析失败:%v", err)
  4138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4139. return
  4140. }
  4141. //if res3507for10188.Infcode
  4142. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4143. //res.Output = resSix10265.Output
  4144. res3.ErrMsg = res3507for10188.ErrMsg
  4145. res3.Cainfo = res3507for10188.Cainfo
  4146. res3.WarnMsg = res3507for10188.WarnMsg
  4147. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4148. res3.Infcode = infocode
  4149. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4150. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4151. utils.ErrorLog("解析失败:%v", err)
  4152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4153. return
  4154. }
  4155. //if res3507for10188.Infcode
  4156. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4157. //res.Output = resSix10265.Output
  4158. res3.ErrMsg = res3507for10188.ErrMsg
  4159. res3.Cainfo = res3507for10188.Cainfo
  4160. res3.WarnMsg = res3507for10188.WarnMsg
  4161. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4162. res3.Infcode = infocode
  4163. } else {
  4164. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4165. utils.ErrorLog("解析失败:%v", err)
  4166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4167. return
  4168. }
  4169. }
  4170. if res3.Infcode == 0 {
  4171. item.IsChange = 1
  4172. item.BgBchno = bg_number
  4173. service.SaveDF2(item)
  4174. } else {
  4175. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4176. }
  4177. }
  4178. }
  4179. } else {
  4180. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4181. }
  4182. }
  4183. } else { //还没结算
  4184. var res3507for10188 FJ3507ResultFor10188
  4185. if item.IsChange == 0 { //没变更,进行变更操作
  4186. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4187. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4188. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4189. var respJSON3 map[string]interface{}
  4190. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4191. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4193. return
  4194. }
  4195. userJSONBytes3, _ := json.Marshal(respJSON3)
  4196. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4197. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4198. utils.ErrorLog("解析失败:%v", err)
  4199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4200. return
  4201. }
  4202. //if res3507for10188.Infcode
  4203. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4204. //res.Output = resSix10265.Output
  4205. res3.ErrMsg = res3507for10188.ErrMsg
  4206. res3.Cainfo = res3507for10188.Cainfo
  4207. res3.WarnMsg = res3507for10188.WarnMsg
  4208. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4209. res3.Infcode = infocode
  4210. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4211. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4212. utils.ErrorLog("解析失败:%v", err)
  4213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4214. return
  4215. }
  4216. //if res3507for10188.Infcode
  4217. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4218. //res.Output = resSix10265.Output
  4219. res3.ErrMsg = res3507for10188.ErrMsg
  4220. res3.Cainfo = res3507for10188.Cainfo
  4221. res3.WarnMsg = res3507for10188.WarnMsg
  4222. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4223. res3.Infcode = infocode
  4224. } else {
  4225. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4226. utils.ErrorLog("解析失败:%v", err)
  4227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4228. return
  4229. }
  4230. }
  4231. if res3.Infcode == 0 {
  4232. item.IsChange = 1
  4233. item.BgBchno = bg_number
  4234. service.SaveDF2(item)
  4235. } else {
  4236. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4237. }
  4238. }
  4239. }
  4240. } else if item.ConsumableType == 7 {
  4241. var res3507for10188 FJ3507ResultFor10188
  4242. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4243. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4244. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4245. //判断是否已经销售
  4246. if item.IsSale == 2 { //是否已经销售,1是 0否
  4247. //是否已经变更 1是 0否
  4248. if item.IsChange == 0 { //没变更,进行变更操作
  4249. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4250. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4251. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4252. var respJSON3 map[string]interface{}
  4253. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4254. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4256. return
  4257. }
  4258. userJSONBytes3, _ := json.Marshal(respJSON3)
  4259. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4260. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4261. utils.ErrorLog("解析失败:%v", err)
  4262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4263. return
  4264. }
  4265. //if res3507for10188.Infcode
  4266. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4267. //res.Output = resSix10265.Output
  4268. res3.ErrMsg = res3507for10188.ErrMsg
  4269. res3.Cainfo = res3507for10188.Cainfo
  4270. res3.WarnMsg = res3507for10188.WarnMsg
  4271. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4272. res3.Infcode = infocode
  4273. } else {
  4274. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4275. utils.ErrorLog("解析失败:%v", err)
  4276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4277. return
  4278. }
  4279. }
  4280. if res3.Infcode == 0 {
  4281. item.IsChange = 1
  4282. item.BgBchno = bg_number
  4283. service.SaveDF2(item)
  4284. } else {
  4285. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4286. }
  4287. }
  4288. } else { //没销售,
  4289. //进行商品销售退货接口
  4290. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4291. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4292. saveLog(result111, result222, "3506", "销售退货")
  4293. var res7 FJ3507Result
  4294. //进行商品销售接口
  4295. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4296. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4297. var respJSON3 map[string]interface{}
  4298. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4301. return
  4302. }
  4303. userJSONBytes3, _ := json.Marshal(respJSON3)
  4304. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4305. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4306. utils.ErrorLog("解析失败:%v", err)
  4307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4308. return
  4309. }
  4310. //if res3507for10188.Infcode
  4311. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4312. //res.Output = resSix10265.Output
  4313. res7.ErrMsg = res3507for10188.ErrMsg
  4314. res7.Cainfo = res3507for10188.Cainfo
  4315. res7.WarnMsg = res3507for10188.WarnMsg
  4316. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4317. res7.Infcode = infocode
  4318. } else {
  4319. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4320. utils.ErrorLog("解析失败:%v", err)
  4321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4322. return
  4323. }
  4324. }
  4325. if res7.Infcode == 0 {
  4326. item.IsSale = 2
  4327. item.SaleDate = item.SaleDate
  4328. item.Bchno = number
  4329. service.SaveDF(item)
  4330. if item.IsChange == 0 { //没变更,进行变更操作
  4331. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4332. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4333. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4334. var respJSON3 map[string]interface{}
  4335. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4336. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4338. return
  4339. }
  4340. userJSONBytes3, _ := json.Marshal(respJSON3)
  4341. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4342. // utils.ErrorLog("解析失败:%v", err)
  4343. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4344. // return
  4345. //}
  4346. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4347. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4348. utils.ErrorLog("解析失败:%v", err)
  4349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4350. return
  4351. }
  4352. //if res3507for10188.Infcode
  4353. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4354. //res.Output = resSix10265.Output
  4355. res3.ErrMsg = res3507for10188.ErrMsg
  4356. res3.Cainfo = res3507for10188.Cainfo
  4357. res3.WarnMsg = res3507for10188.WarnMsg
  4358. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4359. res3.Infcode = infocode
  4360. } else {
  4361. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4362. utils.ErrorLog("解析失败:%v", err)
  4363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4364. return
  4365. }
  4366. }
  4367. if res3.Infcode == 0 {
  4368. item.IsChange = 1
  4369. item.BgBchno = bg_number
  4370. service.SaveDF2(item)
  4371. } else {
  4372. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4373. }
  4374. }
  4375. } else {
  4376. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4377. }
  4378. }
  4379. } else { //还没结算
  4380. if item.IsChange == 0 { //没变更,进行变更操作
  4381. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4382. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4383. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4384. var respJSON3 map[string]interface{}
  4385. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4388. return
  4389. }
  4390. userJSONBytes3, _ := json.Marshal(respJSON3)
  4391. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4392. // utils.ErrorLog("解析失败:%v", err)
  4393. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4394. // return
  4395. //}
  4396. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4397. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4398. utils.ErrorLog("解析失败:%v", err)
  4399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4400. return
  4401. }
  4402. //if res3507for10188.Infcode
  4403. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4404. //res.Output = resSix10265.Output
  4405. res3.ErrMsg = res3507for10188.ErrMsg
  4406. res3.Cainfo = res3507for10188.Cainfo
  4407. res3.WarnMsg = res3507for10188.WarnMsg
  4408. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4409. res3.Infcode = infocode
  4410. } else {
  4411. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4412. utils.ErrorLog("解析失败:%v", err)
  4413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4414. return
  4415. }
  4416. }
  4417. if res3.Infcode == 0 {
  4418. item.IsChange = 1
  4419. item.BgBchno = bg_number
  4420. service.SaveDF2(item)
  4421. } else {
  4422. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4423. }
  4424. }
  4425. }
  4426. }
  4427. }
  4428. if len(err) == 0 {
  4429. c.ServeSuccessJSON(map[string]interface{}{
  4430. "msg": "销售变更成功",
  4431. })
  4432. } else {
  4433. c.ServeSuccessJSON(map[string]interface{}{
  4434. "failed_code": -10,
  4435. "msg": err,
  4436. })
  4437. }
  4438. }
  4439. func (c *HisApiController) ChangeDrugTen() {
  4440. start_time_str := c.GetString("start_time")
  4441. end_time_str := c.GetString("end_time")
  4442. //ids := c.GetString("ids")
  4443. //id_arr := strings.Split(ids, ",")
  4444. timeLayout := "2006-01-02"
  4445. loc, _ := time.LoadLocation("Local")
  4446. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4447. recordStartTime := theStartTime.Unix()
  4448. theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4449. recordEndTime := theEndTime.Unix()
  4450. //timestamp := int64(1729612800)
  4451. flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4452. admin_user_id, _ := c.GetInt64("admin_user_id")
  4453. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4454. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4455. var err []string
  4456. for _, item := range flows {
  4457. var res3 ResultSix
  4458. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4459. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4460. continue
  4461. }
  4462. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4463. continue
  4464. }
  4465. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4466. if prescription.OrderStatus == 2 {
  4467. //已经结算
  4468. //判断 是否已经销售
  4469. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4470. ////是否已经变更 1是 0否
  4471. //if item.IsChange == 0 { //没变更,进行变更操作
  4472. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4473. //
  4474. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4475. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4476. // var respJSON3 map[string]interface{}
  4477. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4478. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4479. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4480. // return
  4481. // }
  4482. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4483. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4484. // utils.ErrorLog("解析失败:%v", err)
  4485. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4486. // return
  4487. // }
  4488. // if res3.Infcode == 0 {
  4489. // item.IsChange = 1
  4490. // item.BgBchno = bg_number
  4491. // service.SaveDF2(item)
  4492. // } else {
  4493. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4494. // }
  4495. //}
  4496. //} else
  4497. if item.IsSale == 0 { //没销售,
  4498. var res FJ3507Result
  4499. var res3507for10188 FJ3507ResultFor10188
  4500. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4501. //进行商品销售接口
  4502. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4503. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4504. var respJSON3 map[string]interface{}
  4505. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4508. return
  4509. }
  4510. userJSONBytes3, _ := json.Marshal(respJSON3)
  4511. if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4512. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4513. utils.ErrorLog("解析失败:%v", err)
  4514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4515. return
  4516. }
  4517. //if res3507for10188.Infcode
  4518. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4519. //res.Output = resSix10265.Output
  4520. res.ErrMsg = res3507for10188.ErrMsg
  4521. res.Cainfo = res3507for10188.Cainfo
  4522. res.WarnMsg = res3507for10188.WarnMsg
  4523. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4524. res.Infcode = infocode
  4525. } else if c.GetAdminUserInfo().CurrentOrgId == 10480 {
  4526. } else {
  4527. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4528. utils.ErrorLog("解析失败:%v", err)
  4529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4530. return
  4531. }
  4532. }
  4533. if res.Infcode == 0 {
  4534. item.IsSale = 1
  4535. item.Bchno = number
  4536. item.SaleDate = time.Now().Format("2006-01-02")
  4537. err5 := service.SaveDF(item)
  4538. utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  4539. //if err5 == nil {
  4540. //
  4541. // if item.IsChange == 1 { //没变更,进行变更操作
  4542. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4543. //
  4544. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4545. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4546. //
  4547. // var respJSON3 map[string]interface{}
  4548. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4549. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4550. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4551. // return
  4552. // }
  4553. //
  4554. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4555. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4556. // utils.ErrorLog("解析失败:%v", err)
  4557. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4558. // return
  4559. // }
  4560. // //if res3507for10188.Infcode
  4561. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4562. // //res.Output = resSix10265.Output
  4563. // res3.ErrMsg = res3507for10188.ErrMsg
  4564. // res3.Cainfo = res3507for10188.Cainfo
  4565. // res3.WarnMsg = res3507for10188.WarnMsg
  4566. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4567. // res3.Infcode = infocode
  4568. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4569. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4570. // utils.ErrorLog("解析失败:%v", err)
  4571. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4572. // return
  4573. // }
  4574. // //if res3507for10188.Infcode
  4575. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4576. // //res.Output = resSix10265.Output
  4577. // res3.ErrMsg = res3507for10188.ErrMsg
  4578. // res3.Cainfo = res3507for10188.Cainfo
  4579. // res3.WarnMsg = res3507for10188.WarnMsg
  4580. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4581. // res3.Infcode = infocode
  4582. //
  4583. // } else {
  4584. //
  4585. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4586. // utils.ErrorLog("解析失败:%v", err)
  4587. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4588. // return
  4589. // }
  4590. //
  4591. // }
  4592. //
  4593. // if res3.Infcode == 0 {
  4594. // item.IsChange = 1
  4595. // item.BgBchno = bg_number
  4596. // service.SaveDF2(item)
  4597. // return
  4598. // } else {
  4599. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4600. // }
  4601. // }
  4602. //}
  4603. } else {
  4604. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4605. }
  4606. }
  4607. }
  4608. } else if item.ConsumableType == 7 {
  4609. var res3507for10188 FJ3507ResultFor10188
  4610. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4611. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4612. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4613. //判断是否已经销售
  4614. if item.IsSale == 2 { //是否已经销售,1是 0否
  4615. //是否已经变更 1是 0否
  4616. if item.IsChange == 0 { //没变更,进行变更操作
  4617. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4618. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4619. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4620. var respJSON3 map[string]interface{}
  4621. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4622. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4624. return
  4625. }
  4626. userJSONBytes3, _ := json.Marshal(respJSON3)
  4627. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4628. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4629. utils.ErrorLog("解析失败:%v", err)
  4630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4631. return
  4632. }
  4633. //if res3507for10188.Infcode
  4634. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4635. //res.Output = resSix10265.Output
  4636. res3.ErrMsg = res3507for10188.ErrMsg
  4637. res3.Cainfo = res3507for10188.Cainfo
  4638. res3.WarnMsg = res3507for10188.WarnMsg
  4639. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4640. res3.Infcode = infocode
  4641. } else {
  4642. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4643. utils.ErrorLog("解析失败:%v", err)
  4644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4645. return
  4646. }
  4647. }
  4648. if res3.Infcode == 0 {
  4649. item.IsChange = 1
  4650. item.BgBchno = bg_number
  4651. service.SaveDF2(item)
  4652. } else {
  4653. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4654. }
  4655. }
  4656. } else { //没销售,
  4657. //进行商品销售退货接口
  4658. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4659. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4660. saveLog(result111, result222, "3506", "销售退货")
  4661. var res7 FJ3507Result
  4662. //进行商品销售接口
  4663. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4664. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4665. var respJSON3 map[string]interface{}
  4666. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4669. return
  4670. }
  4671. userJSONBytes3, _ := json.Marshal(respJSON3)
  4672. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4673. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4674. utils.ErrorLog("解析失败:%v", err)
  4675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4676. return
  4677. }
  4678. //if res3507for10188.Infcode
  4679. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4680. //res.Output = resSix10265.Output
  4681. res7.ErrMsg = res3507for10188.ErrMsg
  4682. res7.Cainfo = res3507for10188.Cainfo
  4683. res7.WarnMsg = res3507for10188.WarnMsg
  4684. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4685. res7.Infcode = infocode
  4686. } else {
  4687. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4688. utils.ErrorLog("解析失败:%v", err)
  4689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4690. return
  4691. }
  4692. }
  4693. if res7.Infcode == 0 {
  4694. item.IsSale = 2
  4695. item.SaleDate = item.SaleDate
  4696. item.Bchno = number
  4697. service.SaveDF(item)
  4698. if item.IsChange == 0 { //没变更,进行变更操作
  4699. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4700. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4701. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4702. var respJSON3 map[string]interface{}
  4703. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4704. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4706. return
  4707. }
  4708. userJSONBytes3, _ := json.Marshal(respJSON3)
  4709. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4710. // utils.ErrorLog("解析失败:%v", err)
  4711. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4712. // return
  4713. //}
  4714. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4715. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4716. utils.ErrorLog("解析失败:%v", err)
  4717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4718. return
  4719. }
  4720. //if res3507for10188.Infcode
  4721. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4722. //res.Output = resSix10265.Output
  4723. res3.ErrMsg = res3507for10188.ErrMsg
  4724. res3.Cainfo = res3507for10188.Cainfo
  4725. res3.WarnMsg = res3507for10188.WarnMsg
  4726. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4727. res3.Infcode = infocode
  4728. } else {
  4729. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4730. utils.ErrorLog("解析失败:%v", err)
  4731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4732. return
  4733. }
  4734. }
  4735. if res3.Infcode == 0 {
  4736. item.IsChange = 1
  4737. item.BgBchno = bg_number
  4738. service.SaveDF2(item)
  4739. } else {
  4740. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4741. }
  4742. }
  4743. } else {
  4744. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4745. }
  4746. }
  4747. } else { //还没结算
  4748. if item.IsChange == 0 { //没变更,进行变更操作
  4749. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4750. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4751. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4752. var respJSON3 map[string]interface{}
  4753. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4756. return
  4757. }
  4758. userJSONBytes3, _ := json.Marshal(respJSON3)
  4759. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4760. // utils.ErrorLog("解析失败:%v", err)
  4761. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4762. // return
  4763. //}
  4764. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4765. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4766. utils.ErrorLog("解析失败:%v", err)
  4767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4768. return
  4769. }
  4770. //if res3507for10188.Infcode
  4771. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4772. //res.Output = resSix10265.Output
  4773. res3.ErrMsg = res3507for10188.ErrMsg
  4774. res3.Cainfo = res3507for10188.Cainfo
  4775. res3.WarnMsg = res3507for10188.WarnMsg
  4776. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4777. res3.Infcode = infocode
  4778. } else {
  4779. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4780. utils.ErrorLog("解析失败:%v", err)
  4781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4782. return
  4783. }
  4784. }
  4785. if res3.Infcode == 0 {
  4786. item.IsChange = 1
  4787. item.BgBchno = bg_number
  4788. service.SaveDF2(item)
  4789. } else {
  4790. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4791. }
  4792. }
  4793. }
  4794. }
  4795. }
  4796. if len(err) == 0 {
  4797. c.ServeSuccessJSON(map[string]interface{}{
  4798. "msg": "销售变更成功",
  4799. })
  4800. } else {
  4801. c.ServeSuccessJSON(map[string]interface{}{
  4802. "failed_code": -10,
  4803. "msg": err,
  4804. })
  4805. }
  4806. }
  4807. func ChangeDrugTenone() {
  4808. //ids := c.GetString("ids")
  4809. //id_arr := strings.Split(ids, ",")
  4810. now := time.Now()
  4811. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  4812. //timestamp := int64(1729612800)
  4813. flows, _ := service.GetNewDrugFlowInforTen(timestamp, 10188)
  4814. admin_user_id := int64(2463)
  4815. roles, _ := service.GetAdminUserInfoByID(10188, admin_user_id)
  4816. miConfig, _ := service.FindMedicalInsuranceInfo(10188)
  4817. var err []string
  4818. for _, item := range flows {
  4819. var res3 ResultSix
  4820. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4821. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4822. continue
  4823. }
  4824. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4825. continue
  4826. }
  4827. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4828. if prescription.OrderStatus == 2 {
  4829. //已经结算
  4830. //判断是否已经销售
  4831. if item.IsSale == 1 { //是否已经销售,1是 0否
  4832. //是否已经变更 1是 0否
  4833. if item.IsChange == 0 { //没变更,进行变更操作
  4834. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4835. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4836. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4837. var respJSON3 map[string]interface{}
  4838. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4839. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4840. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4841. return
  4842. }
  4843. userJSONBytes3, _ := json.Marshal(respJSON3)
  4844. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4845. utils.ErrorLog("解析失败:%v", err)
  4846. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4847. return
  4848. }
  4849. if res3.Infcode == 0 {
  4850. item.IsChange = 1
  4851. item.BgBchno = bg_number
  4852. service.SaveDF2(item)
  4853. } else {
  4854. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4855. }
  4856. }
  4857. } else { //没销售,
  4858. var res FJ3507Result
  4859. var res3507for10188 FJ3507ResultFor10188
  4860. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4861. //进行商品销售接口
  4862. result3, result4 := SaleStock(10188, prescription, item, miConfig, "", roles, number)
  4863. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4864. var respJSON3 map[string]interface{}
  4865. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4867. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4868. return
  4869. }
  4870. userJSONBytes3, _ := json.Marshal(respJSON3)
  4871. {
  4872. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4873. utils.ErrorLog("解析失败:%v", err)
  4874. return
  4875. }
  4876. //if res3507for10188.Infcode
  4877. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4878. //res.Output = resSix10265.Output
  4879. res.ErrMsg = res3507for10188.ErrMsg
  4880. res.Cainfo = res3507for10188.Cainfo
  4881. res.WarnMsg = res3507for10188.WarnMsg
  4882. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4883. res.Infcode = infocode
  4884. }
  4885. if res.Infcode == 0 {
  4886. item.IsSale = 1
  4887. item.Bchno = number
  4888. item.SaleDate = time.Now().Format("2006-01-02")
  4889. err5 := service.SaveDF(item)
  4890. if err5 == nil {
  4891. if item.IsChange == 1 { //没变更,进行变更操作
  4892. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4893. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4894. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4895. var respJSON3 map[string]interface{}
  4896. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4897. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4898. return
  4899. }
  4900. {
  4901. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4902. utils.ErrorLog("解析失败:%v", err)
  4903. return
  4904. }
  4905. //if res3507for10188.Infcode
  4906. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4907. //res.Output = resSix10265.Output
  4908. res3.ErrMsg = res3507for10188.ErrMsg
  4909. res3.Cainfo = res3507for10188.Cainfo
  4910. res3.WarnMsg = res3507for10188.WarnMsg
  4911. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4912. res3.Infcode = infocode
  4913. }
  4914. if res3.Infcode == 0 {
  4915. item.IsChange = 1
  4916. item.BgBchno = bg_number
  4917. service.SaveDF2(item)
  4918. } else {
  4919. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4920. }
  4921. }
  4922. }
  4923. } else {
  4924. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4925. }
  4926. }
  4927. }
  4928. }
  4929. }
  4930. }
  4931. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4932. var struct3502 models.Struct3502
  4933. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4934. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4935. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4936. struct3502.FixmedinsCode = miConfig.Code
  4937. struct3502.Code = miConfig.Code
  4938. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  4939. struct3502.Opter = role.UserName
  4940. struct3502.RxFlag = "1"
  4941. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  4942. struct3502.OrgName = miConfig.OrgName
  4943. struct3502.AccessKey = miConfig.AccessKey
  4944. struct3502.RequestUrl = miConfig.Url
  4945. struct3502.SecretKey = miConfig.SecretKey
  4946. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4947. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4948. struct3502.Url = miConfig.Url
  4949. struct3502.AppId = miConfig.Cainfo
  4950. struct3502.AppSecret = miConfig.AppSecret
  4951. struct3502.Enckey = miConfig.EncKey
  4952. struct3502.SignKey = miConfig.SignKey
  4953. struct3502.SecretKey = miConfig.SecretKey
  4954. struct3502.InvChgType = chgType
  4955. struct3502.FixmedinsBchno = number
  4956. struct3502.Cnt = strconv.FormatInt(count, 10)
  4957. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  4958. //result1, result2, _ := service.FJyb3502(struct3502)
  4959. if miConfig.MdtrtareaAdmvs == "350500" {
  4960. result1, result2, _ := service.FJyb3502(struct3502)
  4961. //saveLog(result1, result2, "3502", "3502")
  4962. return result1, result2
  4963. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4964. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  4965. return result1, result2
  4966. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  4967. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  4968. return result1, result2
  4969. } else {
  4970. data := make(map[string]interface{})
  4971. data["struct_3502s"] = struct3502
  4972. client := &http.Client{}
  4973. bytesData, _ := json.Marshal(data)
  4974. var req *http.Request
  4975. if miConfig.MdtrtareaAdmvs == "320921" {
  4976. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4977. } else {
  4978. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4979. }
  4980. resp, _ := client.Do(req)
  4981. defer resp.Body.Close()
  4982. body, ioErr := ioutil.ReadAll(resp.Body)
  4983. if ioErr != nil {
  4984. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4985. }
  4986. var respJSON map[string]interface{}
  4987. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4989. }
  4990. //var resSix10265 ResultSix10265 //1101结果
  4991. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4992. result, _ := json.Marshal(respJSON)
  4993. return string(result), ""
  4994. }
  4995. }
  4996. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4997. var struct3505 models.Struct3505
  4998. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4999. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5000. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5001. struct3505.FixmedinsBchno = number
  5002. struct3505.Opter = role.UserName
  5003. struct3505.Bchno = "---"
  5004. struct3505.FixmedinsCode = miConfig.Code
  5005. struct3505.Code = miConfig.Code
  5006. struct3505.FinlTrnsPric = drug.HisDoctorAdviceInfo.Price
  5007. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5008. struct3505.PrscDrName = roles.UserName
  5009. if org_id == 10191 {
  5010. struct3505.PharName = "刘水山"
  5011. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5012. }
  5013. if org_id == 10188 {
  5014. struct3505.PharName = "李汉清"
  5015. struct3505.PharPracCertNo = "30220200932022010034"
  5016. }
  5017. if org_id == 10217 {
  5018. struct3505.PharName = "张敏"
  5019. struct3505.PharPracCertNo = "30220230432090100108"
  5020. }
  5021. if org_id == 10318 {
  5022. struct3505.PharName = "邹刘阳"
  5023. struct3505.PharPracCertNo = "210441200001378"
  5024. }
  5025. if org_id == 10402 {
  5026. struct3505.PharName = "刘韶健"
  5027. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5028. }
  5029. if org_id == 9919 {
  5030. struct3505.PharName = "周君权"
  5031. struct3505.PharPracCertNo = "089644396094401375"
  5032. }
  5033. if org_id == 10644 {
  5034. struct3505.PharName = "陈金娣"
  5035. struct3505.PharPracCertNo = "20181441500320100066"
  5036. }
  5037. if org_id == 10567 {
  5038. struct3505.PharName = "范小兰"
  5039. struct3505.PharPracCertNo = "0200102079485"
  5040. }
  5041. if org_id == 10721 {
  5042. struct3505.PharName = "孙莉侠"
  5043. struct3505.PharPracCertNo = "060399"
  5044. }
  5045. if org_id == 10726 {
  5046. struct3505.PharName = "彭建福"
  5047. struct3505.PharPracCertNo = "D445281006261"
  5048. }
  5049. if org_id == 10265 {
  5050. struct3505.PharName = "李彩星"
  5051. struct3505.PharPracCertNo = "20171110600110100019"
  5052. }
  5053. if org_id == 10028 {
  5054. struct3505.PharName = "曾细平"
  5055. struct3505.PharPracCertNo = "D440307022134"
  5056. }
  5057. if org_id == 10138 {
  5058. struct3505.PharName = "彭斯遥"
  5059. struct3505.PharPracCertNo = "30220200943042010052"
  5060. }
  5061. if org_id == 10278 {
  5062. struct3505.PharName = "彭斯遥"
  5063. struct3505.PharPracCertNo = "30220200943042010052"
  5064. }
  5065. if org_id == 10610 {
  5066. struct3505.PharName = "彭斯遥"
  5067. struct3505.PharPracCertNo = "30220200943042010052"
  5068. }
  5069. if org_id == 10537 {
  5070. struct3505.PharName = "彭斯遥"
  5071. struct3505.PharPracCertNo = "30220200943042010052"
  5072. }
  5073. if org_id == 9504 {
  5074. struct3505.PharName = "资美红"
  5075. struct3505.PharPracCertNo = "D440904006635"
  5076. }
  5077. if org_id == 10480 {
  5078. struct3505.PharName = "陈思"
  5079. struct3505.PharPracCertNo = "30220240434110010470"
  5080. }
  5081. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5082. struct3505.SetlId = order.SetlId
  5083. struct3505.MdtrtSn = order.MdtrtId
  5084. struct3505.ManuLotnum = drug.BatchNumber
  5085. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5086. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5087. struct3505.RxFlag = "1"
  5088. if drug.HisDoctorAdviceInfo.PrescribingNumberUnit != drug.HisDoctorAdviceInfo.BaseDrugLib.MinUnit {
  5089. struct3505.TrdnFlag = "0"
  5090. } else {
  5091. struct3505.TrdnFlag = "1"
  5092. }
  5093. if drug.HisDoctorAdviceInfo.ZeroFlag == 1 {
  5094. struct3505.TrdnFlag = "1"
  5095. }
  5096. if drug.HisDoctorAdviceInfo.ZeroFlag == 2 {
  5097. struct3505.TrdnFlag = "0"
  5098. }
  5099. struct3505.RtalDocno = order.Number
  5100. struct3505.PsnCertType = "01"
  5101. struct3505.CertNo = order.Certno
  5102. struct3505.PsnNo = order.PsnNo
  5103. struct3505.PsnName = order.PsnName
  5104. struct3505.Url = miConfig.Url
  5105. struct3505.AppId = miConfig.Cainfo
  5106. struct3505.AppSecret = miConfig.AppSecret
  5107. struct3505.Enckey = miConfig.EncKey
  5108. struct3505.SignKey = miConfig.SignKey
  5109. struct3505.SecretKey = miConfig.SecretKey
  5110. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5111. struct3505.SelRetnCnt = strValue
  5112. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5113. struct3505.SelRetnOpterName = role.UserName
  5114. if order.IsMedicineInsurance == 1 {
  5115. struct3505.MdtrtSetlType = "1"
  5116. } else {
  5117. struct3505.MdtrtSetlType = "2"
  5118. }
  5119. struct3505.OrgName = miConfig.OrgName
  5120. struct3505.AccessKey = miConfig.AccessKey
  5121. struct3505.RequestUrl = miConfig.Url
  5122. struct3505.SecretKey = miConfig.SecretKey
  5123. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5124. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5125. struct3505.Cainfo = miConfig.Cainfo
  5126. struct3505.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5127. if miConfig.MdtrtareaAdmvs == "350500" {
  5128. result1, result2, _ := service.FJyb3505(struct3505)
  5129. return result1, result2
  5130. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5131. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5132. return result1, result2
  5133. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5134. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5135. return result1, result2
  5136. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5137. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5138. return result1, result2
  5139. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5140. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5141. return result1, result2
  5142. } else if miConfig.MdtrtareaAdmvs == "150499" {
  5143. data := make(map[string]interface{})
  5144. data["struct_3505s"] = struct3505
  5145. client := &http.Client{}
  5146. bytesData, _ := json.Marshal(data)
  5147. var req *http.Request
  5148. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  5149. resp, _ := client.Do(req)
  5150. defer resp.Body.Close()
  5151. body, ioErr := ioutil.ReadAll(resp.Body)
  5152. if ioErr != nil {
  5153. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5154. }
  5155. var respJSON map[string]interface{}
  5156. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5158. }
  5159. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5160. result, _ := json.Marshal(respJSON)
  5161. return string(result), ""
  5162. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5163. data := make(map[string]interface{})
  5164. data["struct_3505s"] = struct3505
  5165. client := &http.Client{}
  5166. bytesData, _ := json.Marshal(data)
  5167. var req *http.Request
  5168. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3505", bytes.NewReader(bytesData))
  5169. resp, _ := client.Do(req)
  5170. defer resp.Body.Close()
  5171. body, ioErr := ioutil.ReadAll(resp.Body)
  5172. if ioErr != nil {
  5173. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5174. }
  5175. var respJSON map[string]interface{}
  5176. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5177. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5178. }
  5179. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5180. if status == "0" {
  5181. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5182. utils.ErrorLog("接口返回数据读取失败: %v", err_msg)
  5183. }
  5184. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5185. result, _ := json.Marshal(respJSON)
  5186. return string(result), ""
  5187. } else {
  5188. data := make(map[string]interface{})
  5189. data["struct_3505s"] = struct3505
  5190. client := &http.Client{}
  5191. bytesData, _ := json.Marshal(data)
  5192. var req *http.Request
  5193. if miConfig.MdtrtareaAdmvs == "320921" {
  5194. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5195. } else {
  5196. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5197. }
  5198. resp, _ := client.Do(req)
  5199. defer resp.Body.Close()
  5200. body, ioErr := ioutil.ReadAll(resp.Body)
  5201. if ioErr != nil {
  5202. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5203. }
  5204. var respJSON map[string]interface{}
  5205. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5206. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5207. }
  5208. //var resSix10265 ResultSix10265 //1101结果
  5209. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5210. result, _ := json.Marshal(respJSON)
  5211. return string(result), ""
  5212. }
  5213. }
  5214. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5215. var struct3505 models.Struct3505
  5216. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5217. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5218. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5219. struct3505.FixmedinsBchno = number
  5220. struct3505.Opter = role.UserName
  5221. struct3505.FixmedinsCode = miConfig.Code
  5222. struct3505.Code = miConfig.Code
  5223. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5224. struct3505.PrscDrName = roles.UserName
  5225. if org_id == 10191 {
  5226. struct3505.PharName = "刘水山"
  5227. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5228. }
  5229. if org_id == 10188 {
  5230. struct3505.PharName = "李汉清"
  5231. struct3505.PharPracCertNo = "30220200932022010034"
  5232. }
  5233. if org_id == 10217 {
  5234. struct3505.PharName = "张敏"
  5235. struct3505.PharPracCertNo = "30220230432090100108"
  5236. }
  5237. if org_id == 10318 {
  5238. struct3505.PharName = "邹刘阳"
  5239. struct3505.PharPracCertNo = "210441200001378"
  5240. }
  5241. if org_id == 10402 {
  5242. struct3505.PharName = "刘韶健"
  5243. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5244. }
  5245. if org_id == 9919 {
  5246. struct3505.PharName = "周君权"
  5247. struct3505.PharPracCertNo = "089644396094401375"
  5248. }
  5249. if org_id == 10644 {
  5250. struct3505.PharName = "陈金娣"
  5251. struct3505.PharPracCertNo = "20181441500320100066"
  5252. }
  5253. if org_id == 10567 {
  5254. struct3505.PharName = "范小兰"
  5255. struct3505.PharPracCertNo = "0200102079485"
  5256. }
  5257. if org_id == 10721 {
  5258. struct3505.PharName = "孙莉侠"
  5259. struct3505.PharPracCertNo = "060399"
  5260. }
  5261. if org_id == 10726 {
  5262. struct3505.PharName = "彭建福"
  5263. struct3505.PharPracCertNo = "D445281006261"
  5264. }
  5265. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5266. struct3505.SetlId = order.SetlId
  5267. struct3505.MdtrtSn = order.MdtrtId
  5268. struct3505.ManuLotnum = drug.Number
  5269. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5270. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5271. struct3505.RxFlag = "1"
  5272. struct3505.TrdnFlag = "0"
  5273. struct3505.RtalDocno = order.Number
  5274. struct3505.PsnCertType = "01"
  5275. struct3505.CertNo = order.Certno
  5276. struct3505.PsnNo = order.PsnNo
  5277. struct3505.PsnName = order.PsnName
  5278. struct3505.Url = miConfig.Url
  5279. struct3505.AppId = miConfig.Cainfo
  5280. struct3505.AppSecret = miConfig.AppSecret
  5281. struct3505.Enckey = miConfig.EncKey
  5282. struct3505.SignKey = miConfig.SignKey
  5283. struct3505.SecretKey = miConfig.SecretKey
  5284. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5285. struct3505.SelRetnCnt = strValue
  5286. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5287. struct3505.SelRetnOpterName = role.UserName
  5288. if order.IsMedicineInsurance == 1 {
  5289. struct3505.MdtrtSetlType = "1"
  5290. } else {
  5291. struct3505.MdtrtSetlType = "2"
  5292. }
  5293. struct3505.OrgName = miConfig.OrgName
  5294. struct3505.AccessKey = miConfig.AccessKey
  5295. struct3505.RequestUrl = miConfig.Url
  5296. struct3505.SecretKey = miConfig.SecretKey
  5297. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5298. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5299. struct3505.Cainfo = miConfig.Cainfo
  5300. struct3505.DrugTracCodg = drug.DrugCode
  5301. if miConfig.MdtrtareaAdmvs == "350500" {
  5302. result1, result2, _ := service.FJyb3505(struct3505)
  5303. return result1, result2
  5304. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5305. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5306. return result1, result2
  5307. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5308. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5309. return result1, result2
  5310. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5311. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5312. return result1, result2
  5313. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5314. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5315. return result1, result2
  5316. } else {
  5317. data := make(map[string]interface{})
  5318. data["struct_3505s"] = struct3505
  5319. client := &http.Client{}
  5320. bytesData, _ := json.Marshal(data)
  5321. var req *http.Request
  5322. if miConfig.MdtrtareaAdmvs == "320921" {
  5323. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5324. } else {
  5325. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5326. }
  5327. resp, _ := client.Do(req)
  5328. defer resp.Body.Close()
  5329. body, ioErr := ioutil.ReadAll(resp.Body)
  5330. if ioErr != nil {
  5331. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5332. }
  5333. var respJSON map[string]interface{}
  5334. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5335. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5336. }
  5337. //var resSix10265 ResultSix10265 //1101结果
  5338. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5339. result, _ := json.Marshal(respJSON)
  5340. return string(result), ""
  5341. }
  5342. }
  5343. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5344. var struct3506 models.Struct3506
  5345. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5346. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5347. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5348. struct3506.FixmedinsCode = miConfig.Code
  5349. struct3506.Code = miConfig.Code
  5350. struct3506.FixmedinsBchno = number
  5351. struct3506.Opter = role.UserName
  5352. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5353. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5354. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5355. struct3506.MdtrtSn = order.MdtrtId
  5356. struct3506.ExpyEnd = ""
  5357. struct3506.RxFlag = "0"
  5358. struct3506.TrdnFlag = "1"
  5359. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5360. struct3506.SelRetnCnt = strValue
  5361. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5362. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5363. struct3506.SelRetnOpterName = role.UserName
  5364. struct3506.OrgName = miConfig.OrgName
  5365. struct3506.AccessKey = miConfig.AccessKey
  5366. struct3506.RequestUrl = miConfig.Url
  5367. struct3506.SecretKey = miConfig.SecretKey
  5368. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5369. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5370. struct3506.Url = miConfig.Url
  5371. struct3506.AppId = miConfig.Cainfo
  5372. struct3506.AppSecret = miConfig.AppSecret
  5373. struct3506.Enckey = miConfig.EncKey
  5374. struct3506.SignKey = miConfig.SignKey
  5375. struct3506.SecretKey = miConfig.SecretKey
  5376. struct3506.DrugTracCodg = drug.DrugCode
  5377. if miConfig.MdtrtareaAdmvs == "350500" {
  5378. result1, result2, _ := service.FJyb3506(struct3506)
  5379. return result1, result2
  5380. } else {
  5381. data := make(map[string]interface{})
  5382. data["struct_3506s"] = struct3506
  5383. client := &http.Client{}
  5384. bytesData, _ := json.Marshal(data)
  5385. var req *http.Request
  5386. if miConfig.MdtrtareaAdmvs == "320921" {
  5387. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5388. } else {
  5389. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5390. }
  5391. resp, _ := client.Do(req)
  5392. defer resp.Body.Close()
  5393. body, ioErr := ioutil.ReadAll(resp.Body)
  5394. if ioErr != nil {
  5395. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5396. }
  5397. var respJSON map[string]interface{}
  5398. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5400. }
  5401. //var resSix10265 ResultSix10265 //1101结果
  5402. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5403. result, _ := json.Marshal(respJSON)
  5404. return string(result), ""
  5405. }
  5406. }
  5407. func (c *HisApiController) Get1318() {
  5408. adminUser := c.GetAdminUserInfo()
  5409. admin_user_id, _ := c.GetInt64("admin_user_id")
  5410. code := c.GetString("code")
  5411. code = ""
  5412. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5413. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5414. api := ""
  5415. if miConfig.MdtrtareaAdmvs == "320921" {
  5416. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5417. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5418. } else {
  5419. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5420. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5421. }
  5422. resp, requestErr := http.Get(api)
  5423. if requestErr != nil {
  5424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5425. return
  5426. }
  5427. body, ioErr := ioutil.ReadAll(resp.Body)
  5428. if ioErr != nil {
  5429. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5431. return
  5432. }
  5433. var respJSON map[string]interface{}
  5434. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5435. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5437. return
  5438. }
  5439. //var res Result2406
  5440. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5441. result, _ := json.Marshal(respJSON)
  5442. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5443. utils.ErrorLog("解析失败:%v", err)
  5444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5445. return
  5446. }
  5447. if res.Infcode == "0" {
  5448. c.ServeSuccessJSON(map[string]interface{}{
  5449. "result": "",
  5450. })
  5451. } else {
  5452. c.ServeSuccessJSON(map[string]interface{}{
  5453. "failed_code": -10,
  5454. "msg": res.ErrMsg,
  5455. })
  5456. */return
  5457. //}
  5458. }
  5459. func (c *HisApiController) Get2503() {
  5460. adminUser := c.GetAdminUserInfo()
  5461. admin_user_id, _ := c.GetInt64("admin_user_id")
  5462. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5463. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5464. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5465. }
  5466. func (c *HisApiController) Get2406() {
  5467. id, _ := c.GetInt64("id")
  5468. record_time := c.GetString("record_time")
  5469. his_patient_id, _ := c.GetInt64("his_patient_id")
  5470. admin_user_id, _ := c.GetInt64("admin_user_id")
  5471. diagnosis_id := c.GetString("diagnosis")
  5472. timeLayout := "2006-01-02"
  5473. loc, _ := time.LoadLocation("Local")
  5474. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5475. if err != nil {
  5476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5477. return
  5478. }
  5479. recordDateTime := theTime.Unix()
  5480. adminUser := c.GetAdminUserInfo()
  5481. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5482. var config []*models.HisXtDiagnoseConfig
  5483. for _, item := range diagnosis_ids {
  5484. id, _ := strconv.ParseInt(item, 10, 64)
  5485. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5486. config = append(config, &diagnosisConfig)
  5487. }
  5488. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5489. fmt.Println(his_patient_id)
  5490. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5491. //timestamp := time.Now().Unix()
  5492. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5493. var patientPrescription models.HisPrescriptionInfo
  5494. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5495. if patientPrescription.ID == 0 {
  5496. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5497. }
  5498. var res2 Result2406
  5499. if miConfig.MdtrtareaAdmvs == "341203" {
  5500. data := make(map[string]interface{})
  5501. client := &http.Client{}
  5502. data["psn_no"] = his.PsnNo
  5503. data["mdtrt_id"] = his.Number
  5504. data["operator"] = roles.UserName
  5505. data["cert_no"] = his.IdCardNo
  5506. data["org_name"] = miConfig.OrgName
  5507. data["psn_name"] = his.Name
  5508. data["ipt_otp_no"] = his.IptOtpNo
  5509. data["ipt_psn_sp_flag_type"] = "0901"
  5510. data["ipt_psn_sp_flag"] = "1"
  5511. data["fixmedins_code"] = miConfig.Code
  5512. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5513. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5514. data["url"] = miConfig.Url
  5515. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5516. bytesData, _ := json.Marshal(data)
  5517. var req *http.Request
  5518. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5519. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5520. resp, _ := client.Do(req)
  5521. defer resp.Body.Close()
  5522. body, ioErr := ioutil.ReadAll(resp.Body)
  5523. if ioErr != nil {
  5524. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5526. return
  5527. }
  5528. var respJSON map[string]interface{}
  5529. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5530. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5532. return
  5533. }
  5534. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5535. if status == "0" {
  5536. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5537. c.ServeSuccessJSON(map[string]interface{}{
  5538. "failed_code": -10,
  5539. "msg": err_msg,
  5540. })
  5541. return
  5542. }
  5543. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5544. userJSONBytes, _ := json.Marshal(respJSON)
  5545. fmt.Println("log")
  5546. fmt.Println(string(userJSONBytes))
  5547. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5548. utils.ErrorLog("解析失败:%v", err)
  5549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5550. return
  5551. }
  5552. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5553. data := make(map[string]interface{})
  5554. client := &http.Client{}
  5555. data["psn_no"] = his.PsnNo
  5556. data["mdtrt_id"] = his.Number
  5557. data["operator"] = roles.UserName
  5558. data["cert_no"] = his.IdCardNo
  5559. data["org_name"] = miConfig.OrgName
  5560. data["psn_name"] = his.Name
  5561. data["ipt_otp_no"] = his.IptOtpNo
  5562. data["ipt_psn_sp_flag_type"] = "0901"
  5563. data["ipt_psn_sp_flag"] = "1"
  5564. data["fixmedins_code"] = miConfig.Code
  5565. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5566. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5567. data["url"] = miConfig.Url
  5568. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5569. bytesData, _ := json.Marshal(data)
  5570. var req *http.Request
  5571. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5572. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5573. resp, _ := client.Do(req)
  5574. defer resp.Body.Close()
  5575. body, ioErr := ioutil.ReadAll(resp.Body)
  5576. if ioErr != nil {
  5577. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5579. return
  5580. }
  5581. var respJSON map[string]interface{}
  5582. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5583. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5585. return
  5586. }
  5587. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5588. if status == "0" {
  5589. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5590. c.ServeSuccessJSON(map[string]interface{}{
  5591. "failed_code": -10,
  5592. "msg": err_msg,
  5593. })
  5594. return
  5595. }
  5596. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5597. userJSONBytes, _ := json.Marshal(respJSON)
  5598. fmt.Println("log")
  5599. fmt.Println(string(userJSONBytes))
  5600. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5601. utils.ErrorLog("解析失败:%v", err)
  5602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5603. return
  5604. }
  5605. }
  5606. if res2.Infcode != 0 {
  5607. adminUser := c.GetAdminUserInfo()
  5608. errlog := &models.HisOrderError{
  5609. UserOrgId: adminUser.CurrentOrgId,
  5610. Ctime: time.Now().Unix(),
  5611. Mtime: time.Now().Unix(),
  5612. ErrMsg: res2.ErrMsg,
  5613. Status: 1,
  5614. PatientId: id,
  5615. RecordTime: recordDateTime,
  5616. Stage: 3,
  5617. }
  5618. service.CreateErrMsgLog(errlog)
  5619. c.ServeSuccessJSON(map[string]interface{}{
  5620. "failed_code": -10,
  5621. "msg": res2.ErrMsg,
  5622. })
  5623. return
  5624. } else {
  5625. c.ServeSuccessJSON(map[string]interface{}{
  5626. "msg": "上传成功",
  5627. })
  5628. return
  5629. }
  5630. }
  5631. func (c *HisApiController) Get4105() {
  5632. }
  5633. func (c *HisApiController) Post5302() {
  5634. patient_id, _ := c.GetInt64("id")
  5635. admin_user_id, _ := c.GetInt64("admin_user_id")
  5636. p, _ := service.GetHisPatientById(patient_id)
  5637. adminUser := c.GetAdminUserInfo()
  5638. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5639. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5640. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5641. }
  5642. func (c *HisApiController) Get4104() {
  5643. }
  5644. type Output struct {
  5645. CertNo string `json:"certno"`
  5646. PsnName string `json:"psn_name"`
  5647. CardNo string `json:"card_no"`
  5648. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5649. CardSN string `json:"card_sn"`
  5650. PsnCertType string `json:"psn_cert_type"`
  5651. MdtrtCertNo string `json:"mdtrt_cert_no"`
  5652. MdtrtCertType string `json:"mdtrt_cert_type"`
  5653. QRCode string `json:"qrCode"`
  5654. EcToken string `json:"ecToken"`
  5655. }
  5656. type AHResponse struct {
  5657. Body AHBody `json:"body"`
  5658. Code int `json:"code"`
  5659. CSBCode int `json:"csbCode"`
  5660. Message string `json:"message"`
  5661. RequestID string `json:"requestId"`
  5662. State struct{} `json:"state"`
  5663. }
  5664. type AHBody struct {
  5665. ErrMsg string `json:"err_msg"`
  5666. InfRefMsgID string `json:"inf_refmsgid"`
  5667. InfCode int `json:"infcode"`
  5668. Output struct {
  5669. Result []struct {
  5670. BasMednFlag string `json:"bas_medn_flag"`
  5671. ChldMedcFlag string `json:"chld_medc_flag"`
  5672. ChrgitmLv string `json:"chrgitm_lv"`
  5673. Cnt float64 `json:"cnt"`
  5674. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5675. DrtReimFlag string `json:"drt_reim_flag"`
  5676. FeedetlSn string `json:"feedetl_sn"`
  5677. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5678. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5679. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5680. ListSpItemFlag string `json:"list_sp_item_flag"`
  5681. LmtUsedFlag string `json:"lmt_used_flag"`
  5682. MedChrgitmType string `json:"med_chrgitm_type"`
  5683. Memo string `json:"memo"`
  5684. OverlmtAmt float64 `json:"overlmt_amt"`
  5685. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5686. Pric float64 `json:"pric"`
  5687. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5688. SelfpayProp float64 `json:"selfpay_prop"`
  5689. } `json:"result"`
  5690. } `json:"output"`
  5691. }
  5692. type Response struct {
  5693. Output Output `json:"output"`
  5694. Infcode int `json:"infcode"`
  5695. InfRefMsgID string `json:"inf_refmsgid"`
  5696. RefMsgTime string `json:"refmsg_time"`
  5697. RespondTime string `json:"respond_time"`
  5698. ErrMsg string `json:"err_msg"`
  5699. WarnMsg string `json:"warn_msg"`
  5700. SignType string `json:"signtype"`
  5701. CAInfo string `json:"cainfo"`
  5702. }
  5703. func (c *HisApiController) Getquerydata() {
  5704. query_type, _ := c.GetInt64("type")
  5705. refd_setl_flag := c.GetString("refd_setl_flag")
  5706. med_type := c.GetString("med_type")
  5707. //admin_user_id,_ := c.GetInt64("admin_user_id")
  5708. cert_no := c.GetString("cert_no")
  5709. psn_no := c.GetString("psn_no")
  5710. start_time := c.GetString("start_time")
  5711. end_time := c.GetString("end_time")
  5712. page, _ := c.GetInt64("page")
  5713. limit, _ := c.GetInt64("limit")
  5714. var bp models.BusinessParams5262
  5715. bp.RefdSetlFlag = refd_setl_flag
  5716. bp.MedType = med_type
  5717. bp.Certno = cert_no
  5718. bp.Psnno = psn_no
  5719. bp.QBegntime = start_time
  5720. bp.QEndtime = end_time
  5721. if query_type == 1 { //本地
  5722. Post5262(c, bp, page, limit)
  5723. } else { //异地
  5724. Post5267(c, bp, page, limit)
  5725. }
  5726. }
  5727. func (c *HisApiController) Drugscheck() {
  5728. admin_user_id, _ := c.GetInt64("admin_user_id")
  5729. adminUser := c.GetAdminUserInfo()
  5730. var queryResult []QueryResult
  5731. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  5732. for _, item := range drugs {
  5733. result := QueryResult{
  5734. ID: item.ID,
  5735. Name: item.DrugName,
  5736. Code: item.MedicalInsuranceNumber,
  5737. List_type_code: "101",
  5738. }
  5739. queryResult = append(queryResult, result)
  5740. }
  5741. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5742. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5743. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5744. for _, item := range queryResult {
  5745. 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)
  5746. }
  5747. }
  5748. func (c *HisApiController) Goodcheck() {
  5749. admin_user_id, _ := c.GetInt64("admin_user_id")
  5750. adminUser := c.GetAdminUserInfo()
  5751. var queryResult []QueryResult
  5752. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  5753. for _, item := range goods {
  5754. result := QueryResult{
  5755. ID: item.ID,
  5756. Name: item.GoodName,
  5757. Code: item.SocialSecurityDirectoryCode,
  5758. List_type_code: "301",
  5759. }
  5760. queryResult = append(queryResult, result)
  5761. }
  5762. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5763. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5764. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5765. for _, item := range queryResult {
  5766. 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)
  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. }
  5769. }
  5770. func (c *HisApiController) Projectcheck() {
  5771. admin_user_id, _ := c.GetInt64("admin_user_id")
  5772. adminUser := c.GetAdminUserInfo()
  5773. var queryResult []QueryResult
  5774. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  5775. for _, item := range projects {
  5776. result := QueryResult{
  5777. ID: item.ID,
  5778. Name: item.ProjectName,
  5779. Code: item.MedicalCode,
  5780. List_type_code: "201",
  5781. }
  5782. queryResult = append(queryResult, result)
  5783. }
  5784. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5785. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5786. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5787. for _, item := range queryResult {
  5788. 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)
  5789. }
  5790. }
  5791. //func (c *HisApiController)CancleDia(){
  5792. //
  5793. // id, _ := c.GetInt64("id")
  5794. // record_time := c.GetString("record_time")
  5795. // his_patient_id, _ := c.GetInt64("his_patient_id")
  5796. //
  5797. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5798. //
  5799. // diagnosis_id := c.GetString("diagnosis")
  5800. // sick_type, _ := c.GetInt64("sick_type")
  5801. // reg_type, _ := c.GetInt64("p_type")
  5802. // begin_time := c.GetString("begin_time")
  5803. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  5804. //
  5805. //
  5806. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  5807. //
  5808. // fmt.Println(acct_used_flag)
  5809. //
  5810. //
  5811. // timeLayout := "2006-01-02"
  5812. // loc, _ := time.LoadLocation("Local")
  5813. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5814. // if err != nil {
  5815. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5816. // return
  5817. // }
  5818. // recordDateTime := theTime.Unix()
  5819. // adminUser := c.GetAdminUserInfo()
  5820. //
  5821. //
  5822. //
  5823. //
  5824. //
  5825. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5826. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5827. // var patientPrescription models.HisPrescriptionInfo
  5828. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5829. // if patientPrescription.ID == 0 {
  5830. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5831. // }
  5832. // //if patientPrescription.Do
  5833. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5834. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5835. //
  5836. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5837. //
  5838. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  5839. //
  5840. // var config []*models.HisXtDiagnoseConfig
  5841. // for _, item := range diagnosis_ids {
  5842. // id, _ := strconv.ParseInt(item, 10, 64)
  5843. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  5844. // config = append(config, &diagnosisConfig)
  5845. // }
  5846. //
  5847. // sickConfig, _ := service.FindSickById(sick_type)
  5848. //
  5849. //
  5850. // data := make(map[string]interface{})
  5851. // client := &http.Client{}
  5852. // data["psn_no"] = his.PsnNo
  5853. // data["mdtrt_id"] = his.Number
  5854. // data["doctor"] = roles.UserName
  5855. // data["department"] = department.Name
  5856. // data["org_name"] = miConfig.OrgName
  5857. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  5858. // data["doctor_id"] = doctor_info.DoctorNumber
  5859. // data["new_doctor_name"] = doctor_info.UserName
  5860. // data["fixmedins_code"] = miConfig.Code
  5861. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5862. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5863. // data["secret_key"] = miConfig.SecretKey
  5864. // data["sick_code"] = sickConfig.CountryCode
  5865. // data["sick_name"] = sickConfig.ClassName
  5866. // data["url"] = miConfig.Url
  5867. // data["ak"] = miConfig.AccessKey
  5868. // data["begin_time"] = begin_time
  5869. // data["cainfo"] = miConfig.Cainfo
  5870. // data["is_vaild"] = "0"
  5871. //
  5872. // data["dept"] = strconv.FormatInt(department.ID, 10)
  5873. // data["config"] = config
  5874. // bytesData, _ := json.Marshal(data)
  5875. //
  5876. // var req *http.Request
  5877. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  5878. // resp, _ := client.Do(req)
  5879. // defer resp.Body.Close()
  5880. // body, ioErr := ioutil.ReadAll(resp.Body)
  5881. // if ioErr != nil {
  5882. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5883. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5884. // return
  5885. // }
  5886. // var respJSON map[string]interface{}
  5887. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5888. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5889. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5890. // return
  5891. // }
  5892. //
  5893. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5894. // userJSONBytes, _ := json.Marshal(respJSON)
  5895. // fmt.Println("log")
  5896. // fmt.Println(string(userJSONBytes))
  5897. //
  5898. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5899. // utils.ErrorLog("解析失败:%v", err)
  5900. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5901. // return
  5902. // }
  5903. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  5904. // res2.Output = ressix10265.Output
  5905. // res2.ErrMsg = ressix10265.ErrMsg
  5906. // res2.Cainfo = ressix10265.Cainfo
  5907. // res2.WarnMsg = ressix10265.WarnMsg
  5908. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5909. // res2.Infcode = infocode
  5910. //
  5911. //}
  5912. func (c *HisApiController) Get4102() {
  5913. order_id, _ := c.GetInt64("order_id")
  5914. admin_user_id, _ := c.GetInt64("admin_user_id")
  5915. stas_type := c.GetString("stas_type")
  5916. order, _ := service.GetHisOrderByIDTwo(order_id)
  5917. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5918. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5919. var pp models.PublicParams
  5920. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5921. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5922. pp.FixmedinsName = miConfig.OrgName
  5923. pp.FixmedinsCode = miConfig.Code
  5924. pp.RequestUrl = miConfig.Url
  5925. pp.Cainfo = miConfig.Cainfo
  5926. pp.SecretKey = miConfig.SecretKey
  5927. pp.AccessKey = miConfig.AccessKey
  5928. pp.OpterName = curRoles.UserName
  5929. if miConfig.MdtrtareaAdmvs == "350500" {
  5930. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5931. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  5932. saveLog(result, request, "4102", "清单确认")
  5933. var dat map[string]interface{}
  5934. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5935. fmt.Println(dat)
  5936. } else {
  5937. fmt.Println(err)
  5938. }
  5939. var empty ResultFourteen
  5940. userJSONBytes, _ := json.Marshal(dat)
  5941. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5942. utils.ErrorLog("解析失败:%v", err)
  5943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5944. return
  5945. }
  5946. if empty.Infcode == 0 {
  5947. c.ServeSuccessJSON(map[string]interface{}{
  5948. "msg": "确认成功",
  5949. })
  5950. return
  5951. }
  5952. } else {
  5953. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5954. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  5955. result3, request3 := service.Jxyb4105(pp)
  5956. saveLog(result, request, "4102", "清单确认")
  5957. saveLog(result2, request2, "4103", "清单确认")
  5958. saveLog(result3, request3, "4105", "清单统计")
  5959. var dat map[string]interface{}
  5960. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5961. fmt.Println(dat)
  5962. } else {
  5963. fmt.Println(err)
  5964. }
  5965. var empty ResultFourteen
  5966. userJSONBytes, _ := json.Marshal(dat)
  5967. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5968. utils.ErrorLog("解析失败:%v", err)
  5969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5970. return
  5971. }
  5972. if empty.Infcode == 0 {
  5973. c.ServeSuccessJSON(map[string]interface{}{
  5974. "msg": "确认成功",
  5975. })
  5976. return
  5977. }
  5978. }
  5979. }
  5980. // 对账权限查询
  5981. func (c *HisApiController) Get3260() {
  5982. admin_user_id, _ := c.GetInt64("admin_user_id")
  5983. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5984. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5985. var api string
  5986. var res models.JSResult3260
  5987. if miConfig.MdtrtareaAdmvs == "320921" {
  5988. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5989. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5990. } else {
  5991. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5992. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5993. }
  5994. resp, requestErr := http.Get(api)
  5995. if requestErr != nil {
  5996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5997. return
  5998. }
  5999. body, ioErr := ioutil.ReadAll(resp.Body)
  6000. if ioErr != nil {
  6001. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6003. return
  6004. }
  6005. var respJSON map[string]interface{}
  6006. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6009. return
  6010. }
  6011. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6012. result, _ := json.Marshal(respJSON)
  6013. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6014. utils.ErrorLog("解析失败:%v", err)
  6015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6016. return
  6017. }
  6018. if res.Infcode == "0" {
  6019. c.ServeSuccessJSON(map[string]interface{}{
  6020. "result": res.Output.Data,
  6021. })
  6022. } else {
  6023. c.ServeSuccessJSON(map[string]interface{}{
  6024. "failed_code": -10,
  6025. "msg": res.ErrMsg,
  6026. })
  6027. return
  6028. }
  6029. }
  6030. func (c *HisApiController) Get3261() {
  6031. admin_user_id, _ := c.GetInt64("admin_user_id")
  6032. //month := c.GetString("month")
  6033. startTime := c.GetString("start_time")
  6034. //endTime, _ := c.GetString("end_time")
  6035. times := strings.Split(startTime, "-")
  6036. stmt_mon := times[0] + times[1]
  6037. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6038. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6039. var api string
  6040. var res models.JSResult3261
  6041. //var res10265 Result5301For10265
  6042. if miConfig.MdtrtareaAdmvs == "320921" {
  6043. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6044. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6045. } else {
  6046. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6047. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6048. }
  6049. resp, requestErr := http.Get(api)
  6050. if requestErr != nil {
  6051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6052. return
  6053. }
  6054. body, ioErr := ioutil.ReadAll(resp.Body)
  6055. if ioErr != nil {
  6056. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6058. return
  6059. }
  6060. var respJSON map[string]interface{}
  6061. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6062. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6064. return
  6065. }
  6066. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6067. result, _ := json.Marshal(respJSON)
  6068. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6069. utils.ErrorLog("解析失败:%v", err)
  6070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6071. return
  6072. }
  6073. if res.Infcode == "0" {
  6074. c.ServeSuccessJSON(map[string]interface{}{
  6075. "result": res.Output,
  6076. })
  6077. } else {
  6078. c.ServeSuccessJSON(map[string]interface{}{
  6079. "failed_code": -10,
  6080. "msg": res.ErrMsg,
  6081. })
  6082. return
  6083. }
  6084. }
  6085. type TempFun struct {
  6086. FundKey string
  6087. FundCode string
  6088. }
  6089. func (c *HisApiController) Get3262() {
  6090. admin_user_id, _ := c.GetInt64("admin_user_id")
  6091. startTime := c.GetString("start_time")
  6092. endTime := c.GetString("end_time")
  6093. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6094. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6095. //timeLayout := "2006-01-02"
  6096. //loc, _ := time.LoadLocation("Local")
  6097. //var theStartTIme int64
  6098. //if len(startTime) > 0 {
  6099. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  6100. // if err != nil {
  6101. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6102. // return
  6103. // }
  6104. // theStartTIme = theTime.Unix()
  6105. //}
  6106. //var theEndtTIme int64
  6107. //if len(endTime) > 0 {
  6108. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  6109. // if err != nil {
  6110. // utils.ErrorLog(err.Error())
  6111. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6112. // return
  6113. // }
  6114. // theEndtTIme = theTime.Unix()
  6115. //}
  6116. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6117. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6118. for _, team := range datas {
  6119. fmt.Println(team.PsnTime)
  6120. for _, team_two := range datas_two {
  6121. fmt.Println(team_two.PsnTime)
  6122. if team.FundKey == team_two.FundKey {
  6123. fmt.Println(team_two.PsnTime)
  6124. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  6125. fmt.Println(team.PsnTime)
  6126. }
  6127. }
  6128. }
  6129. fmt.Println("1111")
  6130. fmt.Println(datas)
  6131. fmt.Println("1111")
  6132. var twos []models.FixMonRecDetailFileInTwo
  6133. for _, team := range datas {
  6134. var two models.FixMonRecDetailFileInTwo
  6135. two.MedType = team.MedType
  6136. two.Insutype = team.Insutype
  6137. two.PsnType = team.PsnType
  6138. two.MedType = team.MedType
  6139. two.FixBlngAdmdvs = "999999"
  6140. two.InsuAdmdvs = "555555"
  6141. two.PsnTime = team.PsnTime
  6142. two.PsnCnt = team.PsnCnt
  6143. two.FundKey = team.FundKey
  6144. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6145. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6146. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6147. two.MedfeeSumAmt = ms
  6148. two.InscpAmt = ia
  6149. two.FundPaySumAmt = fps
  6150. twos = append(twos, two)
  6151. }
  6152. //startTime := c.GetString("start_time")
  6153. //endTime, _ := c.GetString("end_time")
  6154. times := strings.Split(startTime, "-")
  6155. stmt_mon := times[0] + times[1]
  6156. var funs []models.FundDetail
  6157. for _, item := range datas {
  6158. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6159. funs = append(funs, fun...)
  6160. }
  6161. var funInfos []models.Fund
  6162. //for _, item := range funs {
  6163. // var rf []models.FundInfo
  6164. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6165. // for _, subitem := range rf {
  6166. // var fund models.Fund
  6167. // fund.FundCode = subitem.FundPayType
  6168. // fund.FundName = subitem.FundPayTypeName
  6169. // fund.FundAmt = subitem.FundPayAmt
  6170. // fund.FundKey = item.FundKey
  6171. // fund.InsuAdmdvs = "555555"
  6172. // fund.FixBlngAdmdvs = "999999"
  6173. // funInfos = append(funInfos, fund)
  6174. // }
  6175. //}
  6176. var tempFuns []TempFun
  6177. for _, funInfo := range funInfos {
  6178. var tempFun TempFun
  6179. tempFun.FundKey = funInfo.FundKey
  6180. tempFun.FundCode = funInfo.FundCode
  6181. tempFuns = append(tempFuns, tempFun)
  6182. }
  6183. tempFuns = RemoveRepeatedFunElement(tempFuns)
  6184. fmt.Println(tempFuns)
  6185. var funInfosTwo []models.Fund
  6186. decimal.DivisionPrecision = 2
  6187. for _, item := range tempFuns {
  6188. var fund models.Fund
  6189. for _, subItem := range funInfos {
  6190. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  6191. fund.FundKey = subItem.FundKey
  6192. fund.InsuAdmdvs = subItem.InsuAdmdvs
  6193. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  6194. fund.FundName = subItem.FundName
  6195. fund.FundCode = subItem.FundCode
  6196. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  6197. }
  6198. }
  6199. funInfosTwo = append(funInfosTwo, fund)
  6200. }
  6201. fmt.Println("funInfosTwo")
  6202. fmt.Println(funInfosTwo)
  6203. var upld_btch string
  6204. var empty models.JSResultEmpty
  6205. data := make(map[string]interface{})
  6206. data["org_name"] = miConfig.OrgName
  6207. data["doctor"] = curRoles.UserName
  6208. data["doctor_name"] = curRoles.UserName
  6209. data["fixmedins_code"] = miConfig.Code
  6210. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6211. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6212. data["secret_key"] = miConfig.SecretKey
  6213. data["url"] = miConfig.Url
  6214. data["ak"] = miConfig.AccessKey
  6215. data["cainfo"] = miConfig.Cainfo
  6216. data["datas"] = twos
  6217. data["fund"] = funInfosTwo
  6218. fmt.Println(twos)
  6219. month := time.Unix(1557042972, 0).Format("1")
  6220. year := time.Now().Format("2006")
  6221. month = time.Now().Format("01")
  6222. day := time.Now().Format("02")
  6223. hour := time.Now().Format("15")
  6224. min := time.Now().Format("04")
  6225. sec := time.Now().Format("05")
  6226. fix_fill_date := year + month + day + hour + min + sec
  6227. data["fix_fill_dept"] = miConfig.OrgName
  6228. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6229. data["fix_fill_psn"] = curRoles.UserName
  6230. data["fix_fill_date"] = fix_fill_date
  6231. data["stmt_loc"] = "2"
  6232. data["setl_mon"] = stmt_mon
  6233. upld_btch = "0"
  6234. data["upld_btch"] = upld_btch
  6235. //fmt.Println(data)
  6236. client := &http.Client{}
  6237. bytesData, _ := json.Marshal(data)
  6238. var req *http.Request
  6239. if miConfig.MdtrtareaAdmvs == "320921" {
  6240. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6241. } else {
  6242. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6243. }
  6244. resp, _ := client.Do(req)
  6245. defer resp.Body.Close()
  6246. body, ioErr := ioutil.ReadAll(resp.Body)
  6247. if ioErr != nil {
  6248. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6250. }
  6251. var respJSON map[string]interface{}
  6252. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6255. }
  6256. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6257. //fmt.Println(respJSON)
  6258. result, _ := json.Marshal(respJSON)
  6259. //fmt.Println(result)
  6260. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6261. utils.ErrorLog("解析失败:%v", err)
  6262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6263. }
  6264. if empty.Infcode != "0" {
  6265. c.ServeSuccessJSON(map[string]interface{}{
  6266. "failed_code": -10,
  6267. "msg": empty.ErrMsg,
  6268. })
  6269. return
  6270. } else {
  6271. c.ServeSuccessJSON(map[string]interface{}{
  6272. "msg": "上传成功",
  6273. })
  6274. return
  6275. }
  6276. }
  6277. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6278. newArr = make([]TempFun, 0)
  6279. for i := 0; i < len(arr); i++ {
  6280. repeat := false
  6281. for j := i + 1; j < len(arr); j++ {
  6282. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6283. repeat = true
  6284. break
  6285. }
  6286. }
  6287. if !repeat {
  6288. newArr = append(newArr, arr[i])
  6289. }
  6290. }
  6291. return
  6292. }
  6293. func (c *HisApiController) Get3263() {
  6294. admin_user_id, _ := c.GetInt64("admin_user_id")
  6295. startTime := c.GetString("start_time")
  6296. //endTime, _ := c.GetString("end_time")
  6297. times := strings.Split(startTime, "-")
  6298. setl_mon := times[0] + times[1]
  6299. upld_btch := "0"
  6300. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6301. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6302. var result3263 models.JSResult3263
  6303. data := make(map[string]interface{})
  6304. data["org_name"] = miConfig.OrgName
  6305. data["doctor"] = curRoles.UserName
  6306. data["doctor_name"] = curRoles.UserName
  6307. data["fixmedins_code"] = miConfig.Code
  6308. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6309. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6310. data["secret_key"] = miConfig.SecretKey
  6311. data["url"] = miConfig.Url
  6312. data["ak"] = miConfig.AccessKey
  6313. data["cainfo"] = miConfig.Cainfo
  6314. data["setl_mon"] = setl_mon
  6315. data["stmt_loc"] = "2"
  6316. data["upld_btch"] = upld_btch
  6317. client := &http.Client{}
  6318. bytesData, _ := json.Marshal(data)
  6319. var req *http.Request
  6320. if miConfig.MdtrtareaAdmvs == "320921" {
  6321. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6322. } else {
  6323. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6324. }
  6325. resp, _ := client.Do(req)
  6326. defer resp.Body.Close()
  6327. body, ioErr := ioutil.ReadAll(resp.Body)
  6328. if ioErr != nil {
  6329. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6331. }
  6332. var respJSON map[string]interface{}
  6333. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6334. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6336. }
  6337. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6338. fmt.Println(respJSON)
  6339. result, _ := json.Marshal(respJSON)
  6340. fmt.Println(result)
  6341. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6342. utils.ErrorLog("解析失败:%v", err)
  6343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6344. }
  6345. if result3263.Infcode != "0" {
  6346. c.ServeSuccessJSON(map[string]interface{}{
  6347. "failed_code": -10,
  6348. "msg": result3263.ErrMsg,
  6349. })
  6350. return
  6351. } else {
  6352. c.ServeSuccessJSON(map[string]interface{}{
  6353. "list": result3263.Output,
  6354. })
  6355. return
  6356. }
  6357. }
  6358. func (c *HisApiController) Get3264() {
  6359. admin_user_id, _ := c.GetInt64("admin_user_id")
  6360. startTime := c.GetString("start_time")
  6361. //endTime, _ := c.GetString("end_time")
  6362. times := strings.Split(startTime, "-")
  6363. setl_mon := times[0] + times[1]
  6364. upld_btch := "0"
  6365. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6366. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6367. //solidify_id := []
  6368. var result3263 models.JSResult3263
  6369. data := make(map[string]interface{})
  6370. data["org_name"] = miConfig.OrgName
  6371. data["doctor"] = curRoles.UserName
  6372. data["doctor_name"] = curRoles.UserName
  6373. data["fixmedins_code"] = miConfig.Code
  6374. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6375. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6376. data["secret_key"] = miConfig.SecretKey
  6377. data["url"] = miConfig.Url
  6378. data["ak"] = miConfig.AccessKey
  6379. data["cainfo"] = miConfig.Cainfo
  6380. data["setl_mon"] = setl_mon
  6381. data["stmt_loc"] = "2"
  6382. data["upld_btch"] = upld_btch
  6383. client := &http.Client{}
  6384. bytesData, _ := json.Marshal(data)
  6385. var req3263 *http.Request
  6386. if miConfig.MdtrtareaAdmvs == "320921" {
  6387. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6388. } else {
  6389. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6390. }
  6391. resp, _ := client.Do(req3263)
  6392. defer resp.Body.Close()
  6393. body, ioErr := ioutil.ReadAll(resp.Body)
  6394. if ioErr != nil {
  6395. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6397. }
  6398. var respJSON3263 map[string]interface{}
  6399. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6400. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6402. }
  6403. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6404. fmt.Println(respJSON3263)
  6405. result, _ := json.Marshal(respJSON3263)
  6406. fmt.Println(result)
  6407. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6408. utils.ErrorLog("解析失败:%v", err)
  6409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6410. }
  6411. var ids []string
  6412. for _, item := range result3263.Output {
  6413. ids = append(ids, item.SolidifyID)
  6414. }
  6415. var empty models.JSResultEmpty
  6416. data2 := make(map[string]interface{})
  6417. data2["org_name"] = miConfig.OrgName
  6418. data2["doctor"] = curRoles.UserName
  6419. data2["doctor_name"] = curRoles.UserName
  6420. data2["fixmedins_code"] = miConfig.Code
  6421. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6422. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6423. data2["secret_key"] = miConfig.SecretKey
  6424. data2["url"] = miConfig.Url
  6425. data2["ak"] = miConfig.AccessKey
  6426. data2["cainfo"] = miConfig.Cainfo
  6427. data2["setl_mon"] = setl_mon
  6428. data2["stmt_loc"] = "2"
  6429. data2["upld_btch"] = upld_btch
  6430. data2["solidify_id"] = ids
  6431. client2 := &http.Client{}
  6432. bytesData2, _ := json.Marshal(data2)
  6433. var req *http.Request
  6434. if miConfig.MdtrtareaAdmvs == "320921" {
  6435. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6436. } else {
  6437. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6438. }
  6439. resp2, _ := client2.Do(req)
  6440. defer resp.Body.Close()
  6441. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6442. if ioErr2 != nil {
  6443. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6445. }
  6446. var respJSON map[string]interface{}
  6447. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6448. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6450. }
  6451. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6452. fmt.Println(respJSON)
  6453. result2, _ := json.Marshal(respJSON)
  6454. fmt.Println(result2)
  6455. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6456. utils.ErrorLog("解析失败:%v", err)
  6457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6458. }
  6459. if empty.Infcode != "0" {
  6460. c.ServeSuccessJSON(map[string]interface{}{
  6461. "failed_code": -10,
  6462. "msg": empty.ErrMsg,
  6463. })
  6464. return
  6465. } else {
  6466. c.ServeSuccessJSON(map[string]interface{}{
  6467. "msg": "",
  6468. })
  6469. return
  6470. }
  6471. }
  6472. func (c *HisApiController) Get3265() {
  6473. admin_user_id, _ := c.GetInt64("admin_user_id")
  6474. startTime := c.GetString("start_time")
  6475. //endTime, _ := c.GetString("end_time")
  6476. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6477. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6478. times := strings.Split(startTime, "-")
  6479. setl_mon := times[0] + times[1]
  6480. var upld_btch string
  6481. upld_btch = "0"
  6482. //var empty models.JSResultEmpty
  6483. var result3265 models.JSResult3264
  6484. var result3263 models.JSResult3263
  6485. data2 := make(map[string]interface{})
  6486. data2["org_name"] = miConfig.OrgName
  6487. data2["doctor"] = curRoles.UserName
  6488. data2["doctor_name"] = curRoles.UserName
  6489. data2["fixmedins_code"] = miConfig.Code
  6490. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6491. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6492. data2["secret_key"] = miConfig.SecretKey
  6493. data2["url"] = miConfig.Url
  6494. data2["ak"] = miConfig.AccessKey
  6495. data2["cainfo"] = miConfig.Cainfo
  6496. data2["setl_mon"] = setl_mon
  6497. data2["stmt_loc"] = "2"
  6498. data2["upld_btch"] = upld_btch
  6499. client2 := &http.Client{}
  6500. bytesData2, _ := json.Marshal(data2)
  6501. var req3263 *http.Request
  6502. if miConfig.MdtrtareaAdmvs == "320921" {
  6503. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6504. } else {
  6505. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6506. }
  6507. resp2, _ := client2.Do(req3263)
  6508. defer resp2.Body.Close()
  6509. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6510. if ioErr2 != nil {
  6511. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6513. }
  6514. var respJSON3263 map[string]interface{}
  6515. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6516. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6518. }
  6519. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6520. fmt.Println(respJSON3263)
  6521. result2, _ := json.Marshal(respJSON3263)
  6522. fmt.Println(result2)
  6523. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6524. utils.ErrorLog("解析失败:%v", err)
  6525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6526. }
  6527. var ids []string
  6528. for _, item := range result3263.Output {
  6529. ids = append(ids, item.SolidifyID)
  6530. }
  6531. data := make(map[string]interface{})
  6532. data["org_name"] = miConfig.OrgName
  6533. data["doctor"] = curRoles.UserName
  6534. data["doctor_name"] = curRoles.UserName
  6535. data["fixmedins_code"] = miConfig.Code
  6536. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6537. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6538. data["secret_key"] = miConfig.SecretKey
  6539. data["url"] = miConfig.Url
  6540. data["ak"] = miConfig.AccessKey
  6541. data["cainfo"] = miConfig.Cainfo
  6542. data["setl_mon"] = setl_mon
  6543. data["solidify_id"] = ids
  6544. month := time.Unix(1557042972, 0).Format("1")
  6545. year := time.Now().Format("2006")
  6546. month = time.Now().Format("01")
  6547. day := time.Now().Format("02")
  6548. hour := time.Now().Format("15")
  6549. min := time.Now().Format("04")
  6550. sec := time.Now().Format("05")
  6551. fix_fill_date := year + month + day + hour + min + sec
  6552. data["fix_fill_dept"] = miConfig.OrgName
  6553. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6554. data["fix_fill_psn"] = curRoles.UserName
  6555. data["fix_fill_date"] = fix_fill_date
  6556. data["stmt_loc"] = "2"
  6557. data["upld_btch"] = upld_btch
  6558. client := &http.Client{}
  6559. bytesData, _ := json.Marshal(data)
  6560. var req *http.Request
  6561. if miConfig.MdtrtareaAdmvs == "320921" {
  6562. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6563. } else {
  6564. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6565. }
  6566. resp, _ := client.Do(req)
  6567. defer resp.Body.Close()
  6568. body, ioErr := ioutil.ReadAll(resp.Body)
  6569. if ioErr != nil {
  6570. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6572. }
  6573. var respJSON map[string]interface{}
  6574. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6577. }
  6578. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6579. fmt.Println(respJSON)
  6580. result, _ := json.Marshal(respJSON)
  6581. fmt.Println(result)
  6582. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6583. utils.ErrorLog("解析失败:%v", err)
  6584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6585. }
  6586. if result3265.Infcode != "0" {
  6587. c.ServeSuccessJSON(map[string]interface{}{
  6588. "failed_code": -10,
  6589. "msg": result3265.ErrMsg,
  6590. })
  6591. return
  6592. } else {
  6593. c.ServeSuccessJSON(map[string]interface{}{
  6594. "info": result3265.Output,
  6595. })
  6596. return
  6597. }
  6598. }
  6599. func (c *HisApiController) Get3266() {
  6600. admin_user_id, _ := c.GetInt64("admin_user_id")
  6601. startTime := c.GetString("start_time")
  6602. //endTime, _ := c.GetString("end_time")
  6603. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6604. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6605. times := strings.Split(startTime, "-")
  6606. stmt_mon := times[0] + times[1]
  6607. var upld_btch string
  6608. //var empty models.JSResultEmpty
  6609. var result3265 models.JSResult3264
  6610. data := make(map[string]interface{})
  6611. data["org_name"] = miConfig.OrgName
  6612. data["doctor"] = curRoles.UserName
  6613. data["doctor_name"] = curRoles.UserName
  6614. data["fixmedins_code"] = miConfig.Code
  6615. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6616. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6617. data["secret_key"] = miConfig.SecretKey
  6618. data["url"] = miConfig.Url
  6619. data["ak"] = miConfig.AccessKey
  6620. data["cainfo"] = miConfig.Cainfo
  6621. data["setl_mon"] = stmt_mon
  6622. month := time.Unix(1557042972, 0).Format("1")
  6623. year := time.Now().Format("2006")
  6624. month = time.Now().Format("01")
  6625. day := time.Now().Format("02")
  6626. hour := time.Now().Format("15")
  6627. min := time.Now().Format("04")
  6628. sec := time.Now().Format("05")
  6629. fix_fill_date := year + month + day + hour + min + sec
  6630. data["fix_fill_dept"] = miConfig.OrgName
  6631. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6632. data["fix_fill_psn"] = curRoles.UserName
  6633. data["fix_fill_date"] = fix_fill_date
  6634. data["stmt_loc"] = "2"
  6635. upld_btch = "0"
  6636. data["upld_btch"] = upld_btch
  6637. client := &http.Client{}
  6638. bytesData, _ := json.Marshal(data)
  6639. var req *http.Request
  6640. if miConfig.MdtrtareaAdmvs == "320921" {
  6641. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6642. } else {
  6643. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6644. }
  6645. resp, _ := client.Do(req)
  6646. defer resp.Body.Close()
  6647. body, ioErr := ioutil.ReadAll(resp.Body)
  6648. if ioErr != nil {
  6649. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6651. }
  6652. var respJSON map[string]interface{}
  6653. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6654. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6656. }
  6657. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6658. fmt.Println(respJSON)
  6659. result, _ := json.Marshal(respJSON)
  6660. fmt.Println(result)
  6661. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6662. utils.ErrorLog("解析失败:%v", err)
  6663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6664. }
  6665. if result3265.Infcode != "0" {
  6666. c.ServeSuccessJSON(map[string]interface{}{
  6667. "failed_code": -10,
  6668. "msg": result3265.ErrMsg,
  6669. })
  6670. return
  6671. } else {
  6672. c.ServeSuccessJSON(map[string]interface{}{
  6673. "info": result3265.Output,
  6674. })
  6675. return
  6676. }
  6677. }
  6678. func (c *HisApiController) Get3267() {
  6679. admin_user_id, _ := c.GetInt64("admin_user_id")
  6680. startTime := c.GetString("start_time")
  6681. //endTime, _ := c.GetString("end_time")
  6682. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6683. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6684. times := strings.Split(startTime, "-")
  6685. setl_mon := times[0] + times[1]
  6686. var upld_btch string
  6687. //var empty models.JSResultEmpty
  6688. var result3265 models.JSResult3264
  6689. upld_btch = "0"
  6690. data := make(map[string]interface{})
  6691. data["org_name"] = miConfig.OrgName
  6692. data["doctor"] = curRoles.UserName
  6693. data["doctor_name"] = curRoles.UserName
  6694. data["fixmedins_code"] = miConfig.Code
  6695. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6696. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6697. data["secret_key"] = miConfig.SecretKey
  6698. data["url"] = miConfig.Url
  6699. data["ak"] = miConfig.AccessKey
  6700. data["cainfo"] = miConfig.Cainfo
  6701. data["setl_mon"] = setl_mon
  6702. data["stmt_loc"] = "2"
  6703. data["upld_btch"] = upld_btch
  6704. client := &http.Client{}
  6705. bytesData, _ := json.Marshal(data)
  6706. var req *http.Request
  6707. if miConfig.MdtrtareaAdmvs == "320921" {
  6708. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6709. } else {
  6710. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6711. }
  6712. resp, _ := client.Do(req)
  6713. defer resp.Body.Close()
  6714. body, ioErr := ioutil.ReadAll(resp.Body)
  6715. if ioErr != nil {
  6716. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6718. }
  6719. var respJSON map[string]interface{}
  6720. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6721. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6723. }
  6724. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6725. fmt.Println(respJSON)
  6726. result, _ := json.Marshal(respJSON)
  6727. fmt.Println(result)
  6728. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6729. utils.ErrorLog("解析失败:%v", err)
  6730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6731. }
  6732. if result3265.Infcode != "0" {
  6733. c.ServeSuccessJSON(map[string]interface{}{
  6734. "failed_code": -10,
  6735. "msg": result3265.ErrMsg,
  6736. })
  6737. return
  6738. } else {
  6739. c.ServeSuccessJSON(map[string]interface{}{
  6740. "info": result3265.Output.Data,
  6741. })
  6742. return
  6743. }
  6744. }
  6745. func (c *HisApiController) Get3268() {
  6746. admin_user_id, _ := c.GetInt64("admin_user_id")
  6747. startTime := c.GetString("start_time")
  6748. endTime := c.GetString("end_time")
  6749. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6750. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6751. times := strings.Split(startTime, "-")
  6752. setl_mon := times[0] + times[1]
  6753. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6754. var twos []models.FixMonRecDetailFileInTwo
  6755. var funs []models.FundDetail
  6756. for _, item := range datas {
  6757. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6758. funs = append(funs, fun...)
  6759. }
  6760. var funInfos []models.Fund
  6761. //for _, item := range funs {
  6762. // var rf []models.FundInfo
  6763. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6764. // for _, subitem := range rf {
  6765. // var fund models.Fund
  6766. // fund.FundCode = subitem.FundPayType
  6767. // fund.FundName = subitem.FundPayTypeName
  6768. // fund.FundAmt = subitem.FundPayAmt
  6769. // fund.FundKey = item.FundKey
  6770. // fund.InsuAdmdvs = "555555"
  6771. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  6772. // funInfos = append(funInfos, fund)
  6773. // }
  6774. //}
  6775. for _, team := range datas {
  6776. var two models.FixMonRecDetailFileInTwo
  6777. two.SetlDate = time.Now().Format("2006-01-02")
  6778. two.MedType = team.MedType
  6779. two.Insutype = team.Insutype
  6780. two.PsnType = team.PsnType
  6781. two.MedType = team.MedType
  6782. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  6783. two.InsuAdmdvs = team.InsuAdmdvs
  6784. two.PsnTime = team.PsnTime
  6785. two.PsnCnt = team.PsnCnt
  6786. two.FundKey = team.FundKey
  6787. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6788. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6789. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6790. two.MedfeeSumAmt = ms
  6791. two.InscpAmt = ia
  6792. two.FundPaySumAmt = fps
  6793. twos = append(twos, two)
  6794. }
  6795. var upld_btch string
  6796. upld_btch = "0"
  6797. var empty models.JSResultEmpty
  6798. data := make(map[string]interface{})
  6799. data["org_name"] = miConfig.OrgName
  6800. data["doctor"] = curRoles.UserName
  6801. data["doctor_name"] = curRoles.UserName
  6802. data["fixmedins_code"] = miConfig.Code
  6803. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6804. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6805. data["secret_key"] = miConfig.SecretKey
  6806. data["url"] = miConfig.Url
  6807. data["ak"] = miConfig.AccessKey
  6808. data["cainfo"] = miConfig.Cainfo
  6809. data["datas"] = twos
  6810. data["fund"] = funInfos
  6811. data["setl_mon"] = setl_mon
  6812. month := time.Unix(1557042972, 0).Format("1")
  6813. year := time.Now().Format("2006")
  6814. month = time.Now().Format("01")
  6815. day := time.Now().Format("02")
  6816. hour := time.Now().Format("15")
  6817. min := time.Now().Format("04")
  6818. sec := time.Now().Format("05")
  6819. fix_fill_date := year + month + day + hour + min + sec
  6820. data["fix_fill_dept"] = miConfig.OrgName
  6821. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6822. data["fix_fill_psn"] = curRoles.UserName
  6823. data["fix_fill_date"] = fix_fill_date
  6824. data["stmt_loc"] = "2"
  6825. data["upld_btch"] = upld_btch
  6826. client := &http.Client{}
  6827. bytesData, _ := json.Marshal(data)
  6828. var req *http.Request
  6829. if miConfig.MdtrtareaAdmvs == "320921" {
  6830. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6831. } else {
  6832. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6833. }
  6834. resp, _ := client.Do(req)
  6835. defer resp.Body.Close()
  6836. body, ioErr := ioutil.ReadAll(resp.Body)
  6837. if ioErr != nil {
  6838. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6840. }
  6841. var respJSON map[string]interface{}
  6842. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6843. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6845. }
  6846. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6847. fmt.Println(respJSON)
  6848. result, _ := json.Marshal(respJSON)
  6849. fmt.Println(result)
  6850. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6851. utils.ErrorLog("解析失败:%v", err)
  6852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6853. }
  6854. if empty.Infcode != "0" {
  6855. c.ServeSuccessJSON(map[string]interface{}{
  6856. "failed_code": -10,
  6857. "msg": empty.ErrMsg,
  6858. })
  6859. return
  6860. } else {
  6861. c.ServeSuccessJSON(map[string]interface{}{
  6862. "msg": "上传成功",
  6863. })
  6864. return
  6865. }
  6866. }
  6867. func (c *HisApiController) Get3269() {
  6868. admin_user_id, _ := c.GetInt64("admin_user_id")
  6869. startTime := c.GetString("start_time")
  6870. //endTime, _ := c.GetString("end_time")
  6871. times := strings.Split(startTime, "-")
  6872. setl_mon := times[0] + times[1]
  6873. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6874. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6875. var result3263 models.JSResult3263
  6876. data := make(map[string]interface{})
  6877. data["org_name"] = miConfig.OrgName
  6878. data["doctor"] = curRoles.UserName
  6879. data["doctor_name"] = curRoles.UserName
  6880. data["fixmedins_code"] = miConfig.Code
  6881. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6882. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6883. data["secret_key"] = miConfig.SecretKey
  6884. data["url"] = miConfig.Url
  6885. data["ak"] = miConfig.AccessKey
  6886. data["cainfo"] = miConfig.Cainfo
  6887. data["setl_mon"] = setl_mon
  6888. data["stmt_loc"] = "2"
  6889. client := &http.Client{}
  6890. bytesData, _ := json.Marshal(data)
  6891. var req *http.Request
  6892. if miConfig.MdtrtareaAdmvs == "320921" {
  6893. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6894. } else {
  6895. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6896. }
  6897. resp, _ := client.Do(req)
  6898. defer resp.Body.Close()
  6899. body, ioErr := ioutil.ReadAll(resp.Body)
  6900. if ioErr != nil {
  6901. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6903. }
  6904. var respJSON map[string]interface{}
  6905. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6906. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6908. }
  6909. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6910. fmt.Println(respJSON)
  6911. result, _ := json.Marshal(respJSON)
  6912. fmt.Println(result)
  6913. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6914. utils.ErrorLog("解析失败:%v", err)
  6915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6916. }
  6917. if result3263.Infcode != "0" {
  6918. c.ServeSuccessJSON(map[string]interface{}{
  6919. "failed_code": -10,
  6920. "msg": result3263.ErrMsg,
  6921. })
  6922. return
  6923. } else {
  6924. c.ServeSuccessJSON(map[string]interface{}{
  6925. "msg": "上传成功",
  6926. })
  6927. return
  6928. }
  6929. }
  6930. func (c *HisApiController) Get3270() {
  6931. admin_user_id, _ := c.GetInt64("admin_user_id")
  6932. startTime := c.GetString("start_time")
  6933. //endTime, _ := c.GetString("end_time")
  6934. times := strings.Split(startTime, "-")
  6935. setl_mon := times[0] + times[1]
  6936. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6937. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6938. var result3263 models.JSResult3263
  6939. data2 := make(map[string]interface{})
  6940. data2["org_name"] = miConfig.OrgName
  6941. data2["doctor"] = curRoles.UserName
  6942. data2["doctor_name"] = curRoles.UserName
  6943. data2["fixmedins_code"] = miConfig.Code
  6944. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6945. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6946. data2["secret_key"] = miConfig.SecretKey
  6947. data2["url"] = miConfig.Url
  6948. data2["ak"] = miConfig.AccessKey
  6949. data2["cainfo"] = miConfig.Cainfo
  6950. data2["setl_mon"] = setl_mon
  6951. data2["stmt_loc"] = "2"
  6952. client2 := &http.Client{}
  6953. bytesData2, _ := json.Marshal(data2)
  6954. var req3263 *http.Request
  6955. if miConfig.MdtrtareaAdmvs == "320921" {
  6956. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6957. } else {
  6958. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6959. }
  6960. resp2, _ := client2.Do(req3263)
  6961. defer resp2.Body.Close()
  6962. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6963. if ioErr2 != nil {
  6964. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6966. }
  6967. var respJSON3263 map[string]interface{}
  6968. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6969. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6971. }
  6972. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6973. fmt.Println(respJSON3263)
  6974. result2, _ := json.Marshal(respJSON3263)
  6975. fmt.Println(result2)
  6976. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6977. utils.ErrorLog("解析失败:%v", err)
  6978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6979. }
  6980. var ids []string
  6981. for _, item := range result3263.Output {
  6982. ids = append(ids, item.SolidifyID)
  6983. }
  6984. var result3264 models.JSResult3264
  6985. data := make(map[string]interface{})
  6986. data["org_name"] = miConfig.OrgName
  6987. data["doctor"] = curRoles.UserName
  6988. data["doctor_name"] = curRoles.UserName
  6989. data["fixmedins_code"] = miConfig.Code
  6990. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6991. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6992. data["secret_key"] = miConfig.SecretKey
  6993. data["url"] = miConfig.Url
  6994. data["ak"] = miConfig.AccessKey
  6995. data["cainfo"] = miConfig.Cainfo
  6996. data["setl_mon"] = setl_mon
  6997. data["stmt_loc"] = "2"
  6998. data["solidify_id"] = ids
  6999. client := &http.Client{}
  7000. bytesData, _ := json.Marshal(data)
  7001. var req *http.Request
  7002. if miConfig.MdtrtareaAdmvs == "320921" {
  7003. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7004. } else {
  7005. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7006. }
  7007. resp, _ := client.Do(req)
  7008. defer resp.Body.Close()
  7009. body, ioErr := ioutil.ReadAll(resp.Body)
  7010. if ioErr != nil {
  7011. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7013. }
  7014. var respJSON map[string]interface{}
  7015. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7016. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7018. }
  7019. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7020. fmt.Println(respJSON)
  7021. result, _ := json.Marshal(respJSON)
  7022. fmt.Println(result)
  7023. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  7024. utils.ErrorLog("解析失败:%v", err)
  7025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7026. }
  7027. if result3264.Infcode != "0" {
  7028. c.ServeSuccessJSON(map[string]interface{}{
  7029. "failed_code": -10,
  7030. "msg": result3264.ErrMsg,
  7031. })
  7032. return
  7033. } else {
  7034. c.ServeSuccessJSON(map[string]interface{}{
  7035. "info": result3264.Output,
  7036. })
  7037. return
  7038. }
  7039. }
  7040. func (c *HisApiController) Get3271() {
  7041. admin_user_id, _ := c.GetInt64("admin_user_id")
  7042. startTime := c.GetString("start_time")
  7043. //endTime, _ := c.GetString("end_time")
  7044. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7045. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7046. times := strings.Split(startTime, "-")
  7047. setl_mon := times[0] + times[1]
  7048. //var empty models.JSResultEmpty
  7049. var result3265 models.JSResult3264
  7050. var result3263 models.JSResult3263
  7051. data2 := make(map[string]interface{})
  7052. data2["org_name"] = miConfig.OrgName
  7053. data2["doctor"] = curRoles.UserName
  7054. data2["doctor_name"] = curRoles.UserName
  7055. data2["fixmedins_code"] = miConfig.Code
  7056. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7057. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7058. data2["secret_key"] = miConfig.SecretKey
  7059. data2["url"] = miConfig.Url
  7060. data2["ak"] = miConfig.AccessKey
  7061. data2["cainfo"] = miConfig.Cainfo
  7062. data2["setl_mon"] = setl_mon
  7063. data2["stmt_loc"] = "2"
  7064. client2 := &http.Client{}
  7065. bytesData2, _ := json.Marshal(data2)
  7066. var req3263 *http.Request
  7067. if miConfig.MdtrtareaAdmvs == "320921" {
  7068. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7069. } else {
  7070. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7071. }
  7072. resp2, _ := client2.Do(req3263)
  7073. defer resp2.Body.Close()
  7074. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7075. if ioErr2 != nil {
  7076. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7078. }
  7079. var respJSON3263 map[string]interface{}
  7080. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7081. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7083. }
  7084. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7085. fmt.Println(respJSON3263)
  7086. result2, _ := json.Marshal(respJSON3263)
  7087. fmt.Println(result2)
  7088. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7089. utils.ErrorLog("解析失败:%v", err)
  7090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7091. }
  7092. var ids []string
  7093. for _, item := range result3263.Output {
  7094. ids = append(ids, item.SolidifyID)
  7095. }
  7096. data := make(map[string]interface{})
  7097. data["org_name"] = miConfig.OrgName
  7098. data["doctor"] = curRoles.UserName
  7099. data["doctor_name"] = curRoles.UserName
  7100. data["fixmedins_code"] = miConfig.Code
  7101. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7102. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7103. data["secret_key"] = miConfig.SecretKey
  7104. data["url"] = miConfig.Url
  7105. data["ak"] = miConfig.AccessKey
  7106. data["cainfo"] = miConfig.Cainfo
  7107. data["setl_mon"] = setl_mon
  7108. data["solidify_id"] = ids
  7109. month := time.Unix(1557042972, 0).Format("1")
  7110. year := time.Now().Format("2006")
  7111. month = time.Now().Format("01")
  7112. day := time.Now().Format("02")
  7113. hour := time.Now().Format("15")
  7114. min := time.Now().Format("04")
  7115. sec := time.Now().Format("05")
  7116. fix_fill_date := year + month + day + hour + min + sec
  7117. data["fix_fill_dept"] = miConfig.OrgName
  7118. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7119. data["fix_fill_psn"] = curRoles.UserName
  7120. data["fix_fill_date"] = fix_fill_date
  7121. data["stmt_loc"] = "2"
  7122. client := &http.Client{}
  7123. bytesData, _ := json.Marshal(data)
  7124. var req *http.Request
  7125. if miConfig.MdtrtareaAdmvs == "320921" {
  7126. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7127. } else {
  7128. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7129. }
  7130. resp, _ := client.Do(req)
  7131. defer resp.Body.Close()
  7132. body, ioErr := ioutil.ReadAll(resp.Body)
  7133. if ioErr != nil {
  7134. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7136. }
  7137. var respJSON map[string]interface{}
  7138. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7139. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7141. }
  7142. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7143. fmt.Println(respJSON)
  7144. result, _ := json.Marshal(respJSON)
  7145. fmt.Println(result)
  7146. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7147. utils.ErrorLog("解析失败:%v", err)
  7148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7149. }
  7150. if result3265.Infcode != "0" {
  7151. c.ServeSuccessJSON(map[string]interface{}{
  7152. "failed_code": -10,
  7153. "msg": result3265.ErrMsg,
  7154. })
  7155. return
  7156. } else {
  7157. c.ServeSuccessJSON(map[string]interface{}{
  7158. "info": result3265.Output.Data,
  7159. })
  7160. return
  7161. }
  7162. }
  7163. func (c *HisApiController) Get3272() {
  7164. admin_user_id, _ := c.GetInt64("admin_user_id")
  7165. startTime := c.GetString("start_time")
  7166. //endTime, _ := c.GetString("end_time")
  7167. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7168. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7169. times := strings.Split(startTime, "-")
  7170. setl_mon := times[0] + times[1]
  7171. var upld_btch string
  7172. //var empty models.JSResultEmpty
  7173. var result3265 models.JSResult3264
  7174. data := make(map[string]interface{})
  7175. data["org_name"] = miConfig.OrgName
  7176. data["doctor"] = curRoles.UserName
  7177. data["doctor_name"] = curRoles.UserName
  7178. data["fixmedins_code"] = miConfig.Code
  7179. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7180. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7181. data["secret_key"] = miConfig.SecretKey
  7182. data["url"] = miConfig.Url
  7183. data["ak"] = miConfig.AccessKey
  7184. data["cainfo"] = miConfig.Cainfo
  7185. data["setl_mon"] = setl_mon
  7186. month := time.Unix(1557042972, 0).Format("1")
  7187. year := time.Now().Format("2006")
  7188. month = time.Now().Format("01")
  7189. day := time.Now().Format("02")
  7190. hour := time.Now().Format("15")
  7191. min := time.Now().Format("04")
  7192. sec := time.Now().Format("05")
  7193. fix_fill_date := year + month + day + hour + min + sec
  7194. data["fix_fill_dept"] = miConfig.OrgName
  7195. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7196. data["fix_fill_psn"] = curRoles.UserName
  7197. data["fix_fill_date"] = fix_fill_date
  7198. data["stmt_loc"] = "2"
  7199. data["upld_btch"] = upld_btch
  7200. client := &http.Client{}
  7201. bytesData, _ := json.Marshal(data)
  7202. var req *http.Request
  7203. if miConfig.MdtrtareaAdmvs == "320921" {
  7204. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7205. } else {
  7206. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7207. }
  7208. resp, _ := client.Do(req)
  7209. defer resp.Body.Close()
  7210. body, ioErr := ioutil.ReadAll(resp.Body)
  7211. if ioErr != nil {
  7212. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7214. }
  7215. var respJSON map[string]interface{}
  7216. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7217. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7219. }
  7220. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7221. fmt.Println(respJSON)
  7222. result, _ := json.Marshal(respJSON)
  7223. fmt.Println(result)
  7224. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7225. utils.ErrorLog("解析失败:%v", err)
  7226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7227. }
  7228. if result3265.Infcode != "0" {
  7229. c.ServeSuccessJSON(map[string]interface{}{
  7230. "failed_code": -10,
  7231. "msg": result3265.ErrMsg,
  7232. })
  7233. return
  7234. } else {
  7235. c.ServeSuccessJSON(map[string]interface{}{
  7236. "info": result3265.Output,
  7237. })
  7238. return
  7239. }
  7240. }
  7241. func (c *HisApiController) Get3273() {
  7242. admin_user_id, _ := c.GetInt64("admin_user_id")
  7243. startTime := c.GetString("start_time")
  7244. //endTime, _ := c.GetString("end_time")
  7245. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7246. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7247. times := strings.Split(startTime, "-")
  7248. setl_mon := times[0] + times[1]
  7249. var result3265 models.JSResult3264
  7250. data := make(map[string]interface{})
  7251. data["org_name"] = miConfig.OrgName
  7252. data["doctor"] = curRoles.UserName
  7253. data["doctor_name"] = curRoles.UserName
  7254. data["fixmedins_code"] = miConfig.Code
  7255. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7256. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7257. data["secret_key"] = miConfig.SecretKey
  7258. data["url"] = miConfig.Url
  7259. data["ak"] = miConfig.AccessKey
  7260. data["cainfo"] = miConfig.Cainfo
  7261. data["setl_mon"] = setl_mon
  7262. data["stmt_loc"] = "2"
  7263. client := &http.Client{}
  7264. bytesData, _ := json.Marshal(data)
  7265. var req *http.Request
  7266. if miConfig.MdtrtareaAdmvs == "320921" {
  7267. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7268. } else {
  7269. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7270. }
  7271. resp, _ := client.Do(req)
  7272. defer resp.Body.Close()
  7273. body, ioErr := ioutil.ReadAll(resp.Body)
  7274. if ioErr != nil {
  7275. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7277. }
  7278. var respJSON map[string]interface{}
  7279. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7280. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7282. }
  7283. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7284. fmt.Println(respJSON)
  7285. result, _ := json.Marshal(respJSON)
  7286. fmt.Println(result)
  7287. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7288. utils.ErrorLog("解析失败:%v", err)
  7289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7290. }
  7291. if result3265.Infcode != "0" {
  7292. c.ServeSuccessJSON(map[string]interface{}{
  7293. "failed_code": -10,
  7294. "msg": result3265.ErrMsg,
  7295. })
  7296. return
  7297. } else {
  7298. c.ServeSuccessJSON(map[string]interface{}{
  7299. "info": result3265.Output.Data,
  7300. })
  7301. return
  7302. }
  7303. }
  7304. func (c *HisApiController) Get3274() {
  7305. //if miConfig.MdtrtareaAdmvs == "320921" {
  7306. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7307. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7308. // "&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
  7309. //
  7310. //} else {
  7311. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7312. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7313. // "&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
  7314. //
  7315. //}
  7316. }
  7317. func (c *HisApiController) Get3275() {
  7318. //if miConfig.MdtrtareaAdmvs == "320921" {
  7319. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7320. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7321. // "&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
  7322. //
  7323. //} else {
  7324. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7325. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7326. // "&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
  7327. //
  7328. //}
  7329. }
  7330. func (c *HisApiController) Get3276() {
  7331. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7332. //month := c.GetString("month")
  7333. //
  7334. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7335. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7336. //var api string
  7337. //var res Result5301
  7338. //
  7339. //if miConfig.MdtrtareaAdmvs == "320921" {
  7340. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7341. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7342. //} else {
  7343. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7344. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7345. //}
  7346. //
  7347. //resp, requestErr := http.Get(api)
  7348. //if requestErr != nil {
  7349. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7350. // return
  7351. //}
  7352. //
  7353. //body, ioErr := ioutil.ReadAll(resp.Body)
  7354. //if ioErr != nil {
  7355. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7356. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7357. // return
  7358. //}
  7359. //var respJSON map[string]interface{}
  7360. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7361. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7362. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7363. // return
  7364. //}
  7365. //
  7366. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7367. //result, _ := json.Marshal(respJSON)
  7368. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7369. // utils.ErrorLog("解析失败:%v", err)
  7370. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7371. // return
  7372. //}
  7373. }
  7374. func (c *HisApiController) Get3277() {
  7375. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7376. //month := c.GetString("month")
  7377. //
  7378. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7379. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7380. //var api string
  7381. //var res Result5301
  7382. //
  7383. //if miConfig.MdtrtareaAdmvs == "320921" {
  7384. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7385. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7386. //} else {
  7387. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7388. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7389. //}
  7390. //
  7391. //resp, requestErr := http.Get(api)
  7392. //if requestErr != nil {
  7393. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7394. // return
  7395. //}
  7396. //
  7397. //body, ioErr := ioutil.ReadAll(resp.Body)
  7398. //if ioErr != nil {
  7399. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7400. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7401. // return
  7402. //}
  7403. //var respJSON map[string]interface{}
  7404. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7405. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7406. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7407. // return
  7408. //}
  7409. //
  7410. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7411. //result, _ := json.Marshal(respJSON)
  7412. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7413. // utils.ErrorLog("解析失败:%v", err)
  7414. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7415. // return
  7416. //}
  7417. }
  7418. //func (c *HisApiController) GetCFYLJG001() {
  7419. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7420. // patient_id, _ := c.GetInt64("patient_id")
  7421. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7422. // record_time := c.GetString("record_time")
  7423. // admin_user_id = 3626
  7424. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7425. // psn, _ := service.GetPsnByPatientId(patient_id)
  7426. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7427. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7428. // var cFYLJG001 models.CFYLJG001
  7429. //
  7430. // timeLayout := "2006-01-02"
  7431. // loc, _ := time.LoadLocation("Local")
  7432. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7433. // if err != nil {
  7434. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7435. // return
  7436. // }
  7437. // recordDateTime := theTime.Unix()
  7438. // prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7439. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7440. //
  7441. // //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7442. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7443. //
  7444. // //dept, _ := service.GetDepartMentDetail(info.Departments)
  7445. //
  7446. // for _, item := range prescriptions {
  7447. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7448. // if his.IdCardType == 1 {
  7449. // bas := strings.Split(psn.CardInfo, "|")
  7450. // basNumber := bas[1]
  7451. // fmt.Println(basNumber)
  7452. // card_sn := bas[3]
  7453. // card_no := bas[2]
  7454. // cFYLJG001.MdtrtCertType = "03"
  7455. // cFYLJG001.CardSn = card_sn
  7456. // cFYLJG001.MdtrtCertNo = card_no
  7457. // cFYLJG001.EcToken = ""
  7458. // cFYLJG001.AuthNo = ""
  7459. // } else if his.IdCardType == 2 {
  7460. // cFYLJG001.MdtrtCertType = "02"
  7461. // cFYLJG001.CardSn = ""
  7462. // cFYLJG001.MdtrtCertNo = his.IdCardNo
  7463. // cFYLJG001.EcToken = ""
  7464. // cFYLJG001.AuthNo = ""
  7465. // } else if his.IdCardType == 4 {
  7466. // cFYLJG001.MdtrtCertType = "01"
  7467. // cFYLJG001.CardSn = ""
  7468. // cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7469. // cFYLJG001.EcToken = psn.VerifyNumber
  7470. // cFYLJG001.AuthNo = ""
  7471. // }
  7472. // cFYLJG001.BizTypeCode = "01"
  7473. // cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7474. // cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7475. // cFYLJG001.RxTypeCode = "1"
  7476. // tempTime := time.Unix(item.PreTime, 0)
  7477. // timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7478. // cFYLJG001.PrscTime = timeFormatOne
  7479. // var count float64
  7480. // if item.Type == 1 {
  7481. // for _, sumItem := range item.HisDoctorAdviceInfo {
  7482. // count = count + sumItem.PrescribingNumber
  7483. // }
  7484. // }
  7485. // cFYLJG001.RxDrugCnt = count
  7486. // cFYLJG001.ValiDays = "5"
  7487. // ts := time.Unix(item.PreTime, 0)
  7488. // record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  7489. // tempTime3 := time.Unix(record_time2, 0)
  7490. // timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7491. // cFYLJG001.ValiEndTime = timeFormat3
  7492. // cFYLJG001.RxCotnFlag = "0"
  7493. // for _, subItem := range item.HisDoctorAdviceInfo {
  7494. // var drug models.RxDrug
  7495. // drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7496. // drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7497. // drug.RxItemTypeCode = "11"
  7498. //
  7499. // drug.DrugDosform = "乳膏剂" //TODO
  7500. // if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7501. // drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7502. // }
  7503. //
  7504. // drug.MedcWayDscr = subItem.DeliveryWay
  7505. //
  7506. // tempTime2 := time.Unix(subItem.StartTime, 0)
  7507. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7508. // drug.MedcBegntime = timeFormatTwo
  7509. // if subItem.Day > 0 {
  7510. // ts := time.Unix(subItem.StartTime, 0)
  7511. // record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7512. // tempTime4 := time.Unix(record_time, 0)
  7513. // timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7514. // drug.MedcEndtime = timeFormat5
  7515. // } else {
  7516. // tempTime2 := time.Unix(subItem.StartTime, 0)
  7517. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7518. // drug.MedcEndtime = timeFormatTwo
  7519. // }
  7520. //
  7521. // drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7522. // drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7523. // drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7524. // drug.DrugCnt = subItem.PrescribingNumber
  7525. // drug.DrugDosunt = subItem.PrescribingNumberUnit
  7526. // drug.DrugGenname = subItem.AdviceName
  7527. // drug.MedcWayCodg = subItem.DeliveryWay
  7528. // //drug.DrugTotlcnt = subItem.PrescribingNumber
  7529. // drug.SinDoscnt = subItem.SingleDose
  7530. // drug.SinDosunt = subItem.SingleDoseUnit
  7531. // drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7532. // drug.UsedFrquName = subItem.ExecutionFrequency
  7533. // drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7534. // drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7535. // drug.HospApprFlag = "1"
  7536. // cFYLJG001.List = append(cFYLJG001.List, drug)
  7537. // }
  7538. // cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7539. // cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  7540. // cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7541. // cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7542. // cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7543. // cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7544. // cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7545. // cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7546. // cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7547. // cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7548. // cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7549. // cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7550. // cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7551. // cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7552. // cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7553. // cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7554. // cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7555. // cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7556. // cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7557. // cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7558. // cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7559. // cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7560. // cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7561. // cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7562. // tempTime2 := time.Now().Unix()
  7563. // tempTime6 := time.Unix(tempTime2, 0)
  7564. // timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7565. // cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7566. // cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  7567. // cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7568. // cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  7569. // cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  7570. //
  7571. // //memo := make(map[string]interface{})
  7572. // //inputData := make(map[string]interface{}, 0)
  7573. //
  7574. // //type MyData struct {
  7575. // // Insutype string `json:"insutype"`
  7576. // //}
  7577. // //
  7578. // // data := MyData{
  7579. // // Insutype: his.Insutype,
  7580. // //}
  7581. // //
  7582. //
  7583. // diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7584. // var config []*models.HisXtDiagnoseConfig
  7585. // for _, item := range diagnosis_ids {
  7586. // id, _ := strconv.ParseInt(item, 10, 64)
  7587. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  7588. // config = append(config, &diagnosisConfig)
  7589. // }
  7590. // for index, subitem := range config {
  7591. // if index == 0 {
  7592. // var dia models.DiseInfo
  7593. // dia.DiagType = "1"
  7594. // dia.MaindiagFlag = "1"
  7595. // dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7596. // dia.DiagCode = subitem.CountryCode
  7597. // dia.DiagName = subitem.ClassName
  7598. // dia.DiagDept = "肾内科"
  7599. // dia.DiagDrNo = doctor.DoctorNumber
  7600. // dia.DiagDrName = doctor.UserName
  7601. // tempTime3 := time.Unix(item.PreTime, 0)
  7602. // timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7603. // dia.DiagTime = timeFormatTwo
  7604. // cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7605. // } else {
  7606. // var dia models.DiseInfo
  7607. // dia.DiagType = "1"
  7608. // dia.MaindiagFlag = "0"
  7609. // dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7610. // dia.DiagCode = subitem.CountryCode
  7611. // dia.DiagName = subitem.ClassName
  7612. // dia.DiagDept = "肾内科"
  7613. // dia.DiagDrNo = doctor.DoctorNumber
  7614. // dia.DiagDrName = doctor.UserName
  7615. // tempTime3 := time.Unix(item.PreTime, 0)
  7616. // timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7617. // dia.DiagTime = timeFormatTwo
  7618. // cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7619. // }
  7620. // }
  7621. // if miConfig.MdtrtareaAdmvs == "340699" {
  7622. // //result, request := service.GetAHCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7623. // //saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7624. //
  7625. // } else {
  7626. // result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7627. // saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7628. //
  7629. // }
  7630. //
  7631. // var res ResultCFYLJG001
  7632. // var respJSON2 map[string]interface{}
  7633. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7634. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7635. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7636. // return
  7637. // }
  7638. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7639. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7640. // utils.ErrorLog("解析失败:%v", err)
  7641. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7642. // return
  7643. // }
  7644. // if res.Infcode == -1 {
  7645. // c.ServeSuccessJSON(map[string]interface{}{
  7646. // "failed_code": -10,
  7647. // "msg": res.ErrMsg,
  7648. // })
  7649. // return
  7650. //
  7651. // } else {
  7652. // var flow models.HisPrescriptionFlow
  7653. // flow.Ctime = time.Now().Unix()
  7654. // flow.SignDigest = ""
  7655. // flow.RxTraceCode = res.Output.RxTraceCode
  7656. // flow.HiRxno = res.Output.HiRxno
  7657. // flow.MID = his.Number
  7658. // flow.Status = 1
  7659. // flow.DCode = doctor_info.DoctorNumber
  7660. // flow.OriginalRxFile = ""
  7661. // flow.OriginalValue = ""
  7662. // flow.SignCertDn = ""
  7663. // flow.UserOrgId = 10454
  7664. // flow.SignCertSn = ""
  7665. // flow.Mtime = time.Now().Unix()
  7666. //
  7667. // service.Createflow(&flow)
  7668. // c.ServeSuccessJSON(map[string]interface{}{
  7669. // "msg": "上传成功",
  7670. // })
  7671. // }
  7672. // }
  7673. //}
  7674. //func (c *HisApiController) GetCFYLJG002() {
  7675. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7676. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7677. // record_time := c.GetString("record_time")
  7678. // admin_user_id = 3626
  7679. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7680. // //id, _ := c.GetInt64("id")
  7681. // admin_user_id = 3626
  7682. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7683. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7684. //
  7685. // flow, _ := service.Getflowtwo(his.Number)
  7686. // //his, _ := service.GetHisPatientByNumber(flow.MID)
  7687. // //record_time := c.GetString("record_time")
  7688. // patient_id, _ := c.GetInt64("patient_id")
  7689. // //patient_id = 23834
  7690. // //record_time = "2023-09-18"
  7691. // timeLayout := "2006-01-02"
  7692. // loc, _ := time.LoadLocation("Local")
  7693. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7694. // if err != nil {
  7695. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7696. // return
  7697. // }
  7698. // recordDateTime := theTime.Unix()
  7699. // //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7700. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7701. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7702. //
  7703. // dept, _ := service.GetDepartMentDetail(info.Departments)
  7704. //
  7705. // inputData := make(map[string]interface{})
  7706. // inputData["rxTraceCode"] = flow.RxTraceCode
  7707. // inputData["hiRxno"] = flow.HiRxno
  7708. // inputData["mdtrtId"] = flow.MID
  7709. // inputData["patnName"] = his.PsnName
  7710. // inputData["psnCertType"] = his.PsnCertType
  7711. // inputData["certno"] = his.Certno
  7712. // inputData["fixmedinsName"] = miConfig.OrgName
  7713. // inputData["fixmedinsCode"] = miConfig.Code
  7714. // inputData["drCode"] = doctor_info.DoctorNumber
  7715. // inputData["prscDrName"] = doctor_info.UserName
  7716. // inputData["pharDeptName"] = dept.Name
  7717. // inputData["pharDeptCode"] = dept.Number
  7718. // inputData["pharProfttlCodg"] = dept.Name
  7719. // inputData["pharProfttlName"] = ""
  7720. // inputData["pharCode"] = "HY440309002107"
  7721. // inputData["pharCertType"] = "01"
  7722. // inputData["pharCertno"] = "430482199408260023"
  7723. // inputData["pharName"] = "彭斯遥"
  7724. // inputData["pharPracCertNo"] = ""
  7725. // tempTime2 := time.Unix(info.Ctime, 0)
  7726. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7727. // inputData["pharChkTime"] = timeFormatTwo
  7728. //
  7729. // bytesData, _ := json.Marshal(inputData)
  7730. // fmt.Println(string(bytesData))
  7731. // encoded := base64.StdEncoding.EncodeToString(bytesData)
  7732. // pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  7733. // if err != nil {
  7734. // fmt.Println("Error reading PDF file:", err)
  7735. // return
  7736. // }
  7737. //
  7738. // // 将 PDF 文件内容进行 Base64 编码
  7739. // rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  7740. //
  7741. // fmt.Println(err)
  7742. //
  7743. // if miConfig.MdtrtareaAdmvs == "340699" {
  7744. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7745. // //saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7746. //
  7747. // } else {
  7748. // result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7749. // //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  7750. // saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7751. //
  7752. // }
  7753. //
  7754. // var res2 Result002
  7755. // var respJSON2 map[string]interface{}
  7756. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7757. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7758. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7759. // return
  7760. // }
  7761. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7762. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7763. // utils.ErrorLog("解析失败:%v", err)
  7764. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7765. // return
  7766. // }
  7767. // if res2.Infcode == 0 {
  7768. // flow.Ctime = time.Now().Unix()
  7769. // flow.SignDigest = res2.Output.SignDigest
  7770. // flow.RxFile = res2.Output.RxFile
  7771. // flow.MID = his.Number
  7772. // flow.Status = 1
  7773. // flow.DCode = doctor_info.DoctorNumber
  7774. // flow.OriginalRxFile = rx_encoded
  7775. // flow.OriginalValue = encoded
  7776. // flow.SignCertDn = res2.Output.SignCertDn
  7777. // flow.SignCertSn = res2.Output.SignCertSn
  7778. // flow.Mtime = time.Now().Unix()
  7779. // service.Saveflow(flow)
  7780. // c.ServeSuccessJSON(map[string]interface{}{
  7781. // "msg": "预签名成功",
  7782. // })
  7783. // } else {
  7784. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7785. // return
  7786. // }
  7787. //}
  7788. //func (c *HisApiController) GetCFYLJG003() {
  7789. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7790. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7791. // record_time := c.GetString("record_time")
  7792. // admin_user_id = 3626
  7793. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7794. // //id, _ := c.GetInt64("id")
  7795. // admin_user_id = 3626
  7796. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7797. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7798. //
  7799. // flow, _ := service.Getflowtwo(his.Number)
  7800. // //id = 3
  7801. // patient_id, _ := c.GetInt64("patient_id")
  7802. // //patient_id = 23834
  7803. // //record_time = "2023-09-18"
  7804. // timeLayout := "2006-01-02"
  7805. // loc, _ := time.LoadLocation("Local")
  7806. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7807. // if err != nil {
  7808. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7809. // return
  7810. // }
  7811. // recordDateTime := theTime.Unix()
  7812. // //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7813. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7814. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7815. // dept, _ := service.GetDepartMentDetail(info.Departments)
  7816. //
  7817. // //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  7818. //
  7819. // var cFYLJG003 models.CFYLJG003
  7820. //
  7821. // cFYLJG003.RxTraceCode = flow.RxTraceCode
  7822. // cFYLJG003.HiRxno = flow.HiRxno
  7823. // cFYLJG003.MdtrtID = flow.MID
  7824. // cFYLJG003.PatnName = his.Name
  7825. // cFYLJG003.Certno = his.Certno
  7826. // cFYLJG003.FixmedinsName = miConfig.OrgName
  7827. // cFYLJG003.FixmedinsCode = miConfig.Code
  7828. //
  7829. // cFYLJG003.DrCode = doctor_info.DoctorNumber
  7830. // cFYLJG003.PrscDrName = doctor_info.UserName
  7831. // cFYLJG003.PharDeptName = dept.Name
  7832. // cFYLJG003.PharDeptCode = dept.Number
  7833. // cFYLJG003.PharCode = "HY440309002107"
  7834. // cFYLJG003.PharCertType = "01"
  7835. // cFYLJG003.PharCertno = "430482199408260023"
  7836. // cFYLJG003.PharName = "彭斯遥"
  7837. // cFYLJG003.PsnCertType = "01"
  7838. // cFYLJG003.RxFile = flow.RxFile
  7839. // cFYLJG003.SignDigest = flow.SignDigest
  7840. // cFYLJG003.FixmedinsCode = miConfig.Code
  7841. // cFYLJG003.PsnCertType = "01"
  7842. // cFYLJG003.PharProfttlCodg = dept.Name
  7843. // //inputData["pharProfttlCodg"] =dept.Name
  7844. //
  7845. // tempTime2 := time.Unix(info.Ctime, 0)
  7846. // timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7847. // cFYLJG003.PharChkTime = timeFormatTwo
  7848. //
  7849. // if miConfig.MdtrtareaAdmvs == "340699" {
  7850. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7851. // //result, request := service.GetAHCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7852. // //saveLog(result, request, "GetAHCFYLJG003", "GetAHCFYLJG003")
  7853. // } else {
  7854. // result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7855. // saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  7856. //
  7857. // }
  7858. //
  7859. // var res ResultCFYLJG003
  7860. // var respJSON2 map[string]interface{}
  7861. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7862. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7863. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7864. // return
  7865. // }
  7866. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7867. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7868. // utils.ErrorLog("解析失败:%v", err)
  7869. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7870. // return
  7871. // }
  7872. // if res.Infcode == -1 {
  7873. // c.ServeSuccessJSON(map[string]interface{}{
  7874. // "failed_code": -10,
  7875. // "msg": res.ErrMsg,
  7876. // })
  7877. // return
  7878. // } else {
  7879. // c.ServeSuccessJSON(map[string]interface{}{
  7880. // "info": res.Output,
  7881. // })
  7882. // }
  7883. //
  7884. //}
  7885. //func (c *HisApiController) GetCFYLJG004() {
  7886. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7887. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7888. // record_time := c.GetString("record_time")
  7889. // admin_user_id = 3626
  7890. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7891. // //id, _ := c.GetInt64("id")
  7892. // admin_user_id = 3626
  7893. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7894. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7895. //
  7896. // flow, _ := service.Getflowtwo(his.Number)
  7897. // //id = 3
  7898. // patient_id, _ := c.GetInt64("patient_id")
  7899. // //patient_id = 23834
  7900. // //record_time = "2023-09-18"
  7901. // timeLayout := "2006-01-02"
  7902. // loc, _ := time.LoadLocation("Local")
  7903. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7904. // if err != nil {
  7905. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7906. // return
  7907. // }
  7908. // recordDateTime := theTime.Unix()
  7909. // info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7910. // doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7911. // var cFYLJG004 models.CFYLJG004
  7912. // cFYLJG004.HiRxno = flow.HiRxno
  7913. // cFYLJG004.FixmedinsCode = miConfig.Code
  7914. // cFYLJG004.UndoDrCertno = doctor_info.IdCard
  7915. // cFYLJG004.UndoDrCertType = "01"
  7916. // cFYLJG004.UndoRea = "撤销处方"
  7917. // cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  7918. // cFYLJG004.UndoDrName = doctor_info.UserName
  7919. // cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  7920. //
  7921. // if miConfig.MdtrtareaAdmvs == "340699" {
  7922. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7923. // //result, request := service.GetAHCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7924. // //saveLog(result, request, "GetAHCFYLJG004", "GetAHCFYLJG004")
  7925. //
  7926. // } else {
  7927. // result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  7928. // saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  7929. //
  7930. // }
  7931. //
  7932. // var res ResultCFYLJG004
  7933. // var respJSON2 map[string]interface{}
  7934. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7935. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7936. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7937. // return
  7938. // }
  7939. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7940. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7941. // utils.ErrorLog("解析失败:%v", err)
  7942. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7943. // return
  7944. // }
  7945. // if res.Infcode == -1 {
  7946. // c.ServeSuccessJSON(map[string]interface{}{
  7947. // "failed_code": -10,
  7948. // "msg": res.ErrMsg,
  7949. // })
  7950. // return
  7951. // } else {
  7952. // flow.Status = 0
  7953. // service.Saveflow(flow)
  7954. // c.ServeSuccessJSON(map[string]interface{}{
  7955. // "msg": "撤销成功",
  7956. // })
  7957. // return
  7958. //
  7959. // }
  7960. //}
  7961. //func (c *HisApiController) GetCFYLJG005() {
  7962. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7963. // his_patient_id, _ := c.GetInt64("his_patient_id")
  7964. // //record_time := c.GetString("record_time")
  7965. // admin_user_id = 3626
  7966. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7967. // //id, _ := c.GetInt64("id")
  7968. // admin_user_id = 3626
  7969. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7970. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7971. //
  7972. // flow, _ := service.Getflowtwo(his.Number)
  7973. // //id = 3
  7974. // var cFYLJG005 models.CFYLJG005
  7975. //
  7976. // //patient_id, _ := c.GetInt64("patient_id")
  7977. // cFYLJG005.HiRxno = flow.HiRxno
  7978. // cFYLJG005.MdtrtID = flow.MID
  7979. // cFYLJG005.EcToken = ""
  7980. // cFYLJG005.PsnName = his.Name
  7981. // cFYLJG005.PsnCertType = "01"
  7982. // cFYLJG005.Certno = his.IdCardNo
  7983. //
  7984. // if miConfig.MdtrtareaAdmvs == "340699" {
  7985. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7986. //
  7987. // //result, request := service.GetAHCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7988. // //saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7989. //
  7990. // } else {
  7991. // result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7992. // saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7993. //
  7994. // }
  7995. //
  7996. // var res ResultCFYLJG005
  7997. // var respJSON2 map[string]interface{}
  7998. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7999. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8000. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8001. // return
  8002. // }
  8003. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8004. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8005. // utils.ErrorLog("解析失败:%v", err)
  8006. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8007. // return
  8008. // }
  8009. // if res.Infcode == -1 {
  8010. // c.ServeSuccessJSON(map[string]interface{}{
  8011. // "failed_code": -10,
  8012. // "msg": res.ErrMsg,
  8013. // })
  8014. // return
  8015. // } else {
  8016. // c.ServeSuccessJSON(map[string]interface{}{
  8017. // "info": res.Output,
  8018. // })
  8019. // return
  8020. // }
  8021. //}
  8022. //func (c *HisApiController) GetCFYLJG006() {
  8023. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8024. // his_patient_id, _ := c.GetInt64("his_patient_id")
  8025. // admin_user_id = 3626
  8026. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8027. // //id, _ := c.GetInt64("id")
  8028. // admin_user_id = 3626
  8029. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8030. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8031. //
  8032. // flow, _ := service.Getflowtwo(his.Number)
  8033. // //id = 3
  8034. // patient_id, _ := c.GetInt64("patient_id")
  8035. // var cFYLJG006 models.CFYLJG006
  8036. // patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8037. // cFYLJG006.HiRxno = flow.HiRxno
  8038. // cFYLJG006.MdtrtID = flow.MID
  8039. // cFYLJG006.PsnName = patient.Name
  8040. // cFYLJG006.PsnCertType = "01"
  8041. // cFYLJG006.Certno = patient.IdCardNo
  8042. //
  8043. // if miConfig.MdtrtareaAdmvs == "340699" {
  8044. // //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8045. //
  8046. // result, request := service.GetAHCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8047. // saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8048. // } else {
  8049. // result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8050. // saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8051. // }
  8052. //
  8053. // var res ResultCFYLJG006
  8054. // var respJSON2 map[string]interface{}
  8055. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8056. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8057. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8058. // return
  8059. // }
  8060. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8061. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8062. // utils.ErrorLog("解析失败:%v", err)
  8063. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8064. // return
  8065. // }
  8066. // if res.Infcode == -1 {
  8067. // c.ServeSuccessJSON(map[string]interface{}{
  8068. // "failed_code": -10,
  8069. // "msg": res.ErrMsg,
  8070. // })
  8071. // return
  8072. // } else {
  8073. // c.ServeSuccessJSON(map[string]interface{}{
  8074. // "info": res.Output,
  8075. // })
  8076. // return
  8077. // }
  8078. //}
  8079. //func (c *HisApiController) GetCFYLJG007() {
  8080. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8081. // his_patient_id, _ := c.GetInt64("his_patient_id")
  8082. // admin_user_id = 3626
  8083. // his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8084. // //id, _ := c.GetInt64("id")
  8085. // admin_user_id = 3626
  8086. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8087. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8088. //
  8089. // flow, _ := service.Getflowtwo(his.Number)
  8090. // //id = 3
  8091. // patient_id, _ := c.GetInt64("patient_id")
  8092. // var cFYLJG007 models.CFYLJG007
  8093. // patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8094. // //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8095. //
  8096. // cFYLJG007.HiRxno = flow.HiRxno
  8097. // cFYLJG007.MdtrtID = flow.MID
  8098. // cFYLJG007.PsnNo = his.PsnNo
  8099. // cFYLJG007.PsnCertType = "01"
  8100. // cFYLJG007.Certno = patient.IdCardNo
  8101. // cFYLJG007.PsnName = patient.Name
  8102. //
  8103. // if miConfig.MdtrtareaAdmvs == "340699" {
  8104. // result, request := service.GetAHCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8105. // saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8106. // } else {
  8107. // result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8108. // saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8109. // }
  8110. //
  8111. // var res ResultCFYLJG007
  8112. // var respJSON2 map[string]interface{}
  8113. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8114. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8115. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8116. // return
  8117. // }
  8118. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8119. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8120. // utils.ErrorLog("解析失败:%v", err)
  8121. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8122. // return
  8123. // }
  8124. // if res.Infcode == -1 {
  8125. // c.ServeSuccessJSON(map[string]interface{}{
  8126. // "failed_code": -10,
  8127. // "msg": res.ErrMsg,
  8128. // })
  8129. // return
  8130. // } else {
  8131. // c.ServeSuccessJSON(map[string]interface{}{
  8132. // "info": res,
  8133. // })
  8134. // return
  8135. // }
  8136. //}
  8137. //
  8138. //func (c *HisApiController) GetCFYLJG008() {
  8139. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8140. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8141. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8142. // var cFYLJG008 models.CFYLJG008
  8143. // //id, _ := c.GetInt64("id")
  8144. // patient_id, _ := c.GetInt64("patient_id")
  8145. // //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8146. // //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8147. // //id = 3
  8148. // //flow, _ := service.Getflow(id)
  8149. // //his, _ := service.GetHisPatientByNumber(flow.MID)
  8150. //
  8151. // //
  8152. // //admin_user_id, _ := c.GetInt64("admin_user_id")
  8153. // //patient_id, _ := c.GetInt64("patient_id")
  8154. // //his_patient_id, _ := c.GetInt64("his_patient_id")
  8155. // record_time := c.GetString("record_time")
  8156. //
  8157. // admin_user_id = 3626
  8158. // patient_id = 19424
  8159. // //his_patient_id = 263947
  8160. // record_time = "2023-08-29"
  8161. //
  8162. // timeLayout := "2006-01-02"
  8163. // loc, _ := time.LoadLocation("Local")
  8164. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8165. // if err != nil {
  8166. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8167. // return
  8168. // }
  8169. // recordDateTime := theTime.Unix()
  8170. // prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8171. //
  8172. // cFYLJG008.FixmedinsName = ""
  8173. // cFYLJG008.Lat = ""
  8174. // cFYLJG008.Lng = ""
  8175. // cFYLJG008.OrderType = "1"
  8176. // cFYLJG008.PoolareaNo = ""
  8177. // cFYLJG008.Lng = ""
  8178. // cFYLJG008.PageNum = 1
  8179. // cFYLJG008.PageSize = 10
  8180. // var MPI models.MedinsProdInvChgDDTO
  8181. // MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8182. // MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8183. // cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8184. //
  8185. // if miConfig.MdtrtareaAdmvs == "340699" {
  8186. // result, request := service.GetAHCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8187. // saveLog(result, request, "GetAHCFYLJG008", "GetAHCFYLJG008")
  8188. //
  8189. // } else {
  8190. // result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8191. // saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8192. //
  8193. // var res ResultCFYLJG008
  8194. // var respJSON2 map[string]interface{}
  8195. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8196. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8197. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8198. // return
  8199. // }
  8200. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8201. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8202. // utils.ErrorLog("解析失败:%v", err)
  8203. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8204. // return
  8205. // }
  8206. // if res.Infcode == -1 {
  8207. // c.ServeSuccessJSON(map[string]interface{}{
  8208. // "failed_code": -10,
  8209. // "msg": res.ErrMsg,
  8210. // })
  8211. // return
  8212. // } else {
  8213. // c.ServeSuccessJSON(map[string]interface{}{
  8214. // "info": res.Output,
  8215. // })
  8216. // return
  8217. // }
  8218. // }
  8219. //
  8220. //}
  8221. func (c *HisApiController) GetBL4201A() {
  8222. order_id, _ := c.GetInt64("order_id")
  8223. admin_user_id, _ := c.GetInt64("admin_user_id")
  8224. order, _ := service.GetHisOrderByIDTwo(order_id)
  8225. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8226. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8227. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8228. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8229. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8230. department, _ := service.GetDepartMentDetail(his.Departments)
  8231. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8232. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8233. if order.ID == 0 {
  8234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8235. return
  8236. }
  8237. var struct4201A models.Struct4201A
  8238. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8239. for _, items := range order_info {
  8240. memo := make(map[string]interface{})
  8241. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8242. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8243. fsiOPFLD.MedType = "14"
  8244. fsiOPFLD.BkkpSn = items.FeedetlSn
  8245. fsiOPFLD.FixmedinsCode = miConfig.Code
  8246. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8247. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8248. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8249. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8250. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8251. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8252. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8253. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8254. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8255. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8256. fsiOPFLD.BilgDeptName = department.Name
  8257. fsiOPFLD.BilgDeptCodg = department.Number
  8258. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8259. fsiOPFLD.BilgDrName = doctor.UserName
  8260. fsiOPFLD.MedChrgitmType = "09"
  8261. memo["hosp_appr_flag"] = "1"
  8262. memo["invoice_no"] = order.MdtrtId
  8263. memo["memo"] = "自费"
  8264. bytesData, _ := json.Marshal(memo)
  8265. fsiOPFLD.Memo = string(bytesData)
  8266. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8267. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8268. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8269. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8270. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8271. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8272. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8273. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8274. fsiOPFLD.BilgDeptName = department.Name
  8275. fsiOPFLD.BilgDeptCodg = department.Number
  8276. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8277. fsiOPFLD.BilgDrName = doctor.UserName
  8278. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8279. case 0:
  8280. break
  8281. case 1:
  8282. fsiOPFLD.MedChrgitmType = "14"
  8283. break
  8284. case 2:
  8285. fsiOPFLD.MedChrgitmType = "05"
  8286. break
  8287. case 3:
  8288. fsiOPFLD.MedChrgitmType = "03"
  8289. break
  8290. case 4:
  8291. fsiOPFLD.MedChrgitmType = "03"
  8292. break
  8293. case 5:
  8294. fsiOPFLD.MedChrgitmType = "08"
  8295. break
  8296. case 6:
  8297. fsiOPFLD.MedChrgitmType = "14"
  8298. break
  8299. case 7:
  8300. fsiOPFLD.MedChrgitmType = "14"
  8301. break
  8302. case 8:
  8303. fsiOPFLD.MedChrgitmType = "03"
  8304. break
  8305. case 9:
  8306. fsiOPFLD.MedChrgitmType = "14"
  8307. break
  8308. case 10:
  8309. fsiOPFLD.MedChrgitmType = "14"
  8310. break
  8311. case 11:
  8312. fsiOPFLD.MedChrgitmType = "06"
  8313. break
  8314. case 12:
  8315. fsiOPFLD.MedChrgitmType = "12"
  8316. break
  8317. case 13:
  8318. fsiOPFLD.MedChrgitmType = "01"
  8319. break
  8320. case 14:
  8321. fsiOPFLD.MedChrgitmType = "04"
  8322. break
  8323. case 15:
  8324. fsiOPFLD.MedChrgitmType = "14"
  8325. break
  8326. }
  8327. memo["hosp_appr_flag"] = "1"
  8328. memo["invoice_no"] = order.MdtrtId
  8329. memo["memo"] = "自费"
  8330. bytesData, _ := json.Marshal(memo)
  8331. fsiOPFLD.Memo = string(bytesData)
  8332. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8333. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8334. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8335. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8336. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8337. fsiOPFLD.BilgDeptName = department.Name
  8338. fsiOPFLD.BilgDeptCodg = department.Number
  8339. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8340. fsiOPFLD.BilgDrName = doctor.UserName
  8341. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8342. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8343. fsiOPFLD.MedChrgitmType = "08"
  8344. memo["hosp_appr_flag"] = "1"
  8345. memo["invoice_no"] = order.MdtrtId
  8346. memo["memo"] = "自费"
  8347. bytesData, _ := json.Marshal(memo)
  8348. fsiOPFLD.Memo = string(bytesData)
  8349. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8350. }
  8351. }
  8352. }
  8353. for _, items := range order_info_two {
  8354. memo := make(map[string]interface{})
  8355. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8356. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8357. fsiOPFLD.MedType = "14"
  8358. fsiOPFLD.BkkpSn = items.FeedetlSn
  8359. fsiOPFLD.FixmedinsCode = miConfig.Code
  8360. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8361. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8362. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8363. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8364. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8365. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8366. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8367. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8368. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8369. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8370. fsiOPFLD.BilgDeptName = department.Name
  8371. fsiOPFLD.BilgDeptCodg = department.Number
  8372. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8373. fsiOPFLD.BilgDrName = doctor.UserName
  8374. fsiOPFLD.MedChrgitmType = "09"
  8375. memo["hosp_appr_flag"] = "1"
  8376. memo["invoice_no"] = order.MdtrtId
  8377. memo["memo"] = "自费"
  8378. bytesData, _ := json.Marshal(memo)
  8379. fsiOPFLD.Memo = string(bytesData)
  8380. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8381. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8382. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8383. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8384. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8385. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8386. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8387. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8388. fsiOPFLD.BilgDeptName = department.Name
  8389. fsiOPFLD.BilgDeptCodg = department.Number
  8390. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8391. fsiOPFLD.BilgDrName = doctor.UserName
  8392. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8393. case 0:
  8394. break
  8395. case 1:
  8396. fsiOPFLD.MedChrgitmType = "14"
  8397. break
  8398. case 2:
  8399. fsiOPFLD.MedChrgitmType = "05"
  8400. break
  8401. case 3:
  8402. fsiOPFLD.MedChrgitmType = "03"
  8403. break
  8404. case 4:
  8405. fsiOPFLD.MedChrgitmType = "03"
  8406. break
  8407. case 5:
  8408. fsiOPFLD.MedChrgitmType = "08"
  8409. break
  8410. case 6:
  8411. fsiOPFLD.MedChrgitmType = "14"
  8412. break
  8413. case 7:
  8414. fsiOPFLD.MedChrgitmType = "14"
  8415. break
  8416. case 8:
  8417. fsiOPFLD.MedChrgitmType = "03"
  8418. break
  8419. case 9:
  8420. fsiOPFLD.MedChrgitmType = "14"
  8421. break
  8422. case 10:
  8423. fsiOPFLD.MedChrgitmType = "14"
  8424. break
  8425. case 11:
  8426. fsiOPFLD.MedChrgitmType = "06"
  8427. break
  8428. case 12:
  8429. fsiOPFLD.MedChrgitmType = "12"
  8430. break
  8431. case 13:
  8432. fsiOPFLD.MedChrgitmType = "01"
  8433. break
  8434. case 14:
  8435. fsiOPFLD.MedChrgitmType = "04"
  8436. break
  8437. case 15:
  8438. fsiOPFLD.MedChrgitmType = "14"
  8439. break
  8440. }
  8441. memo["hosp_appr_flag"] = "1"
  8442. memo["invoice_no"] = order.MdtrtId
  8443. memo["memo"] = "自费"
  8444. bytesData, _ := json.Marshal(memo)
  8445. fsiOPFLD.Memo = string(bytesData)
  8446. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8447. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8448. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8449. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8450. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8451. fsiOPFLD.BilgDeptName = department.Name
  8452. fsiOPFLD.BilgDeptCodg = department.Number
  8453. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8454. fsiOPFLD.BilgDrName = doctor.UserName
  8455. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8456. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8457. fsiOPFLD.MedChrgitmType = "08"
  8458. memo["hosp_appr_flag"] = "1"
  8459. memo["invoice_no"] = order.MdtrtId
  8460. memo["memo"] = "自费"
  8461. bytesData, _ := json.Marshal(memo)
  8462. fsiOPFLD.Memo = string(bytesData)
  8463. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8464. }
  8465. }
  8466. }
  8467. fmt.Println(fsiOPFLDs)
  8468. struct4201A.Fopfd = fsiOPFLDs
  8469. fmt.Println(struct4201A.Fopfd)
  8470. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8471. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8472. var res2 ResultSix
  8473. var respJSON2 map[string]interface{}
  8474. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8475. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8477. return
  8478. }
  8479. userJSONBytes2, _ := json.Marshal(respJSON2)
  8480. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8481. utils.ErrorLog("解析失败:%v", err)
  8482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8483. return
  8484. }
  8485. if res2.Infcode != 0 {
  8486. c.ServeSuccessJSON(map[string]interface{}{
  8487. "failed_code": -10,
  8488. "msg": res2.ErrMsg,
  8489. })
  8490. return
  8491. } else {
  8492. order.IsUploadOrderInfo = 1
  8493. service.UpdateOrder(order)
  8494. c.ServeSuccessJSON(map[string]interface{}{
  8495. "msg": "上传成功",
  8496. })
  8497. }
  8498. }
  8499. func (c *HisApiController) Get2505() {
  8500. admin_user_id, _ := c.GetInt64("admin_user_id")
  8501. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  8502. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8503. service.Gdyb2505("45000000000008100145868008", curRoles.UserName, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "2024-01-12 09:00:00", "2026-12-31 23:00:00", admin_user_id)
  8504. }
  8505. func (c *HisApiController) Get4201A() {
  8506. order_id, _ := c.GetInt64("order_id")
  8507. admin_user_id, _ := c.GetInt64("admin_user_id")
  8508. order, _ := service.GetHisOrderByIDTwo(order_id)
  8509. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8510. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8511. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8512. //order_info = append(order_info, order_info_two...)
  8513. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8514. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8515. department, _ := service.GetDepartMentDetail(his.Departments)
  8516. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8517. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8518. if order.ID == 0 {
  8519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8520. return
  8521. }
  8522. var struct4201A models.Struct4201A
  8523. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8524. for _, items := range order_info {
  8525. memo := make(map[string]interface{})
  8526. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8527. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8528. fsiOPFLD.MedType = "14"
  8529. fsiOPFLD.BkkpSn = items.FeedetlSn
  8530. fsiOPFLD.FixmedinsCode = miConfig.Code
  8531. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8532. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8533. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8534. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8535. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8536. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8537. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8538. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8539. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8540. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8541. fsiOPFLD.BilgDeptName = department.Name
  8542. fsiOPFLD.BilgDeptCodg = department.Number
  8543. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8544. fsiOPFLD.BilgDrName = doctor.UserName
  8545. fsiOPFLD.MedChrgitmType = "09"
  8546. memo["hosp_appr_flag"] = "1"
  8547. memo["invoice_no"] = order.MdtrtId
  8548. memo["memo"] = "自费"
  8549. bytesData, _ := json.Marshal(memo)
  8550. fsiOPFLD.Memo = string(bytesData)
  8551. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8552. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8553. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8554. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8555. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8556. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8557. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8558. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8559. fsiOPFLD.BilgDeptName = department.Name
  8560. fsiOPFLD.BilgDeptCodg = department.Number
  8561. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8562. fsiOPFLD.BilgDrName = doctor.UserName
  8563. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8564. case 0:
  8565. break
  8566. case 1:
  8567. fsiOPFLD.MedChrgitmType = "14"
  8568. break
  8569. case 2:
  8570. fsiOPFLD.MedChrgitmType = "05"
  8571. break
  8572. case 3:
  8573. fsiOPFLD.MedChrgitmType = "03"
  8574. break
  8575. case 4:
  8576. fsiOPFLD.MedChrgitmType = "03"
  8577. break
  8578. case 5:
  8579. fsiOPFLD.MedChrgitmType = "08"
  8580. break
  8581. case 6:
  8582. fsiOPFLD.MedChrgitmType = "14"
  8583. break
  8584. case 7:
  8585. fsiOPFLD.MedChrgitmType = "14"
  8586. break
  8587. case 8:
  8588. fsiOPFLD.MedChrgitmType = "03"
  8589. break
  8590. case 9:
  8591. fsiOPFLD.MedChrgitmType = "14"
  8592. break
  8593. case 10:
  8594. fsiOPFLD.MedChrgitmType = "14"
  8595. break
  8596. case 11:
  8597. fsiOPFLD.MedChrgitmType = "06"
  8598. break
  8599. case 12:
  8600. fsiOPFLD.MedChrgitmType = "12"
  8601. break
  8602. case 13:
  8603. fsiOPFLD.MedChrgitmType = "01"
  8604. break
  8605. case 14:
  8606. fsiOPFLD.MedChrgitmType = "04"
  8607. break
  8608. case 15:
  8609. fsiOPFLD.MedChrgitmType = "14"
  8610. break
  8611. }
  8612. memo["hosp_appr_flag"] = "1"
  8613. memo["invoice_no"] = order.MdtrtId
  8614. memo["memo"] = "自费"
  8615. bytesData, _ := json.Marshal(memo)
  8616. fsiOPFLD.Memo = string(bytesData)
  8617. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8618. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8619. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8620. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8621. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8622. fsiOPFLD.BilgDeptName = department.Name
  8623. fsiOPFLD.BilgDeptCodg = department.Number
  8624. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8625. fsiOPFLD.BilgDrName = doctor.UserName
  8626. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8627. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8628. fsiOPFLD.MedChrgitmType = "08"
  8629. memo["hosp_appr_flag"] = "1"
  8630. memo["invoice_no"] = order.MdtrtId
  8631. memo["memo"] = "自费"
  8632. bytesData, _ := json.Marshal(memo)
  8633. fsiOPFLD.Memo = string(bytesData)
  8634. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8635. }
  8636. }
  8637. }
  8638. for _, items := range order_info_two {
  8639. memo := make(map[string]interface{})
  8640. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8641. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8642. fsiOPFLD.MedType = "14"
  8643. fsiOPFLD.BkkpSn = items.FeedetlSn
  8644. fsiOPFLD.FixmedinsCode = miConfig.Code
  8645. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8646. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8647. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8648. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8649. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8650. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8651. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8652. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8653. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8654. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8655. fsiOPFLD.BilgDeptName = department.Name
  8656. fsiOPFLD.BilgDeptCodg = department.Number
  8657. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8658. fsiOPFLD.BilgDrName = doctor.UserName
  8659. fsiOPFLD.MedChrgitmType = "09"
  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. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8667. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8668. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8669. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8670. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8671. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8672. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8673. fsiOPFLD.BilgDeptName = department.Name
  8674. fsiOPFLD.BilgDeptCodg = department.Number
  8675. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8676. fsiOPFLD.BilgDrName = doctor.UserName
  8677. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8678. case 0:
  8679. break
  8680. case 1:
  8681. fsiOPFLD.MedChrgitmType = "14"
  8682. break
  8683. case 2:
  8684. fsiOPFLD.MedChrgitmType = "05"
  8685. break
  8686. case 3:
  8687. fsiOPFLD.MedChrgitmType = "03"
  8688. break
  8689. case 4:
  8690. fsiOPFLD.MedChrgitmType = "03"
  8691. break
  8692. case 5:
  8693. fsiOPFLD.MedChrgitmType = "08"
  8694. break
  8695. case 6:
  8696. fsiOPFLD.MedChrgitmType = "14"
  8697. break
  8698. case 7:
  8699. fsiOPFLD.MedChrgitmType = "14"
  8700. break
  8701. case 8:
  8702. fsiOPFLD.MedChrgitmType = "03"
  8703. break
  8704. case 9:
  8705. fsiOPFLD.MedChrgitmType = "14"
  8706. break
  8707. case 10:
  8708. fsiOPFLD.MedChrgitmType = "14"
  8709. break
  8710. case 11:
  8711. fsiOPFLD.MedChrgitmType = "06"
  8712. break
  8713. case 12:
  8714. fsiOPFLD.MedChrgitmType = "12"
  8715. break
  8716. case 13:
  8717. fsiOPFLD.MedChrgitmType = "01"
  8718. break
  8719. case 14:
  8720. fsiOPFLD.MedChrgitmType = "04"
  8721. break
  8722. case 15:
  8723. fsiOPFLD.MedChrgitmType = "14"
  8724. break
  8725. }
  8726. memo["hosp_appr_flag"] = "1"
  8727. memo["invoice_no"] = order.MdtrtId
  8728. memo["memo"] = "自费"
  8729. bytesData, _ := json.Marshal(memo)
  8730. fsiOPFLD.Memo = string(bytesData)
  8731. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8732. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8733. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8734. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8735. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8736. fsiOPFLD.BilgDeptName = department.Name
  8737. fsiOPFLD.BilgDeptCodg = department.Number
  8738. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8739. fsiOPFLD.BilgDrName = doctor.UserName
  8740. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8741. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8742. fsiOPFLD.MedChrgitmType = "08"
  8743. memo["hosp_appr_flag"] = "1"
  8744. memo["invoice_no"] = order.MdtrtId
  8745. memo["memo"] = "自费"
  8746. bytesData, _ := json.Marshal(memo)
  8747. fsiOPFLD.Memo = string(bytesData)
  8748. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8749. }
  8750. }
  8751. }
  8752. fmt.Println(fsiOPFLDs)
  8753. struct4201A.Fopfd = fsiOPFLDs
  8754. fmt.Println(struct4201A.Fopfd)
  8755. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8756. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8757. var res2 ResultSix
  8758. var respJSON2 map[string]interface{}
  8759. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8760. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8762. return
  8763. }
  8764. userJSONBytes2, _ := json.Marshal(respJSON2)
  8765. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8766. utils.ErrorLog("解析失败:%v", err)
  8767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8768. return
  8769. }
  8770. if res2.Infcode != 0 {
  8771. c.ServeSuccessJSON(map[string]interface{}{
  8772. "failed_code": -10,
  8773. "msg": res2.ErrMsg,
  8774. })
  8775. return
  8776. } else {
  8777. order.IsUploadOrderInfo = 1
  8778. service.UpdateOrder(order)
  8779. c.ServeSuccessJSON(map[string]interface{}{
  8780. "msg": "上传成功",
  8781. })
  8782. }
  8783. }
  8784. func (c *HisApiController) Get4202() {
  8785. order_id, _ := c.GetInt64("order_id")
  8786. admin_user_id, _ := c.GetInt64("admin_user_id")
  8787. order, _ := service.GetHisOrderByIDTwo(order_id)
  8788. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8789. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8790. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8791. if order.ID == 0 {
  8792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8793. return
  8794. }
  8795. var struct4202 models.Struct4202
  8796. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8797. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8798. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8799. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8800. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8801. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8802. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  8803. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  8804. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8805. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8806. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8807. var config []*models.HisXtDiagnoseConfig
  8808. for _, item := range diagnosis_ids {
  8809. id, _ := strconv.ParseInt(item, 10, 64)
  8810. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8811. config = append(config, &diagnosisConfig)
  8812. }
  8813. var tempDiaginfos []models.OwnPayPatnDiagListD
  8814. for index, item := range config {
  8815. if index == 0 {
  8816. var tempDiaginfo models.OwnPayPatnDiagListD
  8817. tempDiaginfo.InoutDiagType = "1"
  8818. tempDiaginfo.DiagCode = item.CountryCode
  8819. tempDiaginfo.DiagName = item.CountryContentName
  8820. tempDiaginfo.DiagType = "1"
  8821. tempDiaginfo.DiagSrtNo = "1"
  8822. tempDiaginfo.MaindiagFlag = "1"
  8823. tempDiaginfo.ValiFlag = "1"
  8824. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8825. } else {
  8826. var tempDiaginfo models.OwnPayPatnDiagListD
  8827. tempDiaginfo.DiagCode = item.CountryCode
  8828. tempDiaginfo.DiagName = item.CountryContentName
  8829. tempDiaginfo.DiagType = "2"
  8830. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8831. tempDiaginfo.MaindiagFlag = "0"
  8832. tempDiaginfo.ValiFlag = "1"
  8833. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8834. }
  8835. }
  8836. struct4202.ODiagListD = tempDiaginfos
  8837. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  8838. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  8839. var res2 ResultSix
  8840. var respJSON2 map[string]interface{}
  8841. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8842. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8844. return
  8845. }
  8846. userJSONBytes2, _ := json.Marshal(respJSON2)
  8847. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8848. utils.ErrorLog("解析失败:%v", err)
  8849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8850. return
  8851. }
  8852. if res2.Infcode != 0 {
  8853. c.ServeSuccessJSON(map[string]interface{}{
  8854. "failed_code": -10,
  8855. "msg": res2.ErrMsg,
  8856. })
  8857. return
  8858. } else {
  8859. order.IsUploadDiagnose = 1
  8860. service.UpdateOrder(order)
  8861. c.ServeSuccessJSON(map[string]interface{}{
  8862. "msg": "上传成功",
  8863. })
  8864. }
  8865. }
  8866. func (c *HisApiController) Get4203() {
  8867. admin_user_id, _ := c.GetInt64("admin_user_id")
  8868. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8869. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8870. order_id, _ := c.GetInt64("order_id")
  8871. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8872. number := ""
  8873. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8874. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8875. if his.ID == 0 {
  8876. number = hospital.Number
  8877. } else {
  8878. number = his.Number
  8879. }
  8880. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  8881. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  8882. var res2 ResultSix
  8883. var respJSON2 map[string]interface{}
  8884. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8885. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8887. return
  8888. }
  8889. userJSONBytes2, _ := json.Marshal(respJSON2)
  8890. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8891. utils.ErrorLog("解析失败:%v", err)
  8892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8893. return
  8894. }
  8895. if res2.Infcode != 0 {
  8896. c.ServeSuccessJSON(map[string]interface{}{
  8897. "failed_code": -10,
  8898. "msg": res2.ErrMsg,
  8899. })
  8900. return
  8901. } else {
  8902. order.IsUploadSuccess = 1
  8903. service.UpdateOrderTwo(order)
  8904. c.ServeSuccessJSON(map[string]interface{}{
  8905. "msg": "上传成功",
  8906. })
  8907. }
  8908. }
  8909. func (c *HisApiController) Get4205() {
  8910. order_id, _ := c.GetInt64("order_id")
  8911. admin_user_id, _ := c.GetInt64("admin_user_id")
  8912. fapiao_code := c.GetString("fapiao_code")
  8913. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8914. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8915. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8916. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8917. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  8918. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8919. //order_info = append(order_info, order_info_two...)
  8920. department, _ := service.GetDepartMentDetail(his.Departments)
  8921. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8922. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8923. if order.ID == 0 {
  8924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8925. return
  8926. }
  8927. var struct4201A models.Struct4201A
  8928. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8929. for _, items := range order_info {
  8930. memo := make(map[string]interface{})
  8931. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8932. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8933. fsiOPFLD.MedType = pre.MedType
  8934. fsiOPFLD.FixmedinsCode = miConfig.Code
  8935. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8936. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8937. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8938. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8939. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8940. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8941. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8942. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  8943. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8944. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8945. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8946. fsiOPFLD.BilgDeptName = department.Name
  8947. fsiOPFLD.BilgDeptCodg = department.Number
  8948. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8949. fsiOPFLD.BilgDrName = doctor.UserName
  8950. fsiOPFLD.MedChrgitmType = "09"
  8951. memo["hosp_appr_flag"] = "1"
  8952. memo["invoice_no"] = fapiao_code
  8953. memo["memo"] = "自费"
  8954. bytesData, _ := json.Marshal(memo)
  8955. fsiOPFLD.Memo = string(bytesData)
  8956. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8957. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8958. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8959. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8960. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8961. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8962. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8963. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8964. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8965. fsiOPFLD.BilgDeptName = department.Name
  8966. fsiOPFLD.BilgDeptCodg = department.Number
  8967. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8968. fsiOPFLD.BilgDrName = doctor.UserName
  8969. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8970. case 0:
  8971. break
  8972. case 1:
  8973. fsiOPFLD.MedChrgitmType = "14"
  8974. break
  8975. case 2:
  8976. fsiOPFLD.MedChrgitmType = "05"
  8977. break
  8978. case 3:
  8979. fsiOPFLD.MedChrgitmType = "03"
  8980. break
  8981. case 4:
  8982. fsiOPFLD.MedChrgitmType = "03"
  8983. break
  8984. case 5:
  8985. fsiOPFLD.MedChrgitmType = "08"
  8986. break
  8987. case 6:
  8988. fsiOPFLD.MedChrgitmType = "14"
  8989. break
  8990. case 7:
  8991. fsiOPFLD.MedChrgitmType = "14"
  8992. break
  8993. case 8:
  8994. fsiOPFLD.MedChrgitmType = "03"
  8995. break
  8996. case 9:
  8997. fsiOPFLD.MedChrgitmType = "14"
  8998. break
  8999. case 10:
  9000. fsiOPFLD.MedChrgitmType = "14"
  9001. break
  9002. case 11:
  9003. fsiOPFLD.MedChrgitmType = "06"
  9004. break
  9005. case 12:
  9006. fsiOPFLD.MedChrgitmType = "12"
  9007. break
  9008. case 13:
  9009. fsiOPFLD.MedChrgitmType = "01"
  9010. break
  9011. case 14:
  9012. fsiOPFLD.MedChrgitmType = "04"
  9013. break
  9014. case 15:
  9015. fsiOPFLD.MedChrgitmType = "14"
  9016. break
  9017. }
  9018. memo["hosp_appr_flag"] = "1"
  9019. memo["invoice_no"] = fapiao_code
  9020. memo["memo"] = "自费"
  9021. bytesData, _ := json.Marshal(memo)
  9022. fsiOPFLD.Memo = string(bytesData)
  9023. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9024. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9025. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9026. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9027. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9028. fsiOPFLD.BilgDeptName = department.Name
  9029. fsiOPFLD.BilgDeptCodg = department.Number
  9030. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9031. fsiOPFLD.BilgDrName = doctor.UserName
  9032. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9033. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9034. fsiOPFLD.MedChrgitmType = "08"
  9035. memo["hosp_appr_flag"] = "1"
  9036. memo["invoice_no"] = fapiao_code
  9037. memo["memo"] = "自费"
  9038. bytesData, _ := json.Marshal(memo)
  9039. fsiOPFLD.Memo = string(bytesData)
  9040. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9041. }
  9042. }
  9043. }
  9044. for _, items := range order_info_two {
  9045. memo := make(map[string]interface{})
  9046. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9047. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9048. fsiOPFLD.MedType = pre.MedType
  9049. fsiOPFLD.BkkpSn = items.FeedetlSn
  9050. fsiOPFLD.FixmedinsCode = miConfig.Code
  9051. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9052. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9053. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9054. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9055. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9056. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9057. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9058. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9059. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9060. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9061. fsiOPFLD.BilgDeptName = department.Name
  9062. fsiOPFLD.BilgDeptCodg = department.Number
  9063. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9064. fsiOPFLD.BilgDrName = doctor.UserName
  9065. fsiOPFLD.MedChrgitmType = "09"
  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. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9073. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9074. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9075. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9076. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9077. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9078. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9079. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9080. fsiOPFLD.BilgDeptName = department.Name
  9081. fsiOPFLD.BilgDeptCodg = department.Number
  9082. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9083. fsiOPFLD.BilgDrName = doctor.UserName
  9084. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9085. case 0:
  9086. break
  9087. case 1:
  9088. fsiOPFLD.MedChrgitmType = "14"
  9089. break
  9090. case 2:
  9091. fsiOPFLD.MedChrgitmType = "05"
  9092. break
  9093. case 3:
  9094. fsiOPFLD.MedChrgitmType = "03"
  9095. break
  9096. case 4:
  9097. fsiOPFLD.MedChrgitmType = "03"
  9098. break
  9099. case 5:
  9100. fsiOPFLD.MedChrgitmType = "08"
  9101. break
  9102. case 6:
  9103. fsiOPFLD.MedChrgitmType = "14"
  9104. break
  9105. case 7:
  9106. fsiOPFLD.MedChrgitmType = "14"
  9107. break
  9108. case 8:
  9109. fsiOPFLD.MedChrgitmType = "03"
  9110. break
  9111. case 9:
  9112. fsiOPFLD.MedChrgitmType = "14"
  9113. break
  9114. case 10:
  9115. fsiOPFLD.MedChrgitmType = "14"
  9116. break
  9117. case 11:
  9118. fsiOPFLD.MedChrgitmType = "06"
  9119. break
  9120. case 12:
  9121. fsiOPFLD.MedChrgitmType = "12"
  9122. break
  9123. case 13:
  9124. fsiOPFLD.MedChrgitmType = "01"
  9125. break
  9126. case 14:
  9127. fsiOPFLD.MedChrgitmType = "04"
  9128. break
  9129. case 15:
  9130. fsiOPFLD.MedChrgitmType = "14"
  9131. break
  9132. }
  9133. memo["hosp_appr_flag"] = "1"
  9134. memo["invoice_no"] = fapiao_code
  9135. memo["memo"] = "自费"
  9136. bytesData, _ := json.Marshal(memo)
  9137. fsiOPFLD.Memo = string(bytesData)
  9138. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9139. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9140. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9141. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9142. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9143. fsiOPFLD.BilgDeptName = department.Name
  9144. fsiOPFLD.BilgDeptCodg = department.Number
  9145. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9146. fsiOPFLD.BilgDrName = doctor.UserName
  9147. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9148. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9149. fsiOPFLD.MedChrgitmType = "08"
  9150. memo["hosp_appr_flag"] = "1"
  9151. memo["invoice_no"] = fapiao_code
  9152. memo["memo"] = "自费"
  9153. bytesData, _ := json.Marshal(memo)
  9154. fsiOPFLD.Memo = string(bytesData)
  9155. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9156. }
  9157. }
  9158. }
  9159. fmt.Println(fsiOPFLDs)
  9160. struct4201A.Fopfd = fsiOPFLDs
  9161. fmt.Println(struct4201A.Fopfd)
  9162. var struct4202 models.Struct4202
  9163. timeLayout := "2006-01-02 15:04:05"
  9164. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9165. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9166. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9167. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9168. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9169. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9170. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9171. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9172. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9173. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9174. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9175. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9176. var config []*models.HisXtDiagnoseConfig
  9177. for _, item := range diagnosis_ids {
  9178. id, _ := strconv.ParseInt(item, 10, 64)
  9179. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9180. config = append(config, &diagnosisConfig)
  9181. }
  9182. var tempDiaginfos []models.OwnPayPatnDiagListD
  9183. for index, item := range config {
  9184. if index == 0 {
  9185. var tempDiaginfo models.OwnPayPatnDiagListD
  9186. tempDiaginfo.InoutDiagType = "1"
  9187. tempDiaginfo.DiagCode = item.CountryCode
  9188. tempDiaginfo.DiagName = item.CountryContentName
  9189. tempDiaginfo.DiagType = "1"
  9190. tempDiaginfo.DiagSrtNo = "1"
  9191. tempDiaginfo.MaindiagFlag = "1"
  9192. tempDiaginfo.ValiFlag = "1"
  9193. tempDiaginfo.DiagDrName = doctor.UserName
  9194. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9195. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9196. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9197. } else {
  9198. var tempDiaginfo models.OwnPayPatnDiagListD
  9199. tempDiaginfo.DiagCode = item.CountryCode
  9200. tempDiaginfo.DiagName = item.CountryContentName
  9201. tempDiaginfo.DiagType = "2"
  9202. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9203. tempDiaginfo.MaindiagFlag = "0"
  9204. tempDiaginfo.ValiFlag = "1"
  9205. tempDiaginfo.DiagDrName = doctor.UserName
  9206. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9207. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9208. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9209. }
  9210. }
  9211. struct4202.ODiagListD = tempDiaginfos
  9212. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  9213. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  9214. var res2 ResultSix
  9215. var respJSON2 map[string]interface{}
  9216. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9217. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9219. return
  9220. }
  9221. userJSONBytes2, _ := json.Marshal(respJSON2)
  9222. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9223. utils.ErrorLog("解析失败:%v", err)
  9224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9225. return
  9226. }
  9227. if res2.Infcode != 0 {
  9228. c.ServeSuccessJSON(map[string]interface{}{
  9229. "failed_code": -10,
  9230. "msg": res2.ErrMsg,
  9231. })
  9232. return
  9233. } else {
  9234. order.IsUploadDiagnose = 1
  9235. order.IsUploadOrderInfo = 1
  9236. service.UpdateOrderTwo(order)
  9237. c.ServeSuccessJSON(map[string]interface{}{
  9238. "msg": "上传成功",
  9239. })
  9240. }
  9241. }
  9242. func (c *HisApiController) Get4207() {
  9243. admin_user_id, _ := c.GetInt64("admin_user_id")
  9244. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9245. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9246. order_id, _ := c.GetInt64("order_id")
  9247. order, _ := service.GetHisOrderByIDTwo(order_id)
  9248. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9249. var struct4207 models.Struct4207
  9250. struct4207.PageNum = "1"
  9251. struct4207.PageSize = "1000"
  9252. struct4207.FixmedinsCode = miConfig.Code
  9253. struct4207.FixmedinsMdtrtID = order.Number
  9254. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  9255. saveLog(result, requestLog, "4207", "查询")
  9256. var res2 ResultSix
  9257. var respJSON2 map[string]interface{}
  9258. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9261. return
  9262. }
  9263. userJSONBytes2, _ := json.Marshal(respJSON2)
  9264. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9265. utils.ErrorLog("解析失败:%v", err)
  9266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9267. return
  9268. }
  9269. if res2.Infcode != 0 {
  9270. c.ServeSuccessJSON(map[string]interface{}{
  9271. "failed_code": -10,
  9272. "msg": res2.ErrMsg,
  9273. })
  9274. return
  9275. } else {
  9276. c.ServeSuccessJSON(map[string]interface{}{
  9277. "msg": "查询成功",
  9278. })
  9279. }
  9280. }
  9281. func (c *HisApiController) Get4208() {
  9282. admin_user_id, _ := c.GetInt64("admin_user_id")
  9283. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9284. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9285. order_id, _ := c.GetInt64("order_id")
  9286. order, _ := service.GetHisOrderByIDTwo(order_id)
  9287. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9288. var struct4208 models.Struct4208
  9289. struct4208.PageNum = "1"
  9290. struct4208.PageSize = "1000"
  9291. struct4208.PsnCertType = "01"
  9292. struct4208.Certno = his.Certno
  9293. struct4208.MedType = order.MedType
  9294. struct4208.PsnName = his.Name
  9295. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  9296. saveLog(result, requestLog, "4208", "查询")
  9297. var res2 ResultSix
  9298. var respJSON2 map[string]interface{}
  9299. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9300. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9302. return
  9303. }
  9304. userJSONBytes2, _ := json.Marshal(respJSON2)
  9305. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9306. utils.ErrorLog("解析失败:%v", err)
  9307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9308. return
  9309. }
  9310. if res2.Infcode != 0 {
  9311. c.ServeSuccessJSON(map[string]interface{}{
  9312. "failed_code": -10,
  9313. "msg": res2.ErrMsg,
  9314. })
  9315. return
  9316. } else {
  9317. c.ServeSuccessJSON(map[string]interface{}{
  9318. "msg": "查询成功",
  9319. })
  9320. }
  9321. }
  9322. func (c *HisApiController) Get4209() {
  9323. admin_user_id, _ := c.GetInt64("admin_user_id")
  9324. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9325. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9326. order_id, _ := c.GetInt64("order_id")
  9327. order, _ := service.GetHisOrderByIDTwo(order_id)
  9328. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9329. var struct4209 models.Struct4209
  9330. struct4209.FixmedinsMdtrtID = order.Number
  9331. struct4209.FixmedinsCode = miConfig.Code
  9332. struct4209.PageSize = "1000"
  9333. struct4209.PageNum = "1"
  9334. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  9335. saveLog(result, requestLog, "4209", "查询")
  9336. var res2 ResultSix
  9337. var respJSON2 map[string]interface{}
  9338. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9339. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9341. return
  9342. }
  9343. userJSONBytes2, _ := json.Marshal(respJSON2)
  9344. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9345. utils.ErrorLog("解析失败:%v", err)
  9346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9347. return
  9348. }
  9349. if res2.Infcode != 0 {
  9350. c.ServeSuccessJSON(map[string]interface{}{
  9351. "failed_code": -10,
  9352. "msg": res2.ErrMsg,
  9353. })
  9354. return
  9355. } else {
  9356. c.ServeSuccessJSON(map[string]interface{}{
  9357. "msg": "查询成功",
  9358. })
  9359. }
  9360. }
  9361. type Result3101 struct {
  9362. Infcode string `json:"infcode"`
  9363. InfRefmsgid string `json:"inf_refmsgid"`
  9364. RefmsgTime string `json:"refmsg_time"`
  9365. RespondTime string `json:"respond_time"`
  9366. Enctype string `json:"enctype"`
  9367. Signtype string `json:"signtype"`
  9368. ErrMsg string `json:"err_msg"`
  9369. Output struct {
  9370. Result []struct {
  9371. JudgeResultDetailDtos []struct {
  9372. VolaItemType string `json:"vola_item_type"`
  9373. MdtrtID string `json:"mdtrt_id"`
  9374. JrdID string `json:"jrd_id"`
  9375. PatnID string `json:"patn_id"`
  9376. RxID string `json:"rx_id"`
  9377. VolaAmt interface{} `json:"vola_amt"`
  9378. } `json:"judge_result_detail_dtos"`
  9379. RuleID string `json:"rule_id"`
  9380. VolaEvid string `json:"vola_evid"`
  9381. MdtrtID string `json:"mdtrt_id"`
  9382. RuleName string `json:"rule_name"`
  9383. VolaAmtStas string `json:"vola_amt_stas"`
  9384. JrID string `json:"jr_id"`
  9385. PatnID string `json:"patn_id"`
  9386. SevDeg string `json:"sev_deg"`
  9387. VolaAmt float64 `json:"vola_amt"`
  9388. VolaBhvrType string `json:"vola_bhvr_type"`
  9389. VolaCont string `json:"vola_cont"`
  9390. } `json:"result"`
  9391. } `json:"output"`
  9392. }
  9393. type Resultgd3101 struct {
  9394. Infcode int64 `json:"infcode"`
  9395. InfRefmsgid string `json:"inf_refmsgid"`
  9396. RefmsgTime string `json:"refmsg_time"`
  9397. RespondTime string `json:"respond_time"`
  9398. Enctype string `json:"enctype"`
  9399. Signtype string `json:"signtype"`
  9400. ErrMsg string `json:"err_msg"`
  9401. Output struct {
  9402. Result []struct {
  9403. JudgeResultDetailDtos []struct {
  9404. VolaItemType string `json:"vola_item_type"`
  9405. MdtrtID string `json:"mdtrt_id"`
  9406. JrdID string `json:"jrd_id"`
  9407. PatnID string `json:"patn_id"`
  9408. RxID string `json:"rx_id"`
  9409. VolaAmt interface{} `json:"vola_amt"`
  9410. } `json:"judge_result_detail_dtos"`
  9411. RuleID string `json:"rule_id"`
  9412. VolaEvid string `json:"vola_evid"`
  9413. MdtrtID string `json:"mdtrt_id"`
  9414. RuleName string `json:"rule_name"`
  9415. VolaAmtStas string `json:"vola_amt_stas"`
  9416. JrID string `json:"jr_id"`
  9417. PatnID string `json:"patn_id"`
  9418. SevDeg string `json:"sev_deg"`
  9419. VolaAmt float64 `json:"vola_amt"`
  9420. VolaBhvrType string `json:"vola_bhvr_type"`
  9421. VolaCont string `json:"vola_cont"`
  9422. } `json:"result"`
  9423. } `json:"output"`
  9424. }
  9425. func (c *HisApiController) ReadEleToken() {
  9426. admin_user_id, _ := c.GetInt64("admin_user_id")
  9427. his_patient_id, _ := c.GetInt64("his_patient_id")
  9428. adminUser := c.GetAdminUserInfo()
  9429. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9430. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9431. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9432. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9433. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9434. if len(tokens) > 0 {
  9435. c.ServeSuccessJSON(map[string]interface{}{
  9436. "msg": "读取成功",
  9437. })
  9438. } else {
  9439. c.ServeSuccessJSON(map[string]interface{}{
  9440. "failed_code": -10,
  9441. "msg": "读取失败",
  9442. })
  9443. }
  9444. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9445. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9446. if len(tokens) > 0 {
  9447. c.ServeSuccessJSON(map[string]interface{}{
  9448. "msg": "读取成功",
  9449. })
  9450. } else {
  9451. c.ServeSuccessJSON(map[string]interface{}{
  9452. "failed_code": -10,
  9453. "msg": "读取失败",
  9454. })
  9455. }
  9456. } else if miConfig.MdtrtareaAdmvs == "340699" {
  9457. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9458. if len(tokens) > 0 {
  9459. c.ServeSuccessJSON(map[string]interface{}{
  9460. "msg": "读取成功",
  9461. })
  9462. } else {
  9463. c.ServeSuccessJSON(map[string]interface{}{
  9464. "failed_code": -10,
  9465. "msg": "读取失败",
  9466. })
  9467. }
  9468. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9469. var api string
  9470. 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 +
  9471. "&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"
  9472. resp, requestErr := http.Get(api)
  9473. if requestErr != nil {
  9474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9475. }
  9476. body, ioErr := ioutil.ReadAll(resp.Body)
  9477. if ioErr != nil {
  9478. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9480. }
  9481. var respJSON map[string]interface{}
  9482. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9483. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9485. return
  9486. }
  9487. var status string
  9488. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9489. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9490. var token string
  9491. var res ResultTwo //1101结果
  9492. var res10265 ResultTwo10265 //1101结果
  9493. if status == "0" { //读卡成功
  9494. var card_info string //卡信息
  9495. var busi_card_info string
  9496. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9497. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9498. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9499. fmt.Println(card_info)
  9500. fmt.Println(busi_card_info)
  9501. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9502. result, _ := json.Marshal(respJSON)
  9503. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9504. utils.ErrorLog("解析失败:%v", err)
  9505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9506. return
  9507. }
  9508. res.ErrMsg = res10265.ErrMsg
  9509. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9510. res.Infcode = infocode
  9511. res.Output = res10265.Output
  9512. res.InfRefmsgid = res10265.InfRefmsgid
  9513. if res.Infcode == 0 {
  9514. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9515. if err == gorm.ErrRecordNotFound {
  9516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9517. return
  9518. } else if err != nil {
  9519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9520. return
  9521. } else {
  9522. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9523. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9524. infoStr := string(Iinfos)
  9525. idetinfoStr := string(Idetinfos)
  9526. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  9527. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9528. psn := &models.HisPsn{
  9529. PsnNo: res.Output.Baseinfo.PsnNo,
  9530. PatientId: patient.ID,
  9531. Certno: res.Output.Baseinfo.Certno,
  9532. Gend: res.Output.Baseinfo.Gend,
  9533. Naty: res.Output.Baseinfo.Naty,
  9534. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9535. PsnName: res.Output.Baseinfo.PsnName,
  9536. Age: float64(age),
  9537. Brdy: b,
  9538. Idetinfo: idetinfoStr,
  9539. Insuinfo: infoStr,
  9540. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9541. CardInfo: card_info,
  9542. VerifyNumber: token,
  9543. IdCardType: 4,
  9544. }
  9545. var rf []*ResultFive
  9546. json.Unmarshal([]byte(infoStr), &rf)
  9547. var insutypes []*ResultFive
  9548. var insutype string
  9549. var is390 int = 0
  9550. var is310 int = 0
  9551. for _, item := range rf {
  9552. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9553. insutypes = append(insutypes, item)
  9554. }
  9555. }
  9556. if len(insutypes) == 1 {
  9557. insutype = insutypes[0].Insutype
  9558. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9559. } else {
  9560. for _, i := range insutypes {
  9561. if i.Insutype == "390" {
  9562. is390 = 1
  9563. }
  9564. if i.Insutype == "310" {
  9565. is310 = 1
  9566. }
  9567. }
  9568. }
  9569. if is390 == 1 {
  9570. insutype = "390"
  9571. }
  9572. if is310 == 1 {
  9573. insutype = "310"
  9574. }
  9575. if len(insutypes) == 0 {
  9576. insutype = "310"
  9577. }
  9578. service.CreateHisPsn(psn)
  9579. c.ServeSuccessJSON(map[string]interface{}{
  9580. "patient": patient,
  9581. "number": token,
  9582. "insutype": insutype,
  9583. })
  9584. }
  9585. } else {
  9586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9587. return
  9588. }
  9589. } else { //读卡失败
  9590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9591. return
  9592. }
  9593. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9594. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  9595. if len(errMsg) == 0 {
  9596. type ELeData struct {
  9597. Data struct {
  9598. IdNo string `json:"idNo"`
  9599. IdType string `json:"idType"`
  9600. UserName string `json:"userName"`
  9601. EcToken string `json:"ecToken"`
  9602. InsuOrg string `json:"insuOrg"`
  9603. Gender string `json:"gender"`
  9604. Birthday string `json:"birthday"`
  9605. Nationality string `json:"nationality"`
  9606. Email string `json:"email"`
  9607. Extra string `json:"extra"`
  9608. } `json:"data"`
  9609. Code int `json:"code"`
  9610. Message string `json:"message"`
  9611. }
  9612. var ele ELeData
  9613. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9614. if err != nil {
  9615. utils.ErrorLog("解析失败:%v", err)
  9616. }
  9617. token := ele.Data.EcToken
  9618. if len(token) > 0 {
  9619. psn := &models.HisPsn{
  9620. PsnNo: his.PsnNo,
  9621. Age: 0,
  9622. PatientId: his.PatientId,
  9623. Certno: his.Certno,
  9624. Brdy: his.Brdy,
  9625. Gend: his.Gend,
  9626. Naty: his.Naty,
  9627. PsnCertType: his.PsnCertType,
  9628. PsnName: his.PsnName,
  9629. Idetinfo: his.Idetinfo,
  9630. Insuinfo: his.Iinfo,
  9631. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9632. CardInfo: outPutInfo,
  9633. VerifyNumber: token,
  9634. }
  9635. service.CreateHisPsn(psn)
  9636. }
  9637. if len(token) > 0 {
  9638. c.ServeSuccessJSON(map[string]interface{}{
  9639. "msg": "读取成功",
  9640. })
  9641. } else {
  9642. c.ServeSuccessJSON(map[string]interface{}{
  9643. "failed_code": -10,
  9644. "msg": "读取失败",
  9645. })
  9646. }
  9647. }
  9648. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9649. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9650. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9651. type ELeData struct {
  9652. Data struct {
  9653. IdNo string `json:"idNo"`
  9654. IdType string `json:"idType"`
  9655. UserName string `json:"userName"`
  9656. EcToken string `json:"ecToken"`
  9657. InsuOrg string `json:"insuOrg"`
  9658. Gender string `json:"gender"`
  9659. Birthday string `json:"birthday"`
  9660. Nationality string `json:"nationality"`
  9661. Email string `json:"email"`
  9662. Extra string `json:"extra"`
  9663. } `json:"data"`
  9664. Code int `json:"code"`
  9665. Message string `json:"message"`
  9666. }
  9667. var ele ELeData
  9668. err := json.Unmarshal([]byte(result), &ele)
  9669. if err != nil {
  9670. utils.ErrorLog("解析失败:%v", err)
  9671. }
  9672. token := ele.Data.EcToken
  9673. token = Remove0000(token)
  9674. fmt.Println(ele.Data.UserName)
  9675. 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)
  9676. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9677. var res ResultTwo
  9678. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9679. utils.ErrorLog("解析失败:%v", err)
  9680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9681. return
  9682. }
  9683. if res.Infcode == 0 {
  9684. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9685. if err == gorm.ErrRecordNotFound {
  9686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9687. return
  9688. } else if err != nil {
  9689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9690. return
  9691. } else {
  9692. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9693. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9694. infoStr := string(Iinfos)
  9695. idetinfoStr := string(Idetinfos)
  9696. psn := &models.HisPsn{
  9697. PsnNo: res.Output.Baseinfo.PsnNo,
  9698. PatientId: patient.ID,
  9699. Certno: res.Output.Baseinfo.Certno,
  9700. Gend: res.Output.Baseinfo.Gend,
  9701. Naty: res.Output.Baseinfo.Naty,
  9702. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9703. PsnName: res.Output.Baseinfo.PsnName,
  9704. Idetinfo: idetinfoStr,
  9705. Insuinfo: infoStr,
  9706. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9707. CardInfo: "",
  9708. VerifyNumber: token,
  9709. }
  9710. service.CreateHisPsn(psn)
  9711. c.ServeSuccessJSON(map[string]interface{}{
  9712. "patient": patient,
  9713. "number": token,
  9714. })
  9715. }
  9716. } else {
  9717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9718. return
  9719. }
  9720. } else if miConfig.MdtrtareaAdmvs == "361025" {
  9721. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9722. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9723. type ELeData struct {
  9724. Data struct {
  9725. IdNo string `json:"idNo"`
  9726. IdType string `json:"idType"`
  9727. UserName string `json:"userName"`
  9728. EcToken string `json:"ecToken"`
  9729. InsuOrg string `json:"insuOrg"`
  9730. Gender string `json:"gender"`
  9731. Birthday string `json:"birthday"`
  9732. Nationality string `json:"nationality"`
  9733. Email string `json:"email"`
  9734. Extra string `json:"extra"`
  9735. } `json:"data"`
  9736. Code int `json:"code"`
  9737. Message string `json:"message"`
  9738. }
  9739. var ele ELeData
  9740. err := json.Unmarshal([]byte(result), &ele)
  9741. if err != nil {
  9742. utils.ErrorLog("解析失败:%v", err)
  9743. }
  9744. token := ele.Data.EcToken
  9745. token = Remove0000(token)
  9746. fmt.Println(ele.Data.UserName)
  9747. 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)
  9748. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9749. var res ResultTwo
  9750. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9751. utils.ErrorLog("解析失败:%v", err)
  9752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9753. return
  9754. }
  9755. if res.Infcode == 0 {
  9756. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9757. if err == gorm.ErrRecordNotFound {
  9758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9759. return
  9760. } else if err != nil {
  9761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9762. return
  9763. } else {
  9764. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9765. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9766. infoStr := string(Iinfos)
  9767. idetinfoStr := string(Idetinfos)
  9768. psn := &models.HisPsn{
  9769. PsnNo: res.Output.Baseinfo.PsnNo,
  9770. PatientId: patient.ID,
  9771. Certno: res.Output.Baseinfo.Certno,
  9772. Gend: res.Output.Baseinfo.Gend,
  9773. Naty: res.Output.Baseinfo.Naty,
  9774. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9775. PsnName: res.Output.Baseinfo.PsnName,
  9776. Idetinfo: idetinfoStr,
  9777. Insuinfo: infoStr,
  9778. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9779. CardInfo: "",
  9780. VerifyNumber: token,
  9781. }
  9782. service.CreateHisPsn(psn)
  9783. c.ServeSuccessJSON(map[string]interface{}{
  9784. "patient": patient,
  9785. "number": token,
  9786. })
  9787. }
  9788. } else {
  9789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9790. return
  9791. }
  9792. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9793. //if initFlag == 0 {
  9794. //c.TestGetJiangXiBasBaseInit()
  9795. //}
  9796. //if initEleFlag == 0 {
  9797. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9798. //}
  9799. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  9800. utils.ErrorLog("解析失败:%v", json_result)
  9801. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9802. type ELeData struct {
  9803. Data struct {
  9804. IdNo string `json:"idNo"`
  9805. IdType string `json:"idType"`
  9806. UserName string `json:"userName"`
  9807. EcToken string `json:"ecToken"`
  9808. InsuOrg string `json:"insuOrg"`
  9809. Gender string `json:"gender"`
  9810. Birthday string `json:"birthday"`
  9811. Nationality string `json:"nationality"`
  9812. Email string `json:"email"`
  9813. Extra string `json:"extra"`
  9814. } `json:"data"`
  9815. Code int `json:"code"`
  9816. Message string `json:"message"`
  9817. }
  9818. var ele ELeData
  9819. err := json.Unmarshal([]byte(json_result), &ele)
  9820. if err != nil {
  9821. utils.ErrorLog("解析失败:%v", err)
  9822. }
  9823. token := ele.Data.EcToken
  9824. token = Remove0000(token)
  9825. //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)
  9826. 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)
  9827. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9828. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9829. var res ResultTwo
  9830. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9831. utils.ErrorLog("解析失败:%v", err)
  9832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9833. return
  9834. }
  9835. if res.Infcode == 0 {
  9836. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9837. if err == gorm.ErrRecordNotFound {
  9838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9839. return
  9840. } else if err != nil {
  9841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9842. return
  9843. } else {
  9844. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9845. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9846. infoStr := string(Iinfos)
  9847. idetinfoStr := string(Idetinfos)
  9848. psn := &models.HisPsn{
  9849. PsnNo: res.Output.Baseinfo.PsnNo,
  9850. PatientId: patient.ID,
  9851. Certno: res.Output.Baseinfo.Certno,
  9852. Gend: res.Output.Baseinfo.Gend,
  9853. Naty: res.Output.Baseinfo.Naty,
  9854. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9855. PsnName: res.Output.Baseinfo.PsnName,
  9856. Idetinfo: idetinfoStr,
  9857. Insuinfo: infoStr,
  9858. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9859. CardInfo: "",
  9860. VerifyNumber: token,
  9861. InsuplcAdmdvs: ele.Data.InsuOrg,
  9862. }
  9863. service.CreateHisPsn(psn)
  9864. c.ServeSuccessJSON(map[string]interface{}{
  9865. "patient": patient,
  9866. "number": token,
  9867. })
  9868. }
  9869. } else {
  9870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9871. return
  9872. }
  9873. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9874. res := c.GetoleInfo()
  9875. if res.Infcode == 0 {
  9876. var result string
  9877. if res.Output.MdtrtCertType == "01" {
  9878. 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)
  9879. } else if res.Output.MdtrtCertType == "02" {
  9880. 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)
  9881. } else if res.Output.MdtrtCertType == "03" {
  9882. 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)
  9883. }
  9884. var dat map[string]interface{}
  9885. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9886. fmt.Println(dat)
  9887. } else {
  9888. fmt.Println(err)
  9889. }
  9890. userJSONBytes, _ := json.Marshal(dat)
  9891. var res2 ResultTwo
  9892. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9893. utils.ErrorLog("解析失败:%v", err)
  9894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9895. return
  9896. }
  9897. if res2.Infcode == 0 {
  9898. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9899. if err == gorm.ErrRecordNotFound {
  9900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9901. return
  9902. } else if err != nil {
  9903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9904. return
  9905. } else {
  9906. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9907. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9908. infoStr := string(Iinfos)
  9909. idetinfoStr := string(Idetinfos)
  9910. var rf []*ResultFive
  9911. json.Unmarshal([]byte(infoStr), &rf)
  9912. var insutypes []*ResultFive
  9913. var insutype string
  9914. var is390 int = 0
  9915. var is310 int = 0
  9916. //var insuplc_admdvs string
  9917. for _, item := range rf {
  9918. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9919. insutypes = append(insutypes, item)
  9920. }
  9921. }
  9922. if len(insutypes) == 1 {
  9923. insutype = insutypes[0].Insutype
  9924. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9925. } else {
  9926. for _, i := range insutypes {
  9927. if i.Insutype == "390" {
  9928. is390 = 1
  9929. }
  9930. if i.Insutype == "310" {
  9931. is310 = 1
  9932. }
  9933. }
  9934. }
  9935. if is390 == 1 {
  9936. insutype = "390"
  9937. }
  9938. if is310 == 1 {
  9939. insutype = "310"
  9940. }
  9941. if len(insutypes) == 0 {
  9942. insutype = "310"
  9943. }
  9944. psn := &models.HisPsn{
  9945. PsnNo: res2.Output.Baseinfo.PsnNo,
  9946. PatientId: patient.ID,
  9947. Certno: res2.Output.Baseinfo.Certno,
  9948. Gend: res2.Output.Baseinfo.Gend,
  9949. Naty: res2.Output.Baseinfo.Naty,
  9950. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9951. PsnName: res2.Output.Baseinfo.PsnName,
  9952. Idetinfo: idetinfoStr,
  9953. Insuinfo: infoStr,
  9954. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9955. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9956. VerifyNumber: res.Output.EcToken,
  9957. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9958. }
  9959. service.CreateHisPsn(psn)
  9960. c.ServeSuccessJSON(map[string]interface{}{
  9961. "patient": patient,
  9962. "number": res.Output.CardNo,
  9963. "insutype": insutype,
  9964. })
  9965. }
  9966. } else {
  9967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9968. return
  9969. }
  9970. } else {
  9971. c.ServeSuccessJSON(map[string]interface{}{
  9972. "failed_code": -10,
  9973. "msg": res.ErrMsg,
  9974. })
  9975. }
  9976. } else {
  9977. //if initFlag == 0 {
  9978. // c.TestGetBasBaseInit()
  9979. //}
  9980. //token := c.GetEleBaseInfo()
  9981. //token = Remove0000(token)
  9982. type ELeData struct {
  9983. Code string `json:"code"`
  9984. Data struct {
  9985. Aac002 string `json:"aac002"`
  9986. Aaz500 string `json:"aaz500"`
  9987. ActCardNo string `json:"actCardNo"`
  9988. Bab520 string `json:"bab520"`
  9989. Bkz543 string `json:"bkz543"`
  9990. BusinessType string `json:"businessType"`
  9991. CertfCodg string `json:"certfCodg"`
  9992. EcIndexNo string `json:"ecIndexNo"`
  9993. EcToken string `json:"ecToken"`
  9994. ID0000 string `json:"id0000"`
  9995. IDNo string `json:"idNo"`
  9996. IDType string `json:"idType"`
  9997. Idcode string `json:"idcode"`
  9998. IdentityToken string `json:"identity_token"`
  9999. InsuOrg string `json:"insuOrg"`
  10000. OfficeID string `json:"officeId"`
  10001. OfficeName string `json:"officeName"`
  10002. OperatorID string `json:"operatorId"`
  10003. OperatorName string `json:"operatorName"`
  10004. OrgID string `json:"orgId"`
  10005. UserName string `json:"userName"`
  10006. } `json:"data"`
  10007. Infno interface{} `json:"infno"`
  10008. Message string `json:"message"`
  10009. OrgID string `json:"orgId"`
  10010. TransType string `json:"transType"`
  10011. }
  10012. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10013. fmt.Println(result)
  10014. outPutInfo := Remove0000(result)
  10015. fmt.Println(outPutInfo)
  10016. var ele ELeData
  10017. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10018. if err != nil {
  10019. utils.ErrorLog("解析失败:%v", err)
  10020. }
  10021. token := ele.Data.EcToken
  10022. var result2 string
  10023. var requestLog2 string
  10024. if len(token) > 0 {
  10025. if strings.Contains(ele.Data.IDNo, "HKG") {
  10026. 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)
  10027. } else {
  10028. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  10029. }
  10030. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10031. var res ResultTwo
  10032. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10033. utils.ErrorLog("解析失败:%v", err)
  10034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10035. return
  10036. }
  10037. if res.Infcode == 0 {
  10038. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10039. if err == gorm.ErrRecordNotFound {
  10040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10041. return
  10042. } else if err != nil {
  10043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10044. return
  10045. } else {
  10046. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10047. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10048. infoStr := string(Iinfos)
  10049. idetinfoStr := string(Idetinfos)
  10050. psn := &models.HisPsn{
  10051. PsnNo: res.Output.Baseinfo.PsnNo,
  10052. PatientId: patient.ID,
  10053. Certno: res.Output.Baseinfo.Certno,
  10054. Gend: res.Output.Baseinfo.Gend,
  10055. Naty: res.Output.Baseinfo.Naty,
  10056. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10057. PsnName: res.Output.Baseinfo.PsnName,
  10058. Idetinfo: idetinfoStr,
  10059. Insuinfo: infoStr,
  10060. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10061. CardInfo: "",
  10062. VerifyNumber: token,
  10063. }
  10064. service.CreateHisPsn(psn)
  10065. c.ServeSuccessJSON(map[string]interface{}{
  10066. "msg": "读取成功",
  10067. })
  10068. }
  10069. } else {
  10070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10071. return
  10072. }
  10073. } else {
  10074. c.ServeSuccessJSON(map[string]interface{}{
  10075. "failed_code": -10,
  10076. "msg": "读取失败",
  10077. })
  10078. }
  10079. }
  10080. }
  10081. func (c *HisApiController) ReadEleFace() {
  10082. admin_user_id, _ := c.GetInt64("admin_user_id")
  10083. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10084. adminUser := c.GetAdminUserInfo()
  10085. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10086. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10087. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10088. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10089. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10090. if len(tokens) > 0 {
  10091. c.ServeSuccessJSON(map[string]interface{}{
  10092. "msg": "读取成功",
  10093. })
  10094. } else {
  10095. c.ServeSuccessJSON(map[string]interface{}{
  10096. "failed_code": -10,
  10097. "msg": "读取失败",
  10098. })
  10099. }
  10100. }
  10101. }
  10102. func (c *HisApiController) Get9001() {
  10103. adminUser := c.GetAdminUserInfo()
  10104. admin_user_id, _ := c.GetInt64("admin_user_id")
  10105. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10106. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10107. if miConfig.MdtrtareaAdmvs == "350500" {
  10108. service.GetFjAuthorizationInfo(miConfig.Code)
  10109. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10110. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10111. var dat map[string]interface{}
  10112. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10113. fmt.Println(dat)
  10114. } else {
  10115. fmt.Println(err)
  10116. }
  10117. userJSONBytes, _ := json.Marshal(dat)
  10118. var res models.Result9001
  10119. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10120. utils.ErrorLog("解析失败:%v", err)
  10121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10122. return
  10123. }
  10124. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10125. fmt.Println(miConfig.SecretKey)
  10126. var res models.Result9001Two
  10127. 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 +
  10128. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10129. resp, requestErr := http.Get(api)
  10130. if requestErr != nil {
  10131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10132. return
  10133. }
  10134. body, ioErr := ioutil.ReadAll(resp.Body)
  10135. if ioErr != nil {
  10136. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10138. return
  10139. }
  10140. var respJSON map[string]interface{}
  10141. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10142. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10144. return
  10145. }
  10146. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10147. if status == "0" {
  10148. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10149. c.ServeSuccessJSON(map[string]interface{}{
  10150. "failed_code": -10,
  10151. "msg": err_msg,
  10152. })
  10153. return
  10154. }
  10155. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10156. result, _ := json.Marshal(respJSON)
  10157. fmt.Println("log")
  10158. fmt.Println(string(result))
  10159. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10160. utils.ErrorLog("解析失败:%v", err)
  10161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10162. return
  10163. }
  10164. if res.Infcode == 0 {
  10165. sign := models.HisSignIn{
  10166. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10167. SignNo: res.Output.Signinoutb.SignNo,
  10168. SignTime: "",
  10169. Ctime: time.Now().Unix(),
  10170. Mtime: time.Now().Unix(),
  10171. Status: 1,
  10172. InputLog: "",
  10173. OutputLog: "",
  10174. FixmedinsCode: miConfig.Code,
  10175. }
  10176. err := service.CreateSignIn(&sign)
  10177. if err == nil {
  10178. c.ServeSuccessJSON(map[string]interface{}{
  10179. "msg": "签到成功",
  10180. })
  10181. }
  10182. } else {
  10183. c.ServeSuccessJSON(map[string]interface{}{
  10184. "failed_code": -10,
  10185. "msg": res.ErrMsg,
  10186. })
  10187. return
  10188. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10189. //return
  10190. }
  10191. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10192. fmt.Println(miConfig.SecretKey)
  10193. var res models.Result9001Two
  10194. 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 +
  10195. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10196. resp, requestErr := http.Get(api)
  10197. if requestErr != nil {
  10198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10199. return
  10200. }
  10201. body, ioErr := ioutil.ReadAll(resp.Body)
  10202. if ioErr != nil {
  10203. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10205. return
  10206. }
  10207. var respJSON map[string]interface{}
  10208. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10209. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10211. return
  10212. }
  10213. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10214. if status == "0" {
  10215. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10216. c.ServeSuccessJSON(map[string]interface{}{
  10217. "failed_code": -10,
  10218. "msg": err_msg,
  10219. })
  10220. return
  10221. }
  10222. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10223. result, _ := json.Marshal(respJSON)
  10224. fmt.Println("log")
  10225. fmt.Println(string(result))
  10226. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10227. utils.ErrorLog("解析失败:%v", err)
  10228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10229. return
  10230. }
  10231. if res.Infcode == 0 {
  10232. sign := models.HisSignIn{
  10233. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10234. SignNo: res.Output.Signinoutb.SignNo,
  10235. SignTime: "",
  10236. Ctime: time.Now().Unix(),
  10237. Mtime: time.Now().Unix(),
  10238. Status: 1,
  10239. InputLog: "",
  10240. OutputLog: "",
  10241. FixmedinsCode: miConfig.Code,
  10242. }
  10243. err := service.CreateSignIn(&sign)
  10244. if err == nil {
  10245. c.ServeSuccessJSON(map[string]interface{}{
  10246. "msg": "签到成功",
  10247. })
  10248. }
  10249. } else {
  10250. c.ServeSuccessJSON(map[string]interface{}{
  10251. "failed_code": -10,
  10252. "msg": res.ErrMsg,
  10253. })
  10254. return
  10255. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10256. //return
  10257. }
  10258. } else {
  10259. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  10260. var dat map[string]interface{}
  10261. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10262. fmt.Println(dat)
  10263. } else {
  10264. fmt.Println(err)
  10265. }
  10266. userJSONBytes, _ := json.Marshal(dat)
  10267. var res models.Result9001
  10268. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10269. utils.ErrorLog("解析失败:%v", err)
  10270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10271. return
  10272. }
  10273. if res.Infcode == 0 {
  10274. sign := models.HisSignIn{
  10275. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10276. SignNo: res.Output.Signinoutb.SignNo,
  10277. SignTime: res.Output.Signinoutb.SignTime,
  10278. Ctime: time.Now().Unix(),
  10279. Mtime: time.Now().Unix(),
  10280. Status: 1,
  10281. InputLog: "",
  10282. OutputLog: "",
  10283. FixmedinsCode: miConfig.Code,
  10284. }
  10285. err := service.CreateSignIn(&sign)
  10286. if err == nil {
  10287. c.ServeSuccessJSON(map[string]interface{}{
  10288. "msg": "签到成功",
  10289. })
  10290. }
  10291. }
  10292. }
  10293. }
  10294. 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) {
  10295. var res Result3101
  10296. adminUser := c.GetAdminUserInfo()
  10297. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10298. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10299. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10300. //record_time := c.GetString("record_time")
  10301. //trig_scen := c.GetString("trig_scen")
  10302. timeLayout := "2006-01-02"
  10303. loc, _ := time.LoadLocation("Local")
  10304. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10305. if err != nil {
  10306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10307. return res
  10308. }
  10309. recordDateTime := theTime.Unix()
  10310. var patientPrescription models.HisPrescriptionInfo
  10311. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10312. //if patientPrescription.ID == 0 {
  10313. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10314. //}
  10315. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10316. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10317. //
  10318. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10319. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10320. var pp models.PublicParams
  10321. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10322. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10323. pp.FixmedinsName = miConfig.OrgName
  10324. pp.FixmedinsCode = miConfig.Code
  10325. pp.RequestUrl = miConfig.Url
  10326. pp.Cainfo = miConfig.Cainfo
  10327. pp.SecretKey = miConfig.SecretKey
  10328. pp.AccessKey = miConfig.AccessKey
  10329. pp.OpterName = roles.UserName
  10330. var config []*models.HisXtDiagnoseConfig
  10331. for _, item := range diagnosis_ids {
  10332. id, _ := strconv.ParseInt(item, 10, 64)
  10333. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10334. config = append(config, &diagnosisConfig)
  10335. }
  10336. var pd models.PatientDtos
  10337. pd.PatnID = his.PsnNo
  10338. pd.PatnName = his.Name
  10339. pd.Gend = his.Gend
  10340. pd.Brdy = his.Brdy
  10341. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10342. pd.CurrMdtrtID = his.Number
  10343. var fed models.FsiEncounterDtos
  10344. fed.MdtrtID = his.Number
  10345. fed.MedinsID = miConfig.Code
  10346. fed.MedinsName = miConfig.OrgName
  10347. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10348. fed.MedMdtrtType = "1"
  10349. fed.MedinsType = "1"
  10350. fed.MedinsLv = "11"
  10351. tm := time.Unix(his.RecordDate, 0)
  10352. s_tm := tm.Format("2006-01-02 15:04:05")
  10353. fed.AdmDate = s_tm
  10354. fed.DscgDate = s_tm
  10355. fed.DscgMainDiseCodg = config[0].CountryCode
  10356. fed.DscgMainDiseName = config[0].CountryContentName
  10357. //诊断信息
  10358. var fdds []*models.FsiDiagnoseDtos
  10359. for index, item := range config {
  10360. if index == 0 {
  10361. var fdd models.FsiDiagnoseDtos
  10362. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10363. fdd.InoutDiseType = "1"
  10364. fdd.MaindiseFlag = "1"
  10365. fdd.DiseDate = s_tm
  10366. fdd.DiasSrtNo = "1"
  10367. fdd.DiseName = item.CountryContentName
  10368. fdd.DiseCodg = item.CountryCode
  10369. fdds = append(fdds, &fdd)
  10370. } else {
  10371. var fdd models.FsiDiagnoseDtos
  10372. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10373. fdd.InoutDiseType = "1"
  10374. fdd.MaindiseFlag = "1"
  10375. fdd.DiseDate = s_tm
  10376. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10377. fdd.DiseName = item.CountryContentName
  10378. fdd.DiseCodg = item.CountryCode
  10379. fdds = append(fdds, &fdd)
  10380. }
  10381. }
  10382. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10383. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  10384. fed.AdmDeptName = de.Name
  10385. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  10386. fed.DscgDeptName = de.Name
  10387. fed.MedMdtrtType = "1"
  10388. fed.MedType = "11"
  10389. //if his.Insutype == "390" {
  10390. // fed.MedType = "1402"
  10391. //} else {
  10392. // fed.MedType = "9933"
  10393. //}
  10394. var orders []*models.FsiOrderDtos
  10395. if trig_scen == "2" {
  10396. //处方医嘱信息
  10397. for _, item := range prescriptions {
  10398. for _, subItem := range item.HisDoctorAdviceInfo {
  10399. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10400. var order models.FsiOrderDtos
  10401. order.RxID = strconv.FormatInt(item.ID, 10)
  10402. order.Rxno = strconv.FormatInt(item.ID, 10)
  10403. order.LongDrordFlag = "0"
  10404. order.HilistType = "1"
  10405. order.ChrgType = "1"
  10406. order.DrordBhvr = "-"
  10407. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10408. order.HosplistName = subItem.BaseDrugLib.DrugName
  10409. order.HilistLv = "1"
  10410. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10411. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10412. order.HosplistName = subItem.BaseDrugLib.DrugName
  10413. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10414. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10415. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10416. order.OwnpayAmt = ""
  10417. order.SelfpayAmt = ""
  10418. order.Spec = ""
  10419. order.SpecUnt = ""
  10420. order.DrordBegnDate = s_tm
  10421. order.DrordStopDate = ""
  10422. order.DrordDrCodg = doctor_info.DoctorNumber
  10423. order.DrordDeptName = department.Name
  10424. order.DrordDeptCodg = department.Number
  10425. order.DrordDrName = doctor_info.UserName
  10426. order.DrordDrProfttl = "234"
  10427. order.CurrDrordFlag = "1"
  10428. orders = append(orders, &order)
  10429. }
  10430. }
  10431. for _, subItem := range item.HisPrescriptionProject {
  10432. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10433. var order models.FsiOrderDtos
  10434. order.RxID = strconv.FormatInt(item.ID, 10)
  10435. order.Rxno = strconv.FormatInt(item.ID, 10)
  10436. order.LongDrordFlag = "0"
  10437. order.HilistType = "1"
  10438. order.ChrgType = "1"
  10439. order.DrordBhvr = "-"
  10440. order.HilistCode = subItem.HisProject.MedicalCode
  10441. order.HosplistName = subItem.HisProject.ProjectName
  10442. order.HilistLv = "1"
  10443. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10444. order.HosplistCode = subItem.HisProject.MedicalCode
  10445. order.HosplistName = subItem.HisProject.ProjectName
  10446. order.Cnt = subItem.Count
  10447. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10448. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10449. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10450. order.OwnpayAmt = ""
  10451. order.SelfpayAmt = ""
  10452. order.Spec = ""
  10453. order.SpecUnt = ""
  10454. order.DrordBegnDate = s_tm
  10455. order.DrordStopDate = ""
  10456. order.DrordDrCodg = doctor_info.DoctorNumber
  10457. order.DrordDeptName = department.Name
  10458. order.DrordDeptCodg = department.Number
  10459. order.DrordDrName = doctor_info.UserName
  10460. order.DrordDrProfttl = "234"
  10461. order.CurrDrordFlag = "1"
  10462. orders = append(orders, &order)
  10463. }
  10464. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10465. var order models.FsiOrderDtos
  10466. order.RxID = strconv.FormatInt(item.ID, 10)
  10467. order.Rxno = strconv.FormatInt(item.ID, 10)
  10468. order.LongDrordFlag = "0"
  10469. order.HilistType = "1"
  10470. order.ChrgType = "1"
  10471. order.DrordBhvr = "-"
  10472. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10473. order.HosplistName = subItem.GoodInfo.GoodName
  10474. order.HilistLv = "1"
  10475. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10476. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10477. order.HosplistName = subItem.GoodInfo.GoodName
  10478. order.Cnt = subItem.Count
  10479. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10480. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10481. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10482. order.OwnpayAmt = ""
  10483. order.SelfpayAmt = ""
  10484. order.Spec = ""
  10485. order.SpecUnt = ""
  10486. order.DrordBegnDate = s_tm
  10487. order.DrordStopDate = ""
  10488. order.DrordDrCodg = doctor_info.DoctorNumber
  10489. order.DrordDeptName = department.Name
  10490. order.DrordDeptCodg = department.Number
  10491. order.DrordDrName = doctor_info.UserName
  10492. order.DrordDrProfttl = "234"
  10493. order.CurrDrordFlag = "1"
  10494. orders = append(orders, &order)
  10495. }
  10496. }
  10497. }
  10498. //处方医嘱信息
  10499. }
  10500. fed.MatnStas = "0"
  10501. fed.MedfeeSumamt = "0"
  10502. fed.OwnpayAmt = "0"
  10503. fed.SelfpayAmt = "0"
  10504. fed.AcctPayamt = "0"
  10505. fed.MaAmt = "0"
  10506. fed.HifpPayamt = "0"
  10507. fed.SetlTotlnum = "1"
  10508. fed.Insutype = his.Insutype
  10509. fed.ReimFlag = "0"
  10510. fed.OutSetlFlag = "0"
  10511. var fopd []*models.FsiOperationDtosData
  10512. data := make(map[string]interface{})
  10513. data["fed"] = fed
  10514. data["fdd"] = fdds
  10515. data["fod"] = orders
  10516. data["pd"] = pd
  10517. data["pp"] = pp
  10518. data["fopd"] = fopd
  10519. data["trig_scen"] = trig_scen
  10520. fmt.Println(data)
  10521. fmt.Println(fed)
  10522. fmt.Println(fdds)
  10523. fmt.Println(orders)
  10524. fmt.Println(pd)
  10525. fmt.Println(pp)
  10526. fmt.Println(fopd)
  10527. client := &http.Client{}
  10528. bytesData, _ := json.Marshal(data)
  10529. var req *http.Request
  10530. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10531. if miConfig.MdtrtareaAdmvs == "320921" {
  10532. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10533. } else {
  10534. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10535. }
  10536. resp, _ := client.Do(req)
  10537. defer resp.Body.Close()
  10538. body, ioErr := ioutil.ReadAll(resp.Body)
  10539. if ioErr != nil {
  10540. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10542. return res
  10543. }
  10544. var respJSON map[string]interface{}
  10545. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10548. return res
  10549. }
  10550. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10551. fmt.Println(respJSON)
  10552. result, _ := json.Marshal(respJSON)
  10553. fmt.Println(result)
  10554. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10555. utils.ErrorLog("解析失败:%v", err)
  10556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10557. return res
  10558. }
  10559. return res
  10560. } else {
  10561. //if miConfig.MdtrtareaAdmvs == "441202" {
  10562. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10563. saveLog(output, input, "3101", "事前")
  10564. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10565. utils.ErrorLog("解析失败:%v", err)
  10566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10567. return
  10568. }
  10569. return res
  10570. //}
  10571. }
  10572. }
  10573. 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) {
  10574. adminUser := c.GetAdminUserInfo()
  10575. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10576. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10577. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10578. //record_time := c.GetString("record_time")
  10579. //trig_scen := c.GetString("trig_scen")
  10580. timeLayout := "2006-01-02"
  10581. loc, _ := time.LoadLocation("Local")
  10582. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10583. if err != nil {
  10584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10585. return res
  10586. }
  10587. recordDateTime := theTime.Unix()
  10588. var patientPrescription models.HisPrescriptionInfo
  10589. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10590. if patientPrescription.ID == 0 {
  10591. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10592. }
  10593. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10594. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10595. //
  10596. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10597. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10598. var pp models.PublicParams
  10599. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10600. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10601. pp.FixmedinsName = miConfig.OrgName
  10602. pp.FixmedinsCode = miConfig.Code
  10603. pp.RequestUrl = miConfig.Url
  10604. pp.Cainfo = miConfig.Cainfo
  10605. pp.SecretKey = miConfig.SecretKey
  10606. pp.AccessKey = miConfig.AccessKey
  10607. pp.OpterName = roles.UserName
  10608. var config []*models.HisXtDiagnoseConfig
  10609. for _, item := range diagnosis_ids {
  10610. id, _ := strconv.ParseInt(item, 10, 64)
  10611. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10612. config = append(config, &diagnosisConfig)
  10613. }
  10614. var pd models.PatientDtos
  10615. pd.PatnID = his.PsnNo
  10616. pd.PatnName = his.Name
  10617. pd.Gend = his.Gend
  10618. pd.Brdy = his.Brdy
  10619. pd.Poolarea = his.InsuplcAdmdvs
  10620. pd.CurrMdtrtID = his.Number
  10621. var fed models.FsiEncounterDtos
  10622. fed.MdtrtID = his.Number
  10623. fed.MedinsID = miConfig.Code
  10624. fed.MedinsName = miConfig.OrgName
  10625. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10626. fed.MedMdtrtType = "1"
  10627. fed.MedinsType = "1"
  10628. fed.MedinsLv = "11"
  10629. tm := time.Unix(his.RecordDate, 0)
  10630. s_tm := tm.Format("2006-01-02 15:04:05")
  10631. fed.AdmDate = s_tm
  10632. fed.DscgDate = s_tm
  10633. fed.DscgMainDiseCodg = config[0].CountryCode
  10634. fed.DscgMainDiseName = config[0].CountryContentName
  10635. //诊断信息
  10636. var fdds []*models.FsiDiagnoseDtos
  10637. for index, item := range config {
  10638. if index == 0 {
  10639. var fdd models.FsiDiagnoseDtos
  10640. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10641. fdd.InoutDiseType = "1"
  10642. fdd.MaindiseFlag = "1"
  10643. fdd.DiseDate = s_tm
  10644. fdd.DiasSrtNo = "1"
  10645. fdd.DiseName = item.CountryContentName
  10646. fdd.DiseCodg = item.CountryCode
  10647. fdds = append(fdds, &fdd)
  10648. } else {
  10649. var fdd models.FsiDiagnoseDtos
  10650. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10651. fdd.InoutDiseType = "1"
  10652. fdd.MaindiseFlag = "1"
  10653. fdd.DiseDate = s_tm
  10654. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10655. fdd.DiseName = item.CountryContentName
  10656. fdd.DiseCodg = item.CountryCode
  10657. fdds = append(fdds, &fdd)
  10658. }
  10659. }
  10660. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10661. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10662. fed.AdmDeptName = department.Name
  10663. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10664. fed.DscgDeptName = department.Name
  10665. fed.MedMdtrtType = "1"
  10666. fed.MedType = "11"
  10667. //if his.Insutype == "390" {
  10668. // fed.MedType = "1402"
  10669. //} else {
  10670. // fed.MedType = "9933"
  10671. //}
  10672. var orders []*models.FsiOrderDtos
  10673. if trig_scen == "2" {
  10674. //处方医嘱信息
  10675. for _, item := range prescriptions {
  10676. for _, subItem := range item.HisDoctorAdviceInfo {
  10677. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10678. var order models.FsiOrderDtos
  10679. order.RxID = strconv.FormatInt(item.ID, 10)
  10680. order.Rxno = strconv.FormatInt(item.ID, 10)
  10681. order.LongDrordFlag = "0"
  10682. order.HilistType = "1"
  10683. order.ChrgType = "1"
  10684. order.DrordBhvr = "-"
  10685. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10686. order.HosplistName = subItem.BaseDrugLib.DrugName
  10687. order.HilistLv = "1"
  10688. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10689. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10690. order.HosplistName = subItem.BaseDrugLib.DrugName
  10691. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10692. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10693. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10694. order.OwnpayAmt = ""
  10695. order.SelfpayAmt = ""
  10696. order.Spec = ""
  10697. order.SpecUnt = ""
  10698. order.DrordBegnDate = s_tm
  10699. order.DrordStopDate = ""
  10700. order.DrordDrCodg = doctor_info.DoctorNumber
  10701. order.DrordDeptName = department.Name
  10702. order.DrordDeptCodg = department.Number
  10703. order.DrordDrName = doctor_info.UserName
  10704. order.DrordDrProfttl = "234"
  10705. order.CurrDrordFlag = "1"
  10706. orders = append(orders, &order)
  10707. }
  10708. }
  10709. for _, subItem := range item.HisPrescriptionProject {
  10710. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10711. var order models.FsiOrderDtos
  10712. order.RxID = strconv.FormatInt(item.ID, 10)
  10713. order.Rxno = strconv.FormatInt(item.ID, 10)
  10714. order.LongDrordFlag = "0"
  10715. order.HilistType = "1"
  10716. order.ChrgType = "1"
  10717. order.DrordBhvr = "-"
  10718. order.HilistCode = subItem.HisProject.MedicalCode
  10719. order.HosplistName = subItem.HisProject.ProjectName
  10720. order.HilistLv = "1"
  10721. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10722. order.HosplistCode = subItem.HisProject.MedicalCode
  10723. order.HosplistName = subItem.HisProject.ProjectName
  10724. order.Cnt = subItem.Count
  10725. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10726. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10727. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10728. order.OwnpayAmt = ""
  10729. order.SelfpayAmt = ""
  10730. order.Spec = ""
  10731. order.SpecUnt = ""
  10732. order.DrordBegnDate = s_tm
  10733. order.DrordStopDate = ""
  10734. order.DrordDrCodg = doctor_info.DoctorNumber
  10735. order.DrordDeptName = department.Name
  10736. order.DrordDeptCodg = department.Number
  10737. order.DrordDrName = doctor_info.UserName
  10738. order.DrordDrProfttl = "234"
  10739. order.CurrDrordFlag = "1"
  10740. orders = append(orders, &order)
  10741. }
  10742. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10743. var order models.FsiOrderDtos
  10744. order.RxID = strconv.FormatInt(item.ID, 10)
  10745. order.Rxno = strconv.FormatInt(item.ID, 10)
  10746. order.LongDrordFlag = "0"
  10747. order.HilistType = "1"
  10748. order.ChrgType = "1"
  10749. order.DrordBhvr = "-"
  10750. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10751. order.HosplistName = subItem.GoodInfo.GoodName
  10752. order.HilistLv = "1"
  10753. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10754. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10755. order.HosplistName = subItem.GoodInfo.GoodName
  10756. order.Cnt = subItem.Count
  10757. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10758. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10759. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10760. order.OwnpayAmt = ""
  10761. order.SelfpayAmt = ""
  10762. order.Spec = ""
  10763. order.SpecUnt = ""
  10764. order.DrordBegnDate = s_tm
  10765. order.DrordStopDate = ""
  10766. order.DrordDrCodg = doctor_info.DoctorNumber
  10767. order.DrordDeptName = department.Name
  10768. order.DrordDeptCodg = department.Number
  10769. order.DrordDrName = doctor_info.UserName
  10770. order.DrordDrProfttl = "234"
  10771. order.CurrDrordFlag = "1"
  10772. orders = append(orders, &order)
  10773. }
  10774. }
  10775. }
  10776. //处方医嘱信息
  10777. }
  10778. fed.MatnStas = "0"
  10779. fed.MedfeeSumamt = "0"
  10780. fed.OwnpayAmt = "0"
  10781. fed.SelfpayAmt = "0"
  10782. fed.AcctPayamt = "0"
  10783. fed.MaAmt = "0"
  10784. fed.HifpPayamt = "0"
  10785. fed.SetlTotlnum = "1"
  10786. fed.Insutype = his.Insutype
  10787. fed.ReimFlag = "0"
  10788. fed.OutSetlFlag = "0"
  10789. var fopd []*models.FsiOperationDtosData
  10790. data := make(map[string]interface{})
  10791. data["fed"] = fed
  10792. data["fdd"] = fdds
  10793. data["fod"] = orders
  10794. data["pd"] = pd
  10795. data["pp"] = pp
  10796. data["fopd"] = fopd
  10797. data["trig_scen"] = trig_scen
  10798. fmt.Println(data)
  10799. fmt.Println(fed)
  10800. fmt.Println(fdds)
  10801. fmt.Println(orders)
  10802. fmt.Println(pd)
  10803. fmt.Println(pp)
  10804. fmt.Println(fopd)
  10805. client := &http.Client{}
  10806. bytesData, _ := json.Marshal(data)
  10807. var req *http.Request
  10808. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10809. if miConfig.MdtrtareaAdmvs == "320921" {
  10810. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10811. } else {
  10812. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10813. }
  10814. resp, _ := client.Do(req)
  10815. defer resp.Body.Close()
  10816. body, ioErr := ioutil.ReadAll(resp.Body)
  10817. if ioErr != nil {
  10818. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10820. return res
  10821. }
  10822. var respJSON map[string]interface{}
  10823. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10826. return res
  10827. }
  10828. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10829. fmt.Println(respJSON)
  10830. result, _ := json.Marshal(respJSON)
  10831. fmt.Println(result)
  10832. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10833. utils.ErrorLog("解析失败:%v", err)
  10834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10835. return res
  10836. }
  10837. return res
  10838. } else {
  10839. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10840. saveLog(output, input, "3101", "事前")
  10841. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10842. utils.ErrorLog("解析失败:%v", err)
  10843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10844. return
  10845. }
  10846. return res
  10847. }
  10848. return res
  10849. }
  10850. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  10851. ////patient_id, _ := c.GetInt64("patient_id")
  10852. //order_id, _ := c.GetInt64("order_id")
  10853. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  10854. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  10855. //trig_scen := c.GetString("trig_scen")
  10856. adminUser := c.GetAdminUserInfo()
  10857. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10858. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10859. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10860. record_time := c.GetString("record_time")
  10861. order, _ := service.GetHisOrderByID(order_id)
  10862. psn_info, _ := service.GetPsnByPatientId(patient_id)
  10863. timeLayout := "2006-01-02"
  10864. loc, _ := time.LoadLocation("Local")
  10865. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10866. if err != nil {
  10867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10868. return
  10869. }
  10870. recordDateTime := theTime.Unix()
  10871. var patientPrescription models.HisPrescriptionInfo
  10872. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10873. if patientPrescription.ID == 0 {
  10874. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10875. }
  10876. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10877. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10878. //
  10879. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  10880. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10881. var pp models.PublicParams
  10882. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10883. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10884. pp.FixmedinsName = miConfig.OrgName
  10885. pp.FixmedinsCode = miConfig.Code
  10886. pp.RequestUrl = miConfig.Url
  10887. pp.Cainfo = miConfig.Cainfo
  10888. pp.SecretKey = miConfig.SecretKey
  10889. pp.AccessKey = miConfig.AccessKey
  10890. pp.OpterName = roles.UserName
  10891. var config []*models.HisXtDiagnoseConfig
  10892. for _, item := range diagnosis_ids {
  10893. id, _ := strconv.ParseInt(item, 10, 64)
  10894. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10895. config = append(config, &diagnosisConfig)
  10896. }
  10897. var pd models.PatientDtos
  10898. pd.PatnID = his.PsnNo
  10899. pd.PatnName = his.Name
  10900. pd.Gend = his.Gend
  10901. pd.Brdy = psn_info.Brdy
  10902. pd.Poolarea = his.InsuplcAdmdvs
  10903. pd.CurrMdtrtID = his.Number
  10904. var fed models.FsiEncounterDtos
  10905. fed.MdtrtID = his.Number
  10906. fed.MedinsID = miConfig.Code
  10907. fed.MedinsName = miConfig.OrgName
  10908. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10909. fed.MedMdtrtType = "1"
  10910. fed.MedinsType = "1"
  10911. fed.MedinsLv = "11"
  10912. tm := time.Unix(his.RecordDate, 0)
  10913. s_tm := tm.Format("2006-01-02 15:04:05")
  10914. fed.AdmDate = s_tm
  10915. fed.DscgDate = s_tm
  10916. fed.DscgMainDiseCodg = config[0].CountryCode
  10917. fed.DscgMainDiseName = config[0].CountryContentName
  10918. //诊断信息
  10919. var fdds []*models.FsiDiagnoseDtos
  10920. for index, item := range config {
  10921. if index == 0 {
  10922. var fdd models.FsiDiagnoseDtos
  10923. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10924. fdd.InoutDiseType = "1"
  10925. fdd.MaindiseFlag = "1"
  10926. fdd.DiseDate = s_tm
  10927. fdd.DiasSrtNo = "1"
  10928. fdd.DiseName = item.CountryContentName
  10929. fdd.DiseCodg = item.CountryCode
  10930. fdds = append(fdds, &fdd)
  10931. } else {
  10932. var fdd models.FsiDiagnoseDtos
  10933. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10934. fdd.InoutDiseType = "1"
  10935. fdd.MaindiseFlag = "1"
  10936. fdd.DiseDate = s_tm
  10937. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10938. fdd.DiseName = item.CountryContentName
  10939. fdd.DiseCodg = item.CountryCode
  10940. fdds = append(fdds, &fdd)
  10941. }
  10942. }
  10943. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10944. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10945. fed.AdmDeptName = department.Name
  10946. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10947. fed.DscgDeptName = department.Name
  10948. fed.MedType = order.MedType
  10949. //处方医嘱信息
  10950. var orders []*models.FsiOrderDtos
  10951. //for _, item := range prescriptions {
  10952. // for _, subItem := range item.HisDoctorAdviceInfo {
  10953. // var order models.FsiOrderDtos
  10954. // order.RxID = strconv.FormatInt(item.ID, 10)
  10955. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10956. // order.LongDrordFlag = "0"
  10957. // order.HilistType = "1"
  10958. // order.ChrgType = "1"
  10959. // order.DrordBhvr = "-"
  10960. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10961. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10962. // order.HilistLv = "1"
  10963. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10964. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10965. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10966. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  10967. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10968. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  10969. // order.OwnpayAmt = ""
  10970. // order.SelfpayAmt = ""
  10971. // order.Spec = ""
  10972. // order.SpecUnt = ""
  10973. // order.DrordBegnDate = s_tm
  10974. // order.DrordStopDate = ""
  10975. // order.DrordDrCodg = "1"
  10976. // order.DrordDeptName = department.Name
  10977. // order.DrordDrCodg = "1"
  10978. // order.DrordDrName = doctor_info.UserName
  10979. // order.DrordDrProfttl = ""
  10980. // order.CurrDrordFlag = "1"
  10981. // orders = append(orders, &order)
  10982. // }
  10983. // for _, subItem := range item.HisPrescriptionProject {
  10984. // if subItem.Type == 2 {
  10985. // var order models.FsiOrderDtos
  10986. // order.RxID = strconv.FormatInt(item.ID, 10)
  10987. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10988. // order.LongDrordFlag = "0"
  10989. // order.HilistType = "1"
  10990. // order.ChrgType = "1"
  10991. // order.DrordBhvr = "-"
  10992. // order.HilistCode = subItem.HisProject.MedicalCode
  10993. // order.HosplistName = subItem.HisProject.ProjectName
  10994. // order.HilistLv = "1"
  10995. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10996. // order.HosplistCode = subItem.HisProject.MedicalCode
  10997. // order.HosplistName = subItem.HisProject.ProjectName
  10998. // order.Cnt = subItem.Count
  10999. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11000. //
  11001. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11002. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11003. // order.OwnpayAmt = ""
  11004. // order.SelfpayAmt = ""
  11005. // order.Spec = ""
  11006. // order.SpecUnt = ""
  11007. // order.DrordBegnDate = s_tm
  11008. // order.DrordStopDate = ""
  11009. // order.DrordDrCodg = "1"
  11010. // order.DrordDeptName = department.Name
  11011. // order.DrordDrCodg = "1"
  11012. // order.DrordDrName = doctor_info.UserName
  11013. // order.DrordDrProfttl = ""
  11014. // order.CurrDrordFlag = "1"
  11015. // orders = append(orders, &order)
  11016. //
  11017. // }
  11018. // if subItem.Type == 3 {
  11019. //
  11020. // var order models.FsiOrderDtos
  11021. // order.RxID = strconv.FormatInt(item.ID, 10)
  11022. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11023. // order.LongDrordFlag = "0"
  11024. // order.HilistType = "1"
  11025. // order.ChrgType = "1"
  11026. // order.DrordBhvr = "-"
  11027. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11028. // order.HosplistName = subItem.GoodInfo.GoodName
  11029. // order.HilistLv = "1"
  11030. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11031. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11032. // order.HosplistName = subItem.GoodInfo.GoodName
  11033. // order.Cnt = subItem.Count
  11034. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11035. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11036. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11037. // order.OwnpayAmt = ""
  11038. // order.SelfpayAmt = ""
  11039. // order.Spec = ""
  11040. // order.SpecUnt = ""
  11041. // order.DrordBegnDate = s_tm
  11042. // order.DrordStopDate = ""
  11043. // order.DrordDrCodg = "1"
  11044. // order.DrordDeptName = department.Name
  11045. // order.DrordDrCodg = "1"
  11046. // order.DrordDrName = doctor_info.UserName
  11047. // order.DrordDrProfttl = ""
  11048. // order.CurrDrordFlag = "1"
  11049. // orders = append(orders, &order)
  11050. //
  11051. // }
  11052. // }
  11053. //}
  11054. for _, item := range prescriptions {
  11055. for _, subItem := range item.HisDoctorAdviceInfo {
  11056. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11057. var order models.FsiOrderDtos
  11058. order.RxID = strconv.FormatInt(item.ID, 10)
  11059. order.Rxno = strconv.FormatInt(item.ID, 10)
  11060. order.LongDrordFlag = "0"
  11061. order.HilistType = "1"
  11062. order.ChrgType = "1"
  11063. order.DrordBhvr = "-"
  11064. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11065. order.HosplistName = subItem.BaseDrugLib.DrugName
  11066. order.HilistLv = "1"
  11067. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11068. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11069. order.HosplistName = subItem.BaseDrugLib.DrugName
  11070. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11071. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11072. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11073. order.OwnpayAmt = ""
  11074. order.SelfpayAmt = ""
  11075. order.Spec = ""
  11076. order.SpecUnt = ""
  11077. order.DrordBegnDate = s_tm
  11078. order.DrordStopDate = ""
  11079. order.DrordDrCodg = doctor_info.DoctorNumber
  11080. order.DrordDeptName = department.Name
  11081. order.DrordDeptCodg = department.Number
  11082. order.DrordDrName = doctor_info.UserName
  11083. order.DrordDrProfttl = "234"
  11084. order.CurrDrordFlag = "1"
  11085. orders = append(orders, &order)
  11086. }
  11087. }
  11088. for _, subItem := range item.HisPrescriptionProject {
  11089. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11090. var order models.FsiOrderDtos
  11091. order.RxID = strconv.FormatInt(item.ID, 10)
  11092. order.Rxno = strconv.FormatInt(item.ID, 10)
  11093. order.LongDrordFlag = "0"
  11094. order.HilistType = "1"
  11095. order.ChrgType = "1"
  11096. order.DrordBhvr = "-"
  11097. order.HilistCode = subItem.HisProject.MedicalCode
  11098. order.HosplistName = subItem.HisProject.ProjectName
  11099. order.HilistLv = "1"
  11100. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11101. order.HosplistCode = subItem.HisProject.MedicalCode
  11102. order.HosplistName = subItem.HisProject.ProjectName
  11103. order.Cnt = subItem.Count
  11104. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11105. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11106. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11107. order.OwnpayAmt = ""
  11108. order.SelfpayAmt = ""
  11109. order.Spec = ""
  11110. order.SpecUnt = ""
  11111. order.DrordBegnDate = s_tm
  11112. order.DrordStopDate = ""
  11113. order.DrordDrCodg = doctor_info.DoctorNumber
  11114. order.DrordDeptName = department.Name
  11115. order.DrordDeptCodg = department.Number
  11116. order.DrordDrName = doctor_info.UserName
  11117. order.DrordDrProfttl = "234"
  11118. order.CurrDrordFlag = "1"
  11119. orders = append(orders, &order)
  11120. }
  11121. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11122. var order models.FsiOrderDtos
  11123. order.RxID = strconv.FormatInt(item.ID, 10)
  11124. order.Rxno = strconv.FormatInt(item.ID, 10)
  11125. order.LongDrordFlag = "0"
  11126. order.HilistType = "1"
  11127. order.ChrgType = "1"
  11128. order.DrordBhvr = "0"
  11129. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11130. order.HosplistName = subItem.GoodInfo.GoodName
  11131. order.HilistLv = "1"
  11132. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11133. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11134. order.HosplistName = subItem.GoodInfo.GoodName
  11135. order.Cnt = subItem.Count
  11136. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11137. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11138. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11139. order.OwnpayAmt = ""
  11140. order.SelfpayAmt = ""
  11141. order.Spec = ""
  11142. order.SpecUnt = ""
  11143. order.DrordBegnDate = s_tm
  11144. order.DrordStopDate = ""
  11145. order.DrordDrCodg = doctor_info.DoctorNumber
  11146. order.DrordDeptName = department.Name
  11147. order.DrordDeptCodg = department.Number
  11148. order.DrordDrName = doctor_info.UserName
  11149. order.DrordDrProfttl = "234"
  11150. order.CurrDrordFlag = "1"
  11151. orders = append(orders, &order)
  11152. }
  11153. }
  11154. }
  11155. //处方医嘱信息
  11156. fed.MatnStas = "0"
  11157. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11158. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11159. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11160. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11161. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11162. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11163. fed.SetlTotlnum = "1"
  11164. fed.Insutype = his.Insutype
  11165. fed.ReimFlag = "0"
  11166. fed.OutSetlFlag = "0"
  11167. var fopd []*models.FsiOperationDtosData
  11168. data := make(map[string]interface{})
  11169. data["fed"] = fed
  11170. data["fdd"] = fdds
  11171. data["fod"] = orders
  11172. data["pd"] = pd
  11173. data["pp"] = pp
  11174. data["fopd"] = fopd
  11175. data["trig_scen"] = trig_scen
  11176. client := &http.Client{}
  11177. bytesData, _ := json.Marshal(data)
  11178. var req *http.Request
  11179. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11180. if miConfig.MdtrtareaAdmvs == "320921" {
  11181. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11182. } else {
  11183. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11184. }
  11185. resp, _ := client.Do(req)
  11186. defer resp.Body.Close()
  11187. body, ioErr := ioutil.ReadAll(resp.Body)
  11188. if ioErr != nil {
  11189. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11191. return res
  11192. }
  11193. var respJSON map[string]interface{}
  11194. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11195. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11197. return res
  11198. }
  11199. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11200. result, _ := json.Marshal(respJSON)
  11201. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11202. utils.ErrorLog("解析失败:%v", err)
  11203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11204. return res
  11205. }
  11206. return res
  11207. } else {
  11208. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11209. saveLog(output, input, "3102", "事中")
  11210. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11211. utils.ErrorLog("解析失败:%v", err)
  11212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11213. return
  11214. }
  11215. return res
  11216. }
  11217. return res
  11218. }
  11219. 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) {
  11220. var res Resultgd3101
  11221. adminUser := c.GetAdminUserInfo()
  11222. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11223. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11224. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11225. //record_time := c.GetString("record_time")
  11226. //trig_scen := c.GetString("trig_scen")
  11227. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11228. //psn_info, _ := service.GetPatientId(patient_id)
  11229. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11230. timeLayout := "2006-01-02"
  11231. loc, _ := time.LoadLocation("Local")
  11232. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11233. if err != nil {
  11234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11235. return res
  11236. }
  11237. recordDateTime := theTime.Unix()
  11238. var patientPrescription models.HisPrescriptionInfo
  11239. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11240. //if patientPrescription.ID == 0 {
  11241. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11242. //}
  11243. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11244. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11245. //
  11246. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11247. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11248. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11249. var pp models.PublicParams
  11250. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11251. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11252. pp.FixmedinsName = miConfig.OrgName
  11253. pp.FixmedinsCode = miConfig.Code
  11254. pp.RequestUrl = miConfig.Url
  11255. pp.Cainfo = miConfig.Cainfo
  11256. pp.SecretKey = miConfig.SecretKey
  11257. pp.AccessKey = miConfig.AccessKey
  11258. pp.OpterName = roles.UserName
  11259. var config []*models.HisXtDiagnoseConfig
  11260. for _, item := range diagnosis_ids {
  11261. id, _ := strconv.ParseInt(item, 10, 64)
  11262. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11263. config = append(config, &diagnosisConfig)
  11264. }
  11265. var pd models.PatientDtos
  11266. pd.PatnID = his.PsnNo
  11267. pd.PatnName = his.Name
  11268. pd.Gend = his.Gend
  11269. pd.Brdy = str
  11270. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11271. pd.CurrMdtrtID = his.Number
  11272. var fed models.FsiEncounterDtos
  11273. fed.MdtrtID = his.Number
  11274. fed.MedinsID = miConfig.Code
  11275. fed.MedinsName = miConfig.OrgName
  11276. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11277. fed.MedMdtrtType = "1"
  11278. fed.MedinsType = "1"
  11279. fed.MedinsLv = "11"
  11280. tm := time.Unix(his.RecordDate, 0)
  11281. s_tm := tm.Format("2006-01-02 15:04:05")
  11282. fed.AdmDate = s_tm
  11283. fed.DscgDate = s_tm
  11284. fed.DscgMainDiseCodg = config[0].CountryCode
  11285. fed.DscgMainDiseName = config[0].CountryContentName
  11286. //诊断信息
  11287. var fdds []*models.FsiDiagnoseDtos
  11288. for index, item := range config {
  11289. if index == 0 {
  11290. var fdd models.FsiDiagnoseDtos
  11291. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11292. fdd.InoutDiseType = "1"
  11293. fdd.MaindiseFlag = "1"
  11294. fdd.DiseDate = s_tm
  11295. fdd.DiasSrtNo = "1"
  11296. fdd.DiseName = item.CountryContentName
  11297. fdd.DiseCodg = item.CountryCode
  11298. fdds = append(fdds, &fdd)
  11299. } else {
  11300. var fdd models.FsiDiagnoseDtos
  11301. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11302. fdd.InoutDiseType = "1"
  11303. fdd.MaindiseFlag = "1"
  11304. fdd.DiseDate = s_tm
  11305. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11306. fdd.DiseName = item.CountryContentName
  11307. fdd.DiseCodg = item.CountryCode
  11308. fdds = append(fdds, &fdd)
  11309. }
  11310. }
  11311. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11312. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11313. fed.AdmDeptName = de.Name
  11314. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11315. fed.DscgDeptName = de.Name
  11316. fed.MedMdtrtType = "1"
  11317. fed.MedType = "11"
  11318. //if his.Insutype == "390" {
  11319. // fed.MedType = "1402"
  11320. //} else {
  11321. // fed.MedType = "9933"
  11322. //}
  11323. var orders []*models.FsiOrderDtos
  11324. if trig_scen == "2" {
  11325. //处方医嘱信息
  11326. for _, item := range prescriptions {
  11327. for _, subItem := range item.HisDoctorAdviceInfo {
  11328. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11329. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11330. var order models.FsiOrderDtos
  11331. order.RxID = strconv.FormatInt(item.ID, 10)
  11332. order.Rxno = strconv.FormatInt(item.ID, 10)
  11333. order.LongDrordFlag = "0"
  11334. order.HilistType = "1"
  11335. order.ChrgType = "1"
  11336. order.DrordBhvr = "0"
  11337. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11338. order.HosplistName = subItem.BaseDrugLib.DrugName
  11339. order.HilistLv = "1"
  11340. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11341. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11342. order.HosplistName = subItem.BaseDrugLib.DrugName
  11343. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11344. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11345. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11346. order.OwnpayAmt = ""
  11347. order.SelfpayAmt = ""
  11348. order.Spec = spec
  11349. order.SpecUnt = subItem.PrescribingNumberUnit
  11350. order.DrordBegnDate = s_tm
  11351. order.DrordStopDate = ""
  11352. order.DrordDrCodg = doctor_info.DoctorNumber
  11353. order.DrordDeptName = department.Name
  11354. order.DrordDeptCodg = department.Number
  11355. order.DrordDrName = doctor_info.UserName
  11356. order.DrordDrProfttl = "234"
  11357. order.CurrDrordFlag = "1"
  11358. orders = append(orders, &order)
  11359. }
  11360. }
  11361. for _, subItem := range item.HisPrescriptionProject {
  11362. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11363. var order models.FsiOrderDtos
  11364. order.RxID = strconv.FormatInt(item.ID, 10)
  11365. order.Rxno = strconv.FormatInt(item.ID, 10)
  11366. order.LongDrordFlag = "0"
  11367. order.HilistType = "1"
  11368. order.ChrgType = "1"
  11369. order.DrordBhvr = "0"
  11370. order.HilistCode = subItem.HisProject.MedicalCode
  11371. order.HosplistName = subItem.HisProject.ProjectName
  11372. order.HilistLv = "1"
  11373. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11374. order.HosplistCode = subItem.HisProject.MedicalCode
  11375. order.HosplistName = subItem.HisProject.ProjectName
  11376. order.Cnt = subItem.Count
  11377. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11378. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11379. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11380. order.OwnpayAmt = ""
  11381. order.SelfpayAmt = ""
  11382. order.Spec = subItem.Unit
  11383. order.SpecUnt = subItem.Unit
  11384. order.DrordBegnDate = s_tm
  11385. order.DrordStopDate = ""
  11386. order.DrordDrCodg = doctor_info.DoctorNumber
  11387. order.DrordDeptName = department.Name
  11388. order.DrordDeptCodg = department.Number
  11389. order.DrordDrName = doctor_info.UserName
  11390. order.DrordDrProfttl = "234"
  11391. order.CurrDrordFlag = "1"
  11392. orders = append(orders, &order)
  11393. }
  11394. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11395. var order models.FsiOrderDtos
  11396. order.RxID = strconv.FormatInt(item.ID, 10)
  11397. order.Rxno = strconv.FormatInt(item.ID, 10)
  11398. order.LongDrordFlag = "0"
  11399. order.HilistType = "1"
  11400. order.ChrgType = "1"
  11401. order.DrordBhvr = "0"
  11402. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11403. order.HosplistName = subItem.GoodInfo.GoodName
  11404. order.HilistLv = "1"
  11405. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11406. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11407. order.HosplistName = subItem.GoodInfo.GoodName
  11408. order.Cnt = subItem.Count
  11409. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11410. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11411. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11412. order.OwnpayAmt = ""
  11413. order.SelfpayAmt = ""
  11414. order.Spec = subItem.GoodInfo.SpecificationName
  11415. order.SpecUnt = subItem.Unit
  11416. order.DrordBegnDate = s_tm
  11417. order.DrordStopDate = ""
  11418. order.DrordDrCodg = doctor_info.DoctorNumber
  11419. order.DrordDeptName = department.Name
  11420. order.DrordDeptCodg = department.Number
  11421. order.DrordDrName = doctor_info.UserName
  11422. order.DrordDrProfttl = "234"
  11423. order.CurrDrordFlag = "1"
  11424. orders = append(orders, &order)
  11425. }
  11426. }
  11427. }
  11428. //处方医嘱信息
  11429. }
  11430. fed.MatnStas = "0"
  11431. fed.MedfeeSumamt = "0"
  11432. fed.OwnpayAmt = "0"
  11433. fed.SelfpayAmt = "0"
  11434. fed.AcctPayamt = "0"
  11435. fed.MaAmt = "0"
  11436. fed.HifpPayamt = "0"
  11437. fed.SetlTotlnum = "1"
  11438. fed.Insutype = his.Insutype
  11439. fed.ReimFlag = "0"
  11440. fed.OutSetlFlag = "0"
  11441. var fopd []*models.FsiOperationDtosData
  11442. data := make(map[string]interface{})
  11443. data["fed"] = fed
  11444. data["fdd"] = fdds
  11445. data["fod"] = orders
  11446. data["pd"] = pd
  11447. data["pp"] = pp
  11448. data["fopd"] = fopd
  11449. data["trig_scen"] = trig_scen
  11450. fmt.Println(data)
  11451. fmt.Println(fed)
  11452. fmt.Println(fdds)
  11453. fmt.Println(orders)
  11454. fmt.Println(pd)
  11455. fmt.Println(pp)
  11456. fmt.Println(fopd)
  11457. client := &http.Client{}
  11458. bytesData, _ := json.Marshal(data)
  11459. var req *http.Request
  11460. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11461. if miConfig.MdtrtareaAdmvs == "320921" {
  11462. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11463. } else {
  11464. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11465. }
  11466. resp, _ := client.Do(req)
  11467. defer resp.Body.Close()
  11468. body, ioErr := ioutil.ReadAll(resp.Body)
  11469. if ioErr != nil {
  11470. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11472. return res
  11473. }
  11474. var respJSON map[string]interface{}
  11475. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11476. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11478. return res
  11479. }
  11480. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11481. fmt.Println(respJSON)
  11482. result, _ := json.Marshal(respJSON)
  11483. fmt.Println(result)
  11484. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11485. utils.ErrorLog("解析失败:%v", err)
  11486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11487. return res
  11488. }
  11489. return res
  11490. } else {
  11491. //if miConfig.MdtrtareaAdmvs == "441202" {
  11492. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11493. saveLog(output, input, "3101", "事前")
  11494. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11495. utils.ErrorLog("解析失败:%v", err)
  11496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11497. return
  11498. }
  11499. return res
  11500. //}
  11501. }
  11502. }
  11503. 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) {
  11504. adminUser := c.GetAdminUserInfo()
  11505. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11506. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11507. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11508. //record_time := c.GetString("record_time")
  11509. //trig_scen := c.GetString("trig_scen")
  11510. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11511. timeLayout := "2006-01-02"
  11512. loc, _ := time.LoadLocation("Local")
  11513. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11514. if err != nil {
  11515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11516. return res
  11517. }
  11518. recordDateTime := theTime.Unix()
  11519. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11520. var patientPrescription models.HisPrescriptionInfo
  11521. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11522. if patientPrescription.ID == 0 {
  11523. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11524. }
  11525. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11526. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11527. //
  11528. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11529. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11530. var pp models.PublicParams
  11531. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11532. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11533. pp.FixmedinsName = miConfig.OrgName
  11534. pp.FixmedinsCode = miConfig.Code
  11535. pp.RequestUrl = miConfig.Url
  11536. pp.Cainfo = miConfig.Cainfo
  11537. pp.SecretKey = miConfig.SecretKey
  11538. pp.AccessKey = miConfig.AccessKey
  11539. pp.OpterName = roles.UserName
  11540. var config []*models.HisXtDiagnoseConfig
  11541. for _, item := range diagnosis_ids {
  11542. id, _ := strconv.ParseInt(item, 10, 64)
  11543. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11544. config = append(config, &diagnosisConfig)
  11545. }
  11546. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11547. var pd models.PatientDtos
  11548. pd.PatnID = his.PsnNo
  11549. pd.PatnName = his.Name
  11550. pd.Gend = his.Gend
  11551. pd.Brdy = str
  11552. pd.Poolarea = his.InsuplcAdmdvs
  11553. pd.CurrMdtrtID = his.Number
  11554. var fed models.FsiEncounterDtos
  11555. fed.MdtrtID = his.Number
  11556. fed.MedinsID = miConfig.Code
  11557. fed.MedinsName = miConfig.OrgName
  11558. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11559. fed.MedMdtrtType = "1"
  11560. fed.MedinsType = "1"
  11561. fed.MedinsLv = "11"
  11562. tm := time.Unix(his.RecordDate, 0)
  11563. s_tm := tm.Format("2006-01-02 15:04:05")
  11564. fed.AdmDate = s_tm
  11565. fed.DscgDate = s_tm
  11566. fed.DscgMainDiseCodg = config[0].CountryCode
  11567. fed.DscgMainDiseName = config[0].CountryContentName
  11568. //诊断信息
  11569. var fdds []*models.FsiDiagnoseDtos
  11570. for index, item := range config {
  11571. if index == 0 {
  11572. var fdd models.FsiDiagnoseDtos
  11573. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11574. fdd.InoutDiseType = "1"
  11575. fdd.MaindiseFlag = "1"
  11576. fdd.DiseDate = s_tm
  11577. fdd.DiasSrtNo = "1"
  11578. fdd.DiseName = item.CountryContentName
  11579. fdd.DiseCodg = item.CountryCode
  11580. fdds = append(fdds, &fdd)
  11581. } else {
  11582. var fdd models.FsiDiagnoseDtos
  11583. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11584. fdd.InoutDiseType = "1"
  11585. fdd.MaindiseFlag = "1"
  11586. fdd.DiseDate = s_tm
  11587. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11588. fdd.DiseName = item.CountryContentName
  11589. fdd.DiseCodg = item.CountryCode
  11590. fdds = append(fdds, &fdd)
  11591. }
  11592. }
  11593. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11594. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11595. fed.AdmDeptName = department.Name
  11596. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11597. fed.DscgDeptName = department.Name
  11598. fed.MedMdtrtType = "1"
  11599. fed.MedType = "11"
  11600. //if his.Insutype == "390" {
  11601. // fed.MedType = "1402"
  11602. //} else {
  11603. // fed.MedType = "9933"
  11604. //}
  11605. var orders []*models.FsiOrderDtos
  11606. if trig_scen == "2" {
  11607. //处方医嘱信息
  11608. for _, item := range prescriptions {
  11609. for _, subItem := range item.HisDoctorAdviceInfo {
  11610. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11611. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11612. var order models.FsiOrderDtos
  11613. order.RxID = strconv.FormatInt(item.ID, 10)
  11614. order.Rxno = strconv.FormatInt(item.ID, 10)
  11615. order.LongDrordFlag = "0"
  11616. order.HilistType = "1"
  11617. order.ChrgType = "1"
  11618. order.DrordBhvr = "0"
  11619. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11620. order.HosplistName = subItem.BaseDrugLib.DrugName
  11621. order.HilistLv = "1"
  11622. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11623. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11624. order.HosplistName = subItem.BaseDrugLib.DrugName
  11625. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11626. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11627. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11628. order.OwnpayAmt = ""
  11629. order.SelfpayAmt = ""
  11630. order.Spec = spec
  11631. order.SpecUnt = subItem.PrescribingNumberUnit
  11632. order.DrordBegnDate = s_tm
  11633. order.DrordStopDate = ""
  11634. order.DrordDrCodg = doctor_info.DoctorNumber
  11635. order.DrordDeptName = department.Name
  11636. order.DrordDeptCodg = department.Number
  11637. order.DrordDrName = doctor_info.UserName
  11638. order.DrordDrProfttl = "234"
  11639. order.CurrDrordFlag = "1"
  11640. orders = append(orders, &order)
  11641. }
  11642. }
  11643. for _, subItem := range item.HisPrescriptionProject {
  11644. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11645. var order models.FsiOrderDtos
  11646. order.RxID = strconv.FormatInt(item.ID, 10)
  11647. order.Rxno = strconv.FormatInt(item.ID, 10)
  11648. order.LongDrordFlag = "0"
  11649. order.HilistType = "1"
  11650. order.ChrgType = "1"
  11651. order.DrordBhvr = "0"
  11652. order.HilistCode = subItem.HisProject.MedicalCode
  11653. order.HosplistName = subItem.HisProject.ProjectName
  11654. order.HilistLv = "1"
  11655. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11656. order.HosplistCode = subItem.HisProject.MedicalCode
  11657. order.HosplistName = subItem.HisProject.ProjectName
  11658. order.Cnt = subItem.Count
  11659. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11660. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11661. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11662. order.OwnpayAmt = ""
  11663. order.SelfpayAmt = ""
  11664. order.Spec = subItem.Unit
  11665. order.SpecUnt = subItem.Unit
  11666. order.DrordBegnDate = s_tm
  11667. order.DrordStopDate = ""
  11668. order.DrordDrCodg = doctor_info.DoctorNumber
  11669. order.DrordDeptName = department.Name
  11670. order.DrordDeptCodg = department.Number
  11671. order.DrordDrName = doctor_info.UserName
  11672. order.DrordDrProfttl = "234"
  11673. order.CurrDrordFlag = "1"
  11674. orders = append(orders, &order)
  11675. }
  11676. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11677. var order models.FsiOrderDtos
  11678. order.RxID = strconv.FormatInt(item.ID, 10)
  11679. order.Rxno = strconv.FormatInt(item.ID, 10)
  11680. order.LongDrordFlag = "0"
  11681. order.HilistType = "1"
  11682. order.ChrgType = "1"
  11683. order.DrordBhvr = "0"
  11684. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11685. order.HosplistName = subItem.GoodInfo.GoodName
  11686. order.HilistLv = "1"
  11687. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11688. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11689. order.HosplistName = subItem.GoodInfo.GoodName
  11690. order.Cnt = subItem.Count
  11691. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11692. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11693. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11694. order.OwnpayAmt = ""
  11695. order.SelfpayAmt = ""
  11696. order.Spec = subItem.GoodInfo.SpecificationName
  11697. order.SpecUnt = subItem.Unit
  11698. order.DrordBegnDate = s_tm
  11699. order.DrordStopDate = ""
  11700. order.DrordDrCodg = doctor_info.DoctorNumber
  11701. order.DrordDeptName = department.Name
  11702. order.DrordDeptCodg = department.Number
  11703. order.DrordDrName = doctor_info.UserName
  11704. order.DrordDrProfttl = "234"
  11705. order.CurrDrordFlag = "1"
  11706. orders = append(orders, &order)
  11707. }
  11708. }
  11709. }
  11710. //处方医嘱信息
  11711. }
  11712. fed.MatnStas = "0"
  11713. fed.MedfeeSumamt = "0"
  11714. fed.OwnpayAmt = "0"
  11715. fed.SelfpayAmt = "0"
  11716. fed.AcctPayamt = "0"
  11717. fed.MaAmt = "0"
  11718. fed.HifpPayamt = "0"
  11719. fed.SetlTotlnum = "1"
  11720. fed.Insutype = his.Insutype
  11721. fed.ReimFlag = "0"
  11722. fed.OutSetlFlag = "0"
  11723. var fopd []*models.FsiOperationDtosData
  11724. data := make(map[string]interface{})
  11725. data["fed"] = fed
  11726. data["fdd"] = fdds
  11727. data["fod"] = orders
  11728. data["pd"] = pd
  11729. data["pp"] = pp
  11730. data["fopd"] = fopd
  11731. data["trig_scen"] = trig_scen
  11732. fmt.Println(data)
  11733. fmt.Println(fed)
  11734. fmt.Println(fdds)
  11735. fmt.Println(orders)
  11736. fmt.Println(pd)
  11737. fmt.Println(pp)
  11738. fmt.Println(fopd)
  11739. client := &http.Client{}
  11740. bytesData, _ := json.Marshal(data)
  11741. var req *http.Request
  11742. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11743. if miConfig.MdtrtareaAdmvs == "320921" {
  11744. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11745. } else {
  11746. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11747. }
  11748. resp, _ := client.Do(req)
  11749. defer resp.Body.Close()
  11750. body, ioErr := ioutil.ReadAll(resp.Body)
  11751. if ioErr != nil {
  11752. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11754. return res
  11755. }
  11756. var respJSON map[string]interface{}
  11757. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11758. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11760. return res
  11761. }
  11762. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11763. fmt.Println(respJSON)
  11764. result, _ := json.Marshal(respJSON)
  11765. fmt.Println(result)
  11766. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11767. utils.ErrorLog("解析失败:%v", err)
  11768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11769. return res
  11770. }
  11771. return res
  11772. } else {
  11773. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11774. saveLog(output, input, "3101", "事前")
  11775. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11776. utils.ErrorLog("解析失败:%v", err)
  11777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11778. return
  11779. }
  11780. return res
  11781. }
  11782. return res
  11783. }
  11784. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  11785. ////patient_id, _ := c.GetInt64("patient_id")
  11786. //order_id, _ := c.GetInt64("order_id")
  11787. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11788. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11789. //trig_scen := c.GetString("trig_scen")
  11790. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11791. //utils.ErrorLog("解析失败:%v", psn_info)
  11792. adminUser := c.GetAdminUserInfo()
  11793. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11794. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11795. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11796. record_time := c.GetString("record_time")
  11797. order, _ := service.GetHisOrderByID(order_id)
  11798. timeLayout := "2006-01-02"
  11799. loc, _ := time.LoadLocation("Local")
  11800. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11801. if err != nil {
  11802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11803. return
  11804. }
  11805. recordDateTime := theTime.Unix()
  11806. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11807. var patientPrescription models.HisPrescriptionInfo
  11808. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11809. if patientPrescription.ID == 0 {
  11810. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11811. }
  11812. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11813. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11814. //
  11815. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11816. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11817. var pp models.PublicParams
  11818. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11819. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11820. pp.FixmedinsName = miConfig.OrgName
  11821. pp.FixmedinsCode = miConfig.Code
  11822. pp.RequestUrl = miConfig.Url
  11823. pp.Cainfo = miConfig.Cainfo
  11824. pp.SecretKey = miConfig.SecretKey
  11825. pp.AccessKey = miConfig.AccessKey
  11826. pp.OpterName = roles.UserName
  11827. var config []*models.HisXtDiagnoseConfig
  11828. for _, item := range diagnosis_ids {
  11829. id, _ := strconv.ParseInt(item, 10, 64)
  11830. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11831. config = append(config, &diagnosisConfig)
  11832. }
  11833. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11834. var pd models.PatientDtos
  11835. pd.PatnID = his.PsnNo
  11836. pd.PatnName = his.Name
  11837. pd.Gend = his.Gend
  11838. pd.Brdy = str
  11839. pd.Poolarea = his.InsuplcAdmdvs
  11840. pd.CurrMdtrtID = his.Number
  11841. var fed models.FsiEncounterDtos
  11842. fed.MdtrtID = his.Number
  11843. fed.MedinsID = miConfig.Code
  11844. fed.MedinsName = miConfig.OrgName
  11845. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11846. fed.MedMdtrtType = "1"
  11847. fed.MedinsType = "1"
  11848. fed.MedinsLv = "11"
  11849. tm := time.Unix(his.RecordDate, 0)
  11850. s_tm := tm.Format("2006-01-02 15:04:05")
  11851. fed.AdmDate = s_tm
  11852. fed.DscgDate = s_tm
  11853. fed.DscgMainDiseCodg = config[0].CountryCode
  11854. fed.DscgMainDiseName = config[0].CountryContentName
  11855. //诊断信息
  11856. var fdds []*models.FsiDiagnoseDtos
  11857. for index, item := range config {
  11858. if index == 0 {
  11859. var fdd models.FsiDiagnoseDtos
  11860. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11861. fdd.InoutDiseType = "1"
  11862. fdd.MaindiseFlag = "1"
  11863. fdd.DiseDate = s_tm
  11864. fdd.DiasSrtNo = "1"
  11865. fdd.DiseName = item.CountryContentName
  11866. fdd.DiseCodg = item.CountryCode
  11867. fdds = append(fdds, &fdd)
  11868. } else {
  11869. var fdd models.FsiDiagnoseDtos
  11870. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11871. fdd.InoutDiseType = "1"
  11872. fdd.MaindiseFlag = "1"
  11873. fdd.DiseDate = s_tm
  11874. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11875. fdd.DiseName = item.CountryContentName
  11876. fdd.DiseCodg = item.CountryCode
  11877. fdds = append(fdds, &fdd)
  11878. }
  11879. }
  11880. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11881. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11882. fed.AdmDeptName = department.Name
  11883. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11884. fed.DscgDeptName = department.Name
  11885. fed.MedType = order.MedType
  11886. //处方医嘱信息
  11887. var orders []*models.FsiOrderDtos
  11888. //for _, item := range prescriptions {
  11889. // for _, subItem := range item.HisDoctorAdviceInfo {
  11890. // var order models.FsiOrderDtos
  11891. // order.RxID = strconv.FormatInt(item.ID, 10)
  11892. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11893. // order.LongDrordFlag = "0"
  11894. // order.HilistType = "1"
  11895. // order.ChrgType = "1"
  11896. // order.DrordBhvr = "-"
  11897. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11898. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11899. // order.HilistLv = "1"
  11900. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11901. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11902. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11903. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11904. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11905. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11906. // order.OwnpayAmt = ""
  11907. // order.SelfpayAmt = ""
  11908. // order.Spec = ""
  11909. // order.SpecUnt = ""
  11910. // order.DrordBegnDate = s_tm
  11911. // order.DrordStopDate = ""
  11912. // order.DrordDrCodg = "1"
  11913. // order.DrordDeptName = department.Name
  11914. // order.DrordDrCodg = "1"
  11915. // order.DrordDrName = doctor_info.UserName
  11916. // order.DrordDrProfttl = ""
  11917. // order.CurrDrordFlag = "1"
  11918. // orders = append(orders, &order)
  11919. // }
  11920. // for _, subItem := range item.HisPrescriptionProject {
  11921. // if subItem.Type == 2 {
  11922. // var order models.FsiOrderDtos
  11923. // order.RxID = strconv.FormatInt(item.ID, 10)
  11924. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11925. // order.LongDrordFlag = "0"
  11926. // order.HilistType = "1"
  11927. // order.ChrgType = "1"
  11928. // order.DrordBhvr = "-"
  11929. // order.HilistCode = subItem.HisProject.MedicalCode
  11930. // order.HosplistName = subItem.HisProject.ProjectName
  11931. // order.HilistLv = "1"
  11932. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11933. // order.HosplistCode = subItem.HisProject.MedicalCode
  11934. // order.HosplistName = subItem.HisProject.ProjectName
  11935. // order.Cnt = subItem.Count
  11936. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11937. //
  11938. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11939. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11940. // order.OwnpayAmt = ""
  11941. // order.SelfpayAmt = ""
  11942. // order.Spec = ""
  11943. // order.SpecUnt = ""
  11944. // order.DrordBegnDate = s_tm
  11945. // order.DrordStopDate = ""
  11946. // order.DrordDrCodg = "1"
  11947. // order.DrordDeptName = department.Name
  11948. // order.DrordDrCodg = "1"
  11949. // order.DrordDrName = doctor_info.UserName
  11950. // order.DrordDrProfttl = ""
  11951. // order.CurrDrordFlag = "1"
  11952. // orders = append(orders, &order)
  11953. //
  11954. // }
  11955. // if subItem.Type == 3 {
  11956. //
  11957. // var order models.FsiOrderDtos
  11958. // order.RxID = strconv.FormatInt(item.ID, 10)
  11959. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11960. // order.LongDrordFlag = "0"
  11961. // order.HilistType = "1"
  11962. // order.ChrgType = "1"
  11963. // order.DrordBhvr = "-"
  11964. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11965. // order.HosplistName = subItem.GoodInfo.GoodName
  11966. // order.HilistLv = "1"
  11967. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11968. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11969. // order.HosplistName = subItem.GoodInfo.GoodName
  11970. // order.Cnt = subItem.Count
  11971. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11972. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11973. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11974. // order.OwnpayAmt = ""
  11975. // order.SelfpayAmt = ""
  11976. // order.Spec = ""
  11977. // order.SpecUnt = ""
  11978. // order.DrordBegnDate = s_tm
  11979. // order.DrordStopDate = ""
  11980. // order.DrordDrCodg = "1"
  11981. // order.DrordDeptName = department.Name
  11982. // order.DrordDrCodg = "1"
  11983. // order.DrordDrName = doctor_info.UserName
  11984. // order.DrordDrProfttl = ""
  11985. // order.CurrDrordFlag = "1"
  11986. // orders = append(orders, &order)
  11987. //
  11988. // }
  11989. // }
  11990. //}
  11991. for _, item := range prescriptions {
  11992. for _, subItem := range item.HisDoctorAdviceInfo {
  11993. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11994. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11995. var order models.FsiOrderDtos
  11996. order.RxID = strconv.FormatInt(item.ID, 10)
  11997. order.Rxno = strconv.FormatInt(item.ID, 10)
  11998. order.LongDrordFlag = "0"
  11999. order.HilistType = "1"
  12000. order.ChrgType = "1"
  12001. order.DrordBhvr = "0"
  12002. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12003. order.HosplistName = subItem.BaseDrugLib.DrugName
  12004. order.HilistLv = "1"
  12005. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12006. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12007. order.HosplistName = subItem.BaseDrugLib.DrugName
  12008. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12009. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12010. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12011. order.OwnpayAmt = ""
  12012. order.SelfpayAmt = ""
  12013. order.Spec = spec
  12014. order.SpecUnt = subItem.PrescribingNumberUnit
  12015. order.DrordBegnDate = s_tm
  12016. order.DrordStopDate = ""
  12017. order.DrordDrCodg = doctor_info.DoctorNumber
  12018. order.DrordDeptName = department.Name
  12019. order.DrordDeptCodg = department.Number
  12020. order.DrordDrName = doctor_info.UserName
  12021. order.DrordDrProfttl = "234"
  12022. order.CurrDrordFlag = "1"
  12023. orders = append(orders, &order)
  12024. }
  12025. }
  12026. for _, subItem := range item.HisPrescriptionProject {
  12027. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12028. var order models.FsiOrderDtos
  12029. order.RxID = strconv.FormatInt(item.ID, 10)
  12030. order.Rxno = strconv.FormatInt(item.ID, 10)
  12031. order.LongDrordFlag = "0"
  12032. order.HilistType = "1"
  12033. order.ChrgType = "1"
  12034. order.DrordBhvr = "0"
  12035. order.HilistCode = subItem.HisProject.MedicalCode
  12036. order.HosplistName = subItem.HisProject.ProjectName
  12037. order.HilistLv = "1"
  12038. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12039. order.HosplistCode = subItem.HisProject.MedicalCode
  12040. order.HosplistName = subItem.HisProject.ProjectName
  12041. order.Cnt = subItem.Count
  12042. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12043. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12044. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12045. order.OwnpayAmt = ""
  12046. order.SelfpayAmt = ""
  12047. order.Spec = subItem.Unit
  12048. order.SpecUnt = subItem.Unit
  12049. order.DrordBegnDate = s_tm
  12050. order.DrordStopDate = ""
  12051. order.DrordDrCodg = doctor_info.DoctorNumber
  12052. order.DrordDeptName = department.Name
  12053. order.DrordDeptCodg = department.Number
  12054. order.DrordDrName = doctor_info.UserName
  12055. order.DrordDrProfttl = "234"
  12056. order.CurrDrordFlag = "1"
  12057. orders = append(orders, &order)
  12058. }
  12059. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12060. var order models.FsiOrderDtos
  12061. order.RxID = strconv.FormatInt(item.ID, 10)
  12062. order.Rxno = strconv.FormatInt(item.ID, 10)
  12063. order.LongDrordFlag = "0"
  12064. order.HilistType = "1"
  12065. order.ChrgType = "1"
  12066. order.DrordBhvr = "0"
  12067. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12068. order.HosplistName = subItem.GoodInfo.GoodName
  12069. order.HilistLv = "1"
  12070. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12071. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12072. order.HosplistName = subItem.GoodInfo.GoodName
  12073. order.Cnt = subItem.Count
  12074. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12075. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12076. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12077. order.OwnpayAmt = ""
  12078. order.SelfpayAmt = ""
  12079. order.Spec = subItem.GoodInfo.SpecificationName
  12080. order.SpecUnt = subItem.Unit
  12081. order.DrordBegnDate = s_tm
  12082. order.DrordStopDate = ""
  12083. order.DrordDrCodg = doctor_info.DoctorNumber
  12084. order.DrordDeptName = department.Name
  12085. order.DrordDeptCodg = department.Number
  12086. order.DrordDrName = doctor_info.UserName
  12087. order.DrordDrProfttl = "234"
  12088. order.CurrDrordFlag = "1"
  12089. orders = append(orders, &order)
  12090. }
  12091. }
  12092. }
  12093. //处方医嘱信息
  12094. fed.MatnStas = "0"
  12095. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  12096. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  12097. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  12098. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  12099. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  12100. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  12101. fed.SetlTotlnum = "1"
  12102. fed.Insutype = his.Insutype
  12103. fed.ReimFlag = "0"
  12104. fed.OutSetlFlag = "0"
  12105. var fopd []*models.FsiOperationDtosData
  12106. data := make(map[string]interface{})
  12107. data["fed"] = fed
  12108. data["fdd"] = fdds
  12109. data["fod"] = orders
  12110. data["pd"] = pd
  12111. data["pp"] = pp
  12112. data["fopd"] = fopd
  12113. data["trig_scen"] = trig_scen
  12114. client := &http.Client{}
  12115. bytesData, _ := json.Marshal(data)
  12116. var req *http.Request
  12117. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12118. if miConfig.MdtrtareaAdmvs == "320921" {
  12119. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12120. } else {
  12121. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12122. }
  12123. resp, _ := client.Do(req)
  12124. defer resp.Body.Close()
  12125. body, ioErr := ioutil.ReadAll(resp.Body)
  12126. if ioErr != nil {
  12127. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12129. return res
  12130. }
  12131. var respJSON map[string]interface{}
  12132. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12133. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12135. return res
  12136. }
  12137. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12138. result, _ := json.Marshal(respJSON)
  12139. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12140. utils.ErrorLog("解析失败:%v", err)
  12141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12142. return res
  12143. }
  12144. return res
  12145. } else {
  12146. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12147. saveLog(output, input, "3102", "事中")
  12148. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12149. utils.ErrorLog("解析失败:%v", err)
  12150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12151. return
  12152. }
  12153. return res
  12154. }
  12155. return res
  12156. }
  12157. func (c *HisApiController) Check() {
  12158. psn_no := c.GetString("psn_no")
  12159. in := c.GetString("in")
  12160. mt := c.GetString("mt")
  12161. baseParams := models.BaseParams{
  12162. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  12163. FixmedinsCode: "H15049901371",
  12164. InsuplcAdmdvs: "150499",
  12165. MdtrtareaAdmvs: "150499",
  12166. OrgName: "赤峰费森血液透析中心",
  12167. Doctor: "1111",
  12168. }
  12169. service.Gdyb2001(baseParams, psn_no, in, mt)
  12170. }
  12171. func (c *HisApiController) GetPsnNcdsInfo() {
  12172. admin_user_id, _ := c.GetInt64("admin_user_id")
  12173. patient_id, _ := c.GetInt64("patient_id")
  12174. //id, _ := c.GetInt64("id")
  12175. adminUser := c.GetAdminUserInfo()
  12176. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12177. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12178. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  12179. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12180. //psn_record, _ := service.GetP(id)
  12181. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12182. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  12183. //
  12184. //if psn_record.ID == 0 {
  12185. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12186. // return
  12187. //}
  12188. var res Result5301
  12189. var res10265 Result5301For10265
  12190. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12191. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12192. var api string
  12193. if miConfig.MdtrtareaAdmvs == "320921" {
  12194. 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 +
  12195. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12196. } else {
  12197. 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 +
  12198. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12199. }
  12200. resp, requestErr := http.Get(api)
  12201. if requestErr != nil {
  12202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12203. return
  12204. }
  12205. body, ioErr := ioutil.ReadAll(resp.Body)
  12206. if ioErr != nil {
  12207. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12209. return
  12210. }
  12211. var respJSON map[string]interface{}
  12212. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12213. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12215. return
  12216. }
  12217. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12218. result, _ := json.Marshal(respJSON)
  12219. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12220. utils.ErrorLog("解析失败:%v", err)
  12221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12222. return
  12223. }
  12224. res.ErrMsg = res10265.ErrMsg
  12225. res.Output = res10265.Output
  12226. res.InfRefmsgid = res10265.InfRefmsgid
  12227. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12228. res.Infcode = infocode
  12229. } else if miConfig.MdtrtareaAdmvs == "341203" {
  12230. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12231. var api string
  12232. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12233. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12234. resp, requestErr := http.Get(api)
  12235. if requestErr != nil {
  12236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12237. return
  12238. }
  12239. body, ioErr := ioutil.ReadAll(resp.Body)
  12240. if ioErr != nil {
  12241. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12243. return
  12244. }
  12245. var respJSON map[string]interface{}
  12246. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12247. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12249. return
  12250. }
  12251. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12252. if status == "0" {
  12253. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12254. c.ServeSuccessJSON(map[string]interface{}{
  12255. "failed_code": -10,
  12256. "msg": err_msg,
  12257. })
  12258. return
  12259. }
  12260. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12261. result, _ := json.Marshal(respJSON)
  12262. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12263. utils.ErrorLog("解析失败:%v", err)
  12264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12265. return
  12266. }
  12267. } else if miConfig.MdtrtareaAdmvs == "340699" {
  12268. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  12269. var api string
  12270. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12271. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12272. resp, requestErr := http.Get(api)
  12273. if requestErr != nil {
  12274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12275. return
  12276. }
  12277. body, ioErr := ioutil.ReadAll(resp.Body)
  12278. if ioErr != nil {
  12279. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12281. return
  12282. }
  12283. var respJSON map[string]interface{}
  12284. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12285. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12287. return
  12288. }
  12289. status := respJSON["data"].(map[string]interface{})["status"].(string)
  12290. if status == "0" {
  12291. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  12292. c.ServeSuccessJSON(map[string]interface{}{
  12293. "failed_code": -10,
  12294. "msg": err_msg,
  12295. })
  12296. return
  12297. }
  12298. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12299. result, _ := json.Marshal(respJSON)
  12300. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12301. utils.ErrorLog("解析失败:%v", err)
  12302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12303. return
  12304. }
  12305. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12306. p, _ := service.GetHisPatientById(patient_id)
  12307. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12308. var dat map[string]interface{}
  12309. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12310. fmt.Println(dat)
  12311. } else {
  12312. fmt.Println(err)
  12313. }
  12314. userJSONBytes, _ := json.Marshal(dat)
  12315. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12316. utils.ErrorLog("解析失败:%v", err)
  12317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12318. return
  12319. }
  12320. } else if miConfig.MdtrtareaAdmvs == "361025" {
  12321. p, _ := service.GetHisPatientById(patient_id)
  12322. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12323. var dat map[string]interface{}
  12324. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12325. fmt.Println(dat)
  12326. } else {
  12327. fmt.Println(err)
  12328. }
  12329. userJSONBytes, _ := json.Marshal(dat)
  12330. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12331. utils.ErrorLog("解析失败:%v", err)
  12332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12333. return
  12334. }
  12335. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12336. p, _ := service.GetHisPatientById(patient_id)
  12337. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  12338. var dat map[string]interface{}
  12339. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12340. fmt.Println(dat)
  12341. } else {
  12342. fmt.Println(err)
  12343. }
  12344. userJSONBytes, _ := json.Marshal(dat)
  12345. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12346. utils.ErrorLog("解析失败:%v", err)
  12347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12348. return
  12349. }
  12350. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12351. p, _ := service.GetHisPatientById(patient_id)
  12352. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12353. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12354. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12355. resp, requestErr := http.Get(api)
  12356. if requestErr != nil {
  12357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12358. return
  12359. }
  12360. body, ioErr := ioutil.ReadAll(resp.Body)
  12361. if ioErr != nil {
  12362. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12364. return
  12365. }
  12366. var respJSON map[string]interface{}
  12367. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12370. return
  12371. }
  12372. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12373. result, _ := json.Marshal(respJSON)
  12374. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12375. utils.ErrorLog("解析失败:%v", err)
  12376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12377. return
  12378. }
  12379. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12380. p, _ := service.GetHisPatientById(patient_id)
  12381. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  12382. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12383. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12384. resp, requestErr := http.Get(api)
  12385. if requestErr != nil {
  12386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12387. return
  12388. }
  12389. body, ioErr := ioutil.ReadAll(resp.Body)
  12390. if ioErr != nil {
  12391. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12393. return
  12394. }
  12395. var respJSON map[string]interface{}
  12396. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12397. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12399. return
  12400. }
  12401. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12402. result, _ := json.Marshal(respJSON)
  12403. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12404. utils.ErrorLog("解析失败:%v", err)
  12405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12406. return
  12407. }
  12408. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12409. p, _ := service.GetHisPatientById(patient_id)
  12410. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12411. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12412. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12413. resp, requestErr := http.Get(api)
  12414. if requestErr != nil {
  12415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12416. return
  12417. }
  12418. body, ioErr := ioutil.ReadAll(resp.Body)
  12419. if ioErr != nil {
  12420. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12422. return
  12423. }
  12424. var respJSON map[string]interface{}
  12425. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12426. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12428. return
  12429. }
  12430. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12431. result, _ := json.Marshal(respJSON)
  12432. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12433. utils.ErrorLog("解析失败:%v", err)
  12434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12435. return
  12436. }
  12437. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12438. p, _ := service.GetHisPatientById(patient_id)
  12439. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  12440. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12441. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12442. resp, requestErr := http.Get(api)
  12443. if requestErr != nil {
  12444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12445. return
  12446. }
  12447. body, ioErr := ioutil.ReadAll(resp.Body)
  12448. if ioErr != nil {
  12449. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12451. return
  12452. }
  12453. var respJSON map[string]interface{}
  12454. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12455. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12457. return
  12458. }
  12459. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12460. result, _ := json.Marshal(respJSON)
  12461. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12462. utils.ErrorLog("解析失败:%v", err)
  12463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12464. return
  12465. }
  12466. } else if miConfig.MdtrtareaAdmvs == "421300" {
  12467. p, _ := service.GetHisPatientById(patient_id)
  12468. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  12469. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12470. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12471. resp, requestErr := http.Get(api)
  12472. if requestErr != nil {
  12473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12474. return
  12475. }
  12476. body, ioErr := ioutil.ReadAll(resp.Body)
  12477. if ioErr != nil {
  12478. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12480. return
  12481. }
  12482. var respJSON map[string]interface{}
  12483. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12484. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12486. return
  12487. }
  12488. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12489. result, _ := json.Marshal(respJSON)
  12490. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12491. utils.ErrorLog("解析失败:%v", err)
  12492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12493. return
  12494. }
  12495. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12496. p, _ := service.GetHisPatientById(patient_id)
  12497. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  12498. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  12499. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12500. resp, requestErr := http.Get(api)
  12501. if requestErr != nil {
  12502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12503. return
  12504. }
  12505. body, ioErr := ioutil.ReadAll(resp.Body)
  12506. if ioErr != nil {
  12507. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12509. return
  12510. }
  12511. var respJSON map[string]interface{}
  12512. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12513. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12515. return
  12516. }
  12517. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12518. result, _ := json.Marshal(respJSON)
  12519. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12520. utils.ErrorLog("解析失败:%v", err)
  12521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12522. return
  12523. }
  12524. } else {
  12525. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  12526. var dat map[string]interface{}
  12527. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12528. fmt.Println(dat)
  12529. } else {
  12530. fmt.Println(err)
  12531. }
  12532. userJSONBytes, _ := json.Marshal(dat)
  12533. if miConfig.Code == "H15049901371" {
  12534. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12535. utils.ErrorLog("解析失败:%v", err)
  12536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12537. return
  12538. }
  12539. res.InfRefmsgid = res10265.InfRefmsgid
  12540. res.Output = res10265.Output
  12541. res.ErrMsg = res10265.ErrMsg
  12542. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12543. res.Infcode = infocode
  12544. } else {
  12545. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12546. utils.ErrorLog("解析失败:%v", err)
  12547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12548. return
  12549. }
  12550. }
  12551. }
  12552. if res.Infcode == 0 {
  12553. c.ServeSuccessJSON(map[string]interface{}{
  12554. "result": res.Output.Result,
  12555. })
  12556. }
  12557. }
  12558. func (c *HisApiController) CheckInsutype() {
  12559. his_patient_id, _ := c.GetInt64("his_patient_id")
  12560. admin_user_id, _ := c.GetInt64("admin_user_id")
  12561. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12562. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12563. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12564. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  12565. var dat map[string]interface{}
  12566. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12567. fmt.Println(dat)
  12568. } else {
  12569. fmt.Println(err)
  12570. }
  12571. userJSONBytes, _ := json.Marshal(dat)
  12572. var res Result90100
  12573. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12574. utils.ErrorLog("解析失败:%v", err)
  12575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12576. return
  12577. }
  12578. if res.Infcode != 0 {
  12579. c.ServeSuccessJSON(map[string]interface{}{
  12580. "failed_code": -10,
  12581. "msg": res.ErrMsg,
  12582. })
  12583. return
  12584. } else {
  12585. fmt.Println(res)
  12586. }
  12587. }
  12588. func (c *HisApiController) CheckCardPWD() {
  12589. card_pwd := c.GetString("card_pwd")
  12590. his_patient_id, _ := c.GetInt64("his_patient_id")
  12591. admin_user_id, _ := c.GetInt64("admin_user_id")
  12592. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12593. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12594. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12595. psn, _ := service.GetPsnByPatientId(his.PatientId)
  12596. bas := strings.Split(psn.CardInfo, "|")
  12597. basNumber := bas[2]
  12598. if psn.InsuplcAdmdvs[:4] == "4403" {
  12599. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  12600. var dat map[string]interface{}
  12601. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12602. fmt.Println(dat)
  12603. } else {
  12604. fmt.Println(err)
  12605. }
  12606. userJSONBytes, _ := json.Marshal(dat)
  12607. var res Result90991
  12608. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12609. utils.ErrorLog("解析失败:%v", err)
  12610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12611. return
  12612. }
  12613. if res.Infcode != 0 {
  12614. c.ServeSuccessJSON(map[string]interface{}{
  12615. "failed_code": -10,
  12616. "msg": res.ErrMsg,
  12617. })
  12618. return
  12619. } else {
  12620. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  12621. var msg string
  12622. switch res.Output.Result.CardStat {
  12623. case "00":
  12624. msg = "未激活"
  12625. break
  12626. case "10":
  12627. msg = "激活"
  12628. break
  12629. case "20":
  12630. msg = "窗口挂失"
  12631. break
  12632. case "21":
  12633. msg = "电话挂失"
  12634. break
  12635. case "22":
  12636. msg = "单位网上申报挂失"
  12637. break
  12638. case "23":
  12639. msg = "保健办挂失"
  12640. break
  12641. case "24":
  12642. msg = "个人网上挂失"
  12643. break
  12644. case "25":
  12645. msg = "网上服务大厅挂失"
  12646. break
  12647. case "30":
  12648. msg = "注销"
  12649. break
  12650. case "40":
  12651. msg = "回收"
  12652. break
  12653. case "99":
  12654. msg = "制卡中(无效卡)"
  12655. break
  12656. }
  12657. c.ServeSuccessJSON(map[string]interface{}{
  12658. "failed_code": -10,
  12659. "msg": msg,
  12660. })
  12661. return
  12662. } else {
  12663. c.ServeSuccessJSON(map[string]interface{}{
  12664. "msg": "校验成功",
  12665. })
  12666. return
  12667. }
  12668. }
  12669. } else {
  12670. c.ServeSuccessJSON(map[string]interface{}{
  12671. "msg": "校验成功",
  12672. })
  12673. return
  12674. }
  12675. }
  12676. func (c *HisApiController) CheckCardPWDTwo() {
  12677. //card_pwd := c.GetString("card_pwd")
  12678. //his_patient_id, _ := c.GetInt64("his_patient_id")
  12679. admin_user_id, _ := c.GetInt64("admin_user_id")
  12680. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12681. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12682. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  12683. var dat map[string]interface{}
  12684. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12685. fmt.Println(dat)
  12686. } else {
  12687. fmt.Println(err)
  12688. }
  12689. userJSONBytes, _ := json.Marshal(dat)
  12690. var res Result90991
  12691. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12692. utils.ErrorLog("解析失败:%v", err)
  12693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12694. return
  12695. }
  12696. if res.Infcode != 0 {
  12697. c.ServeSuccessJSON(map[string]interface{}{
  12698. "failed_code": -10,
  12699. "msg": res.ErrMsg,
  12700. })
  12701. return
  12702. } else {
  12703. if res.Output.Result.SscnoCheckStat == "0" {
  12704. var msg string
  12705. switch res.Output.Result.CardStat {
  12706. case "00":
  12707. msg = "未激活"
  12708. break
  12709. case "10":
  12710. msg = "激活"
  12711. break
  12712. case "20":
  12713. msg = "窗口挂失"
  12714. break
  12715. case "21":
  12716. msg = "电话挂失"
  12717. break
  12718. case "22":
  12719. msg = "单位网上申报挂失"
  12720. break
  12721. case "23":
  12722. msg = "保健办挂失"
  12723. break
  12724. case "24":
  12725. msg = "个人网上挂失"
  12726. break
  12727. case "25":
  12728. msg = "网上服务大厅挂失"
  12729. break
  12730. case "30":
  12731. msg = "注销"
  12732. break
  12733. case "40":
  12734. msg = "回收"
  12735. break
  12736. case "99":
  12737. msg = "制卡中(无效卡)"
  12738. break
  12739. }
  12740. c.ServeSuccessJSON(map[string]interface{}{
  12741. "failed_code": -10,
  12742. "msg": msg,
  12743. })
  12744. return
  12745. } else {
  12746. c.ServeSuccessJSON(map[string]interface{}{
  12747. "msg": "校验成功",
  12748. })
  12749. return
  12750. }
  12751. }
  12752. }
  12753. type ELeCertData struct {
  12754. Data struct {
  12755. Extra string `json:"extra"`
  12756. IDNo string `json:"idNo"`
  12757. IDType string `json:"idType"`
  12758. EcToken string `json:"ecToken"`
  12759. InsuOrg string `json:"insuOrg"`
  12760. UserName string `json:"userName"`
  12761. EcIndexNo string `json:"ecIndexNo"`
  12762. Gender string `json:"gender"`
  12763. Birthday string `json:"birthday"`
  12764. Nationality string `json:"nationality"`
  12765. Email string `json:"email"`
  12766. } `json:"OutData"`
  12767. }
  12768. func (c *HisApiController) ReadCard() {
  12769. id_card_type, _ := c.GetInt64("id_card_type")
  12770. admin_user_id, _ := c.GetInt64("admin_user_id")
  12771. certificates, _ := c.GetInt64("certificates")
  12772. //
  12773. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  12774. id_card_no := c.GetString("id_card_no")
  12775. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12776. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12777. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12778. switch id_card_type {
  12779. case 1:
  12780. if miConfig.MdtrtareaAdmvs == "421300" {
  12781. var res ResultTwo
  12782. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  12783. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12784. "&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)
  12785. resp, requestErr := http.Get(api)
  12786. if requestErr != nil {
  12787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12788. return
  12789. }
  12790. body, ioErr := ioutil.ReadAll(resp.Body)
  12791. if ioErr != nil {
  12792. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12794. return
  12795. }
  12796. var respJSON map[string]interface{}
  12797. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12798. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12800. return
  12801. }
  12802. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12803. result, _ := json.Marshal(respJSON)
  12804. fmt.Println("log")
  12805. fmt.Println(string(result))
  12806. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12807. utils.ErrorLog("解析失败:%v", err)
  12808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12809. return
  12810. }
  12811. if res.Infcode == 0 {
  12812. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12813. if err == gorm.ErrRecordNotFound {
  12814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12815. return
  12816. } else if err != nil {
  12817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12818. return
  12819. } else {
  12820. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12821. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12822. infoStr := string(Iinfos)
  12823. idetinfoStr := string(Idetinfos)
  12824. var rf []*ResultFive
  12825. json.Unmarshal([]byte(infoStr), &rf)
  12826. var insutypes []*ResultFive
  12827. var insutype string
  12828. var is390 int = 0
  12829. var is310 int = 0
  12830. for _, item := range rf {
  12831. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12832. insutypes = append(insutypes, item)
  12833. }
  12834. }
  12835. if len(insutypes) == 1 {
  12836. insutype = insutypes[0].Insutype
  12837. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12838. } else {
  12839. for _, i := range insutypes {
  12840. if i.Insutype == "390" {
  12841. is390 = 1
  12842. }
  12843. if i.Insutype == "310" {
  12844. is310 = 1
  12845. }
  12846. }
  12847. }
  12848. if is390 == 1 {
  12849. insutype = "390"
  12850. }
  12851. if is310 == 1 {
  12852. insutype = "310"
  12853. }
  12854. if len(insutypes) == 0 {
  12855. insutype = "390"
  12856. }
  12857. var insuplc_admdvs string
  12858. for _, item := range rf {
  12859. if item.Insutype == insutype {
  12860. insuplc_admdvs = item.InsuplcAdmdvs
  12861. }
  12862. }
  12863. if strings.Contains(insuplc_admdvs, "4213") {
  12864. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  12865. }
  12866. psn := &models.HisPsn{
  12867. PsnNo: res.Output.Baseinfo.PsnNo,
  12868. PatientId: patient.ID,
  12869. Certno: res.Output.Baseinfo.Certno,
  12870. Gend: res.Output.Baseinfo.Gend,
  12871. Naty: res.Output.Baseinfo.Naty,
  12872. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12873. PsnName: res.Output.Baseinfo.PsnName,
  12874. Idetinfo: idetinfoStr,
  12875. Insuinfo: infoStr,
  12876. InsuplcAdmdvs: insuplc_admdvs,
  12877. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12878. }
  12879. service.CreateHisPsn(psn)
  12880. c.ServeSuccessJSON(map[string]interface{}{
  12881. "patient": patient,
  12882. "number": res.Output.Baseinfo.Certno,
  12883. })
  12884. }
  12885. } else {
  12886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12887. return
  12888. }
  12889. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12890. var res ResultTwo
  12891. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  12892. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12893. "&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)
  12894. resp, requestErr := http.Get(api)
  12895. if requestErr != nil {
  12896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12897. return
  12898. }
  12899. body, ioErr := ioutil.ReadAll(resp.Body)
  12900. if ioErr != nil {
  12901. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12903. return
  12904. }
  12905. var respJSON map[string]interface{}
  12906. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12907. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12909. return
  12910. }
  12911. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12912. result, _ := json.Marshal(respJSON)
  12913. fmt.Println("log")
  12914. fmt.Println(string(result))
  12915. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12916. utils.ErrorLog("解析失败:%v", err)
  12917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12918. return
  12919. }
  12920. if res.Infcode == 0 {
  12921. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12922. if err == gorm.ErrRecordNotFound {
  12923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12924. return
  12925. } else if err != nil {
  12926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12927. return
  12928. } else {
  12929. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12930. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12931. infoStr := string(Iinfos)
  12932. idetinfoStr := string(Idetinfos)
  12933. psn := &models.HisPsn{
  12934. PsnNo: res.Output.Baseinfo.PsnNo,
  12935. PatientId: patient.ID,
  12936. Certno: res.Output.Baseinfo.Certno,
  12937. Gend: res.Output.Baseinfo.Gend,
  12938. Naty: res.Output.Baseinfo.Naty,
  12939. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12940. PsnName: res.Output.Baseinfo.PsnName,
  12941. Idetinfo: idetinfoStr,
  12942. Insuinfo: infoStr,
  12943. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12944. }
  12945. service.CreateHisPsn(psn)
  12946. var rf []*ResultFive
  12947. json.Unmarshal([]byte(infoStr), &rf)
  12948. var insutypes []*ResultFive
  12949. var insutype string
  12950. var is390 int = 0
  12951. var is310 int = 0
  12952. for _, item := range rf {
  12953. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12954. insutypes = append(insutypes, item)
  12955. }
  12956. }
  12957. if len(insutypes) == 1 {
  12958. insutype = insutypes[0].Insutype
  12959. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12960. } else {
  12961. for _, i := range insutypes {
  12962. if i.Insutype == "390" {
  12963. is390 = 1
  12964. }
  12965. if i.Insutype == "310" {
  12966. is310 = 1
  12967. }
  12968. }
  12969. }
  12970. if is390 == 1 {
  12971. insutype = "390"
  12972. }
  12973. if is310 == 1 {
  12974. insutype = "310"
  12975. }
  12976. if len(insutypes) == 0 {
  12977. insutype = "310"
  12978. }
  12979. c.ServeSuccessJSON(map[string]interface{}{
  12980. "patient": patient,
  12981. "number": res.Output.Baseinfo.Certno,
  12982. "insutype": insutype,
  12983. })
  12984. }
  12985. } else {
  12986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12987. return
  12988. }
  12989. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12990. var res ResultTwo
  12991. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  12992. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12993. "&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)
  12994. resp, requestErr := http.Get(api)
  12995. if requestErr != nil {
  12996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12997. return
  12998. }
  12999. body, ioErr := ioutil.ReadAll(resp.Body)
  13000. if ioErr != nil {
  13001. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13003. return
  13004. }
  13005. var respJSON map[string]interface{}
  13006. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13009. return
  13010. }
  13011. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13012. result, _ := json.Marshal(respJSON)
  13013. fmt.Println("log")
  13014. fmt.Println(string(result))
  13015. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13016. utils.ErrorLog("解析失败:%v", err)
  13017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13018. return
  13019. }
  13020. if res.Infcode == 0 {
  13021. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13022. if err == gorm.ErrRecordNotFound {
  13023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13024. return
  13025. } else if err != nil {
  13026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13027. return
  13028. } else {
  13029. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13030. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13031. infoStr := string(Iinfos)
  13032. idetinfoStr := string(Idetinfos)
  13033. var rf []*ResultFive
  13034. json.Unmarshal([]byte(infoStr), &rf)
  13035. var insutypes []*ResultFive
  13036. var insutype string
  13037. var is390 int = 0
  13038. var is310 int = 0
  13039. for _, item := range rf {
  13040. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13041. insutypes = append(insutypes, item)
  13042. }
  13043. }
  13044. if len(insutypes) == 1 {
  13045. insutype = insutypes[0].Insutype
  13046. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13047. } else {
  13048. for _, i := range insutypes {
  13049. if i.Insutype == "390" {
  13050. is390 = 1
  13051. }
  13052. if i.Insutype == "310" {
  13053. is310 = 1
  13054. }
  13055. }
  13056. }
  13057. if is390 == 1 {
  13058. insutype = "390"
  13059. }
  13060. if is310 == 1 {
  13061. insutype = "310"
  13062. }
  13063. if len(insutypes) == 0 {
  13064. insutype = "390"
  13065. }
  13066. var insuplc_admdvs string
  13067. for _, item := range rf {
  13068. if item.Insutype == insutype {
  13069. insuplc_admdvs = item.InsuplcAdmdvs
  13070. }
  13071. }
  13072. psn := &models.HisPsn{
  13073. PsnNo: res.Output.Baseinfo.PsnNo,
  13074. PatientId: patient.ID,
  13075. Certno: res.Output.Baseinfo.Certno,
  13076. Gend: res.Output.Baseinfo.Gend,
  13077. Naty: res.Output.Baseinfo.Naty,
  13078. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13079. PsnName: res.Output.Baseinfo.PsnName,
  13080. Idetinfo: idetinfoStr,
  13081. Insuinfo: infoStr,
  13082. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13083. InsuplcAdmdvs: insuplc_admdvs,
  13084. }
  13085. service.CreateHisPsn(psn)
  13086. for _, item := range rf {
  13087. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13088. insutypes = append(insutypes, item)
  13089. }
  13090. }
  13091. if len(insutypes) == 1 {
  13092. insutype = insutypes[0].Insutype
  13093. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13094. } else {
  13095. for _, i := range insutypes {
  13096. if i.Insutype == "390" {
  13097. is390 = 1
  13098. }
  13099. if i.Insutype == "310" {
  13100. is310 = 1
  13101. }
  13102. }
  13103. }
  13104. if is390 == 1 {
  13105. insutype = "390"
  13106. }
  13107. if is310 == 1 {
  13108. insutype = "310"
  13109. }
  13110. if len(insutypes) == 0 {
  13111. insutype = "310"
  13112. }
  13113. c.ServeSuccessJSON(map[string]interface{}{
  13114. "patient": patient,
  13115. "number": res.Output.Baseinfo.Certno,
  13116. "insutype": insutype,
  13117. })
  13118. }
  13119. } else {
  13120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13121. return
  13122. }
  13123. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13124. var res ResultTwo
  13125. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  13126. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13127. "&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)
  13128. resp, requestErr := http.Get(api)
  13129. if requestErr != nil {
  13130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13131. return
  13132. }
  13133. body, ioErr := ioutil.ReadAll(resp.Body)
  13134. if ioErr != nil {
  13135. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13137. return
  13138. }
  13139. var respJSON map[string]interface{}
  13140. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13143. return
  13144. }
  13145. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13146. result, _ := json.Marshal(respJSON)
  13147. fmt.Println("log")
  13148. fmt.Println(string(result))
  13149. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13150. utils.ErrorLog("解析失败:%v", err)
  13151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13152. return
  13153. }
  13154. if res.Infcode == 0 {
  13155. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13156. if err == gorm.ErrRecordNotFound {
  13157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13158. return
  13159. } else if err != nil {
  13160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13161. return
  13162. } else {
  13163. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13164. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13165. infoStr := string(Iinfos)
  13166. idetinfoStr := string(Idetinfos)
  13167. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13168. psn := &models.HisPsn{
  13169. PsnNo: res.Output.Baseinfo.PsnNo,
  13170. PatientId: patient.ID,
  13171. Certno: res.Output.Baseinfo.Certno,
  13172. Brdy: b,
  13173. Age: float64(age),
  13174. Gend: res.Output.Baseinfo.Gend,
  13175. Naty: res.Output.Baseinfo.Naty,
  13176. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13177. PsnName: res.Output.Baseinfo.PsnName,
  13178. Idetinfo: idetinfoStr,
  13179. Insuinfo: infoStr,
  13180. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13181. }
  13182. service.CreateHisPsn(psn)
  13183. var rf []*ResultFive
  13184. json.Unmarshal([]byte(infoStr), &rf)
  13185. var insutypes []*ResultFive
  13186. var insutype string
  13187. var is390 int = 0
  13188. var is310 int = 0
  13189. for _, item := range rf {
  13190. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13191. insutypes = append(insutypes, item)
  13192. }
  13193. }
  13194. if len(insutypes) == 1 {
  13195. insutype = insutypes[0].Insutype
  13196. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13197. } else {
  13198. for _, i := range insutypes {
  13199. if i.Insutype == "390" {
  13200. is390 = 1
  13201. }
  13202. if i.Insutype == "310" {
  13203. is310 = 1
  13204. }
  13205. }
  13206. }
  13207. if is390 == 1 {
  13208. insutype = "390"
  13209. }
  13210. if is310 == 1 {
  13211. insutype = "310"
  13212. }
  13213. if len(insutypes) == 0 {
  13214. insutype = "310"
  13215. }
  13216. c.ServeSuccessJSON(map[string]interface{}{
  13217. "patient": patient,
  13218. "number": res.Output.Baseinfo.Certno,
  13219. "insutype": insutype,
  13220. })
  13221. }
  13222. } else {
  13223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13224. return
  13225. }
  13226. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13227. var api string
  13228. if miConfig.MdtrtareaAdmvs == "320921" {
  13229. 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 +
  13230. "&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
  13231. fmt.Println(api)
  13232. } else {
  13233. 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 +
  13234. "&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)
  13235. }
  13236. resp, requestErr := http.Get(api)
  13237. if requestErr != nil {
  13238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13239. return
  13240. }
  13241. body, ioErr := ioutil.ReadAll(resp.Body)
  13242. if ioErr != nil {
  13243. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13245. return
  13246. }
  13247. var respJSON map[string]interface{}
  13248. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13249. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13251. return
  13252. }
  13253. var status string
  13254. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13255. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13256. //console.log()
  13257. fmt.Println("type===")
  13258. fmt.Println(card_type)
  13259. var token string
  13260. var res ResultTwo //1101结果
  13261. var res10265 ResultTwo10265 //1101结果
  13262. var card_info string //卡信息
  13263. var busi_card_info string
  13264. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13265. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13266. if status == "0" { //读卡成功
  13267. if card_type == "1" {
  13268. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13269. result, _ := json.Marshal(respJSON)
  13270. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13271. utils.ErrorLog("解析失败:%v", err)
  13272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13273. return
  13274. }
  13275. res.ErrMsg = res10265.ErrMsg
  13276. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13277. res.Infcode = infocode
  13278. res.Output = res10265.Output
  13279. res.InfRefmsgid = res10265.InfRefmsgid
  13280. } else {
  13281. //var card_info string //卡信息
  13282. //var busi_card_info string
  13283. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13284. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13285. //fmt.Println(card_info)
  13286. //fmt.Println(busi_card_info)
  13287. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13288. result, _ := json.Marshal(respJSON)
  13289. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13290. utils.ErrorLog("解析失败:%v", err)
  13291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13292. return
  13293. }
  13294. res.ErrMsg = res10265.ErrMsg
  13295. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13296. res.Infcode = infocode
  13297. res.Output = res10265.Output
  13298. res.InfRefmsgid = res10265.InfRefmsgid
  13299. }
  13300. if res.Infcode == 0 {
  13301. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13302. if err == gorm.ErrRecordNotFound {
  13303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13304. return
  13305. } else if err != nil {
  13306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13307. return
  13308. } else {
  13309. if card_type == "1" {
  13310. bas := strings.Split(card_info, "|")
  13311. basNumber := bas[2]
  13312. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13313. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13314. infoStr := string(Iinfos)
  13315. idetinfoStr := string(Idetinfos)
  13316. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13317. psn := &models.HisPsn{
  13318. PsnNo: res.Output.Baseinfo.PsnNo,
  13319. PatientId: patient.ID,
  13320. Certno: res.Output.Baseinfo.Certno,
  13321. Brdy: b,
  13322. Age: float64(age),
  13323. Gend: res.Output.Baseinfo.Gend,
  13324. Naty: res.Output.Baseinfo.Naty,
  13325. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13326. PsnName: res.Output.Baseinfo.PsnName,
  13327. Idetinfo: idetinfoStr,
  13328. Insuinfo: infoStr,
  13329. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13330. CardInfo: card_info,
  13331. VerifyNumber: busi_card_info,
  13332. }
  13333. service.CreateHisPsn(psn)
  13334. var rf []*ResultFive
  13335. json.Unmarshal([]byte(infoStr), &rf)
  13336. var insutypes []*ResultFive
  13337. var insutype string
  13338. var is390 int = 0
  13339. var is310 int = 0
  13340. for _, item := range rf {
  13341. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13342. insutypes = append(insutypes, item)
  13343. }
  13344. }
  13345. if len(insutypes) == 1 {
  13346. insutype = insutypes[0].Insutype
  13347. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13348. } else {
  13349. for _, i := range insutypes {
  13350. if i.Insutype == "390" {
  13351. is390 = 1
  13352. }
  13353. if i.Insutype == "310" {
  13354. is310 = 1
  13355. }
  13356. }
  13357. }
  13358. if is390 == 1 {
  13359. insutype = "390"
  13360. }
  13361. if is310 == 1 {
  13362. insutype = "310"
  13363. }
  13364. if len(insutypes) == 0 {
  13365. insutype = "310"
  13366. }
  13367. c.ServeSuccessJSON(map[string]interface{}{
  13368. "patient": patient,
  13369. "number": basNumber,
  13370. "insutype": insutype,
  13371. })
  13372. } else {
  13373. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13374. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13375. infoStr := string(Iinfos)
  13376. idetinfoStr := string(Idetinfos)
  13377. psn := &models.HisPsn{
  13378. PsnNo: res.Output.Baseinfo.PsnNo,
  13379. PatientId: patient.ID,
  13380. Certno: res.Output.Baseinfo.Certno,
  13381. Gend: res.Output.Baseinfo.Gend,
  13382. Naty: res.Output.Baseinfo.Naty,
  13383. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13384. PsnName: res.Output.Baseinfo.PsnName,
  13385. Idetinfo: idetinfoStr,
  13386. Insuinfo: infoStr,
  13387. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13388. CardInfo: card_info,
  13389. VerifyNumber: token,
  13390. }
  13391. service.CreateHisPsn(psn)
  13392. c.ServeSuccessJSON(map[string]interface{}{
  13393. "patient": patient,
  13394. "number": token,
  13395. })
  13396. }
  13397. }
  13398. } else {
  13399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13400. return
  13401. }
  13402. } else { //读卡失败
  13403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13404. return
  13405. }
  13406. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13407. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  13408. cardnum = DeleteExtraSpaceTwo(cardnum)
  13409. cardCode = DeleteExtraSpaceTwo(cardCode)
  13410. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  13411. name = DeleteExtraSpaceTwo(name)
  13412. errmsg = DeleteExtraSpaceTwo(errmsg)
  13413. cardnum = Remove0000(cardnum)
  13414. cardCode = Remove0000(cardCode)
  13415. id_card_no = Remove0000(id_card_no)
  13416. name = Remove0000(name)
  13417. errmsg = Remove0000(errmsg)
  13418. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  13419. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  13420. //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)
  13421. //fmt.Println(result2)
  13422. //fmt.Println(requestLog2)
  13423. //fmt.Println(errMsgLog2)
  13424. 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)
  13425. saveLog(result, requestLog, "1101", "获取人员信息")
  13426. fmt.Println(errMsgLog)
  13427. if len(errMsgLog) > 0 {
  13428. } else {
  13429. var dat map[string]interface{}
  13430. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13431. fmt.Println(dat)
  13432. } else {
  13433. fmt.Println(err)
  13434. }
  13435. userJSONBytes, _ := json.Marshal(dat)
  13436. var res ResultTwo
  13437. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13438. utils.ErrorLog("解析失败:%v", err)
  13439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13440. return
  13441. }
  13442. res.ErrMsg = errMsgLog
  13443. if res.Infcode == 0 {
  13444. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13445. if err == gorm.ErrRecordNotFound {
  13446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13447. return
  13448. } else if err != nil {
  13449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13450. return
  13451. } else {
  13452. fmt.Println(res)
  13453. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13454. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13455. infoStr := string(Iinfos)
  13456. idetinfoStr := string(Idetinfos)
  13457. var rf []*ResultFive
  13458. json.Unmarshal([]byte(infoStr), &rf)
  13459. var insutypes []*ResultFive
  13460. var insutype string
  13461. var is390 int = 0
  13462. var is310 int = 0
  13463. for _, item := range rf {
  13464. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13465. insutypes = append(insutypes, item)
  13466. }
  13467. }
  13468. if len(insutypes) == 1 {
  13469. insutype = insutypes[0].Insutype
  13470. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13471. } else {
  13472. for _, i := range insutypes {
  13473. if i.Insutype == "390" {
  13474. is390 = 1
  13475. }
  13476. if i.Insutype == "310" {
  13477. is310 = 1
  13478. }
  13479. }
  13480. }
  13481. if is390 == 1 {
  13482. insutype = "390"
  13483. }
  13484. if is310 == 1 {
  13485. insutype = "310"
  13486. }
  13487. if len(insutypes) == 0 {
  13488. insutype = "390"
  13489. }
  13490. var insuplc_admdvs string
  13491. for _, item := range rf {
  13492. if item.Insutype == insutype {
  13493. insuplc_admdvs = item.InsuplcAdmdvs
  13494. }
  13495. }
  13496. psn := &models.HisPsn{
  13497. PsnNo: res.Output.Baseinfo.PsnNo,
  13498. PatientId: patient.ID,
  13499. Certno: res.Output.Baseinfo.Certno,
  13500. Gend: res.Output.Baseinfo.Gend,
  13501. Naty: res.Output.Baseinfo.Naty,
  13502. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13503. PsnName: res.Output.Baseinfo.PsnName,
  13504. Idetinfo: idetinfoStr,
  13505. Insuinfo: infoStr,
  13506. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13507. CardInfo: basStr,
  13508. VerifyNumber: "",
  13509. InsuplcAdmdvs: insuplc_admdvs,
  13510. }
  13511. service.CreateHisPsn(psn)
  13512. c.ServeSuccessJSON(map[string]interface{}{
  13513. "patient": patient,
  13514. "number": cardnum,
  13515. "insutype": insutype,
  13516. })
  13517. }
  13518. } else {
  13519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13520. return
  13521. }
  13522. }
  13523. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13524. fmt.Println(initFlag)
  13525. fmt.Println("initFlag")
  13526. if initFlag == 0 {
  13527. c.TestGetJiangXiBasBaseInit()
  13528. }
  13529. basStr := c.GetBasBaseInfo()
  13530. if len(basStr) == 0 {
  13531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13532. return
  13533. }
  13534. fmt.Println(basStr)
  13535. bas := strings.Split(basStr, "|")
  13536. basNumber := bas[1]
  13537. fmt.Println(basNumber)
  13538. card_sn := bas[3]
  13539. fmt.Println(card_sn)
  13540. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13541. 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)
  13542. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13543. var dat map[string]interface{}
  13544. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13545. fmt.Println(dat)
  13546. } else {
  13547. fmt.Println(err)
  13548. }
  13549. userJSONBytes, _ := json.Marshal(dat)
  13550. var res ResultTwo
  13551. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13552. utils.ErrorLog("解析失败:%v", err)
  13553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13554. return
  13555. }
  13556. if res.Infcode == 0 {
  13557. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13558. if err == gorm.ErrRecordNotFound {
  13559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13560. return
  13561. } else if err != nil {
  13562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13563. return
  13564. } else {
  13565. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13566. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13567. infoStr := string(Iinfos)
  13568. idetinfoStr := string(Idetinfos)
  13569. var rf []*ResultFive
  13570. json.Unmarshal([]byte(infoStr), &rf)
  13571. var insutypes []*ResultFive
  13572. var insutype string
  13573. var is390 int = 0
  13574. var is310 int = 0
  13575. var insuplc_admdvs string
  13576. for _, item := range rf {
  13577. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13578. insutypes = append(insutypes, item)
  13579. }
  13580. }
  13581. if len(insutypes) == 1 {
  13582. insutype = insutypes[0].Insutype
  13583. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13584. } else {
  13585. for _, i := range insutypes {
  13586. if i.Insutype == "390" {
  13587. is390 = 1
  13588. }
  13589. if i.Insutype == "310" {
  13590. is310 = 1
  13591. }
  13592. }
  13593. }
  13594. if is390 == 1 {
  13595. insutype = "390"
  13596. }
  13597. if is310 == 1 {
  13598. insutype = "310"
  13599. }
  13600. if len(insutypes) == 0 {
  13601. insutype = "310"
  13602. }
  13603. for _, item := range rf {
  13604. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13605. insuplc_admdvs = item.InsuplcAdmdvs
  13606. }
  13607. }
  13608. psn := &models.HisPsn{
  13609. PsnNo: res.Output.Baseinfo.PsnNo,
  13610. PatientId: patient.ID,
  13611. Certno: res.Output.Baseinfo.Certno,
  13612. Gend: res.Output.Baseinfo.Gend,
  13613. Naty: res.Output.Baseinfo.Naty,
  13614. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13615. PsnName: res.Output.Baseinfo.PsnName,
  13616. Idetinfo: idetinfoStr,
  13617. Insuinfo: infoStr,
  13618. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13619. CardInfo: basStr,
  13620. InsuplcAdmdvs: insuplc_admdvs,
  13621. VerifyNumber: "",
  13622. }
  13623. service.CreateHisPsn(psn)
  13624. c.ServeSuccessJSON(map[string]interface{}{
  13625. "patient": patient,
  13626. "number": basNumber,
  13627. "insutype": insutype,
  13628. })
  13629. }
  13630. } else {
  13631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13632. return
  13633. }
  13634. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13635. basStr := c.GetBasBaseInfo22222()
  13636. fmt.Println(basStr)
  13637. if len(basStr) == 0 {
  13638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13639. return
  13640. }
  13641. fmt.Println(basStr)
  13642. bas := strings.Split(basStr, "|")
  13643. basNumber := bas[2] //卡号
  13644. card_sn := bas[3] //
  13645. id_card_No := bas[1] //卡号
  13646. fmt.Println(basNumber)
  13647. fmt.Println(card_sn)
  13648. fmt.Println(id_card_No)
  13649. var patient service.Patients
  13650. if len(id_card_No) == 0 {
  13651. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13652. } else {
  13653. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13654. }
  13655. 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)
  13656. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13657. var dat map[string]interface{}
  13658. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13659. fmt.Println(dat)
  13660. } else {
  13661. fmt.Println(err)
  13662. }
  13663. userJSONBytes, _ := json.Marshal(dat)
  13664. var res ResultTwo
  13665. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13666. utils.ErrorLog("解析失败:%v", err)
  13667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13668. return
  13669. }
  13670. if res.Infcode == 0 {
  13671. var pateint2 service.Patients
  13672. var err error
  13673. if len(id_card_No) == 0 {
  13674. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13675. } else {
  13676. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13677. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  13678. }
  13679. if err == gorm.ErrRecordNotFound {
  13680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13681. return
  13682. } else if err != nil {
  13683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13684. return
  13685. } else {
  13686. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13687. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13688. infoStr := string(Iinfos)
  13689. idetinfoStr := string(Idetinfos)
  13690. var rf []*ResultFive
  13691. json.Unmarshal([]byte(infoStr), &rf)
  13692. var insutypes []*ResultFive
  13693. var insutype string
  13694. var is390 int = 0
  13695. var is310 int = 0
  13696. var insuplc_admdvs string
  13697. for _, item := range rf {
  13698. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13699. insutypes = append(insutypes, item)
  13700. }
  13701. }
  13702. if len(insutypes) == 1 {
  13703. insutype = insutypes[0].Insutype
  13704. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13705. } else {
  13706. for _, i := range insutypes {
  13707. if i.Insutype == "390" {
  13708. is390 = 1
  13709. }
  13710. if i.Insutype == "310" {
  13711. is310 = 1
  13712. }
  13713. }
  13714. }
  13715. if is390 == 1 {
  13716. insutype = "390"
  13717. }
  13718. if is310 == 1 {
  13719. insutype = "310"
  13720. }
  13721. if len(insutypes) == 0 {
  13722. insutype = "310"
  13723. }
  13724. for _, item := range rf {
  13725. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  13726. insuplc_admdvs = item.InsuplcAdmdvs
  13727. }
  13728. }
  13729. psn := &models.HisPsn{
  13730. PsnNo: res.Output.Baseinfo.PsnNo,
  13731. PatientId: pateint2.ID,
  13732. Certno: res.Output.Baseinfo.Certno,
  13733. Gend: res.Output.Baseinfo.Gend,
  13734. Naty: res.Output.Baseinfo.Naty,
  13735. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13736. PsnName: res.Output.Baseinfo.PsnName,
  13737. Idetinfo: idetinfoStr,
  13738. Insuinfo: infoStr,
  13739. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13740. CardInfo: basStr,
  13741. InsuplcAdmdvs: insuplc_admdvs,
  13742. VerifyNumber: "",
  13743. }
  13744. service.CreateHisPsn(psn)
  13745. c.ServeSuccessJSON(map[string]interface{}{
  13746. "patient": patient,
  13747. "number": basNumber,
  13748. "insutype": insutype,
  13749. })
  13750. }
  13751. } else {
  13752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13753. return
  13754. }
  13755. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13756. fmt.Println(initFlag)
  13757. fmt.Println("initFlag")
  13758. if initFlag == 0 {
  13759. c.TestGetHnBasBaseInit()
  13760. }
  13761. basStr := c.GetBasBaseInfo()
  13762. if len(basStr) == 0 {
  13763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13764. return
  13765. }
  13766. fmt.Println(basStr)
  13767. bas := strings.Split(basStr, "|")
  13768. basNumber := bas[1]
  13769. fmt.Println(basNumber)
  13770. card_sn := bas[3]
  13771. card_no := bas[2]
  13772. fmt.Println(card_sn)
  13773. name := bas[4]
  13774. name = ConvertToString(name, "gbk", "utf-8")
  13775. 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)
  13776. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  13777. var dat map[string]interface{}
  13778. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13779. fmt.Println(dat)
  13780. } else {
  13781. fmt.Println(err)
  13782. }
  13783. userJSONBytes, _ := json.Marshal(dat)
  13784. var res ResultTwo
  13785. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13786. utils.ErrorLog("解析失败:%v", err)
  13787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13788. return
  13789. }
  13790. if res.Infcode == 0 {
  13791. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13792. if err == gorm.ErrRecordNotFound {
  13793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13794. return
  13795. } else if err != nil {
  13796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13797. return
  13798. } else {
  13799. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13800. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13801. infoStr := string(Iinfos)
  13802. idetinfoStr := string(Idetinfos)
  13803. psn := &models.HisPsn{
  13804. PsnNo: res.Output.Baseinfo.PsnNo,
  13805. PatientId: patient.ID,
  13806. Certno: res.Output.Baseinfo.Certno,
  13807. Gend: res.Output.Baseinfo.Gend,
  13808. Naty: res.Output.Baseinfo.Naty,
  13809. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13810. PsnName: res.Output.Baseinfo.PsnName,
  13811. Idetinfo: idetinfoStr,
  13812. Insuinfo: infoStr,
  13813. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13814. CardInfo: basStr,
  13815. VerifyNumber: "",
  13816. }
  13817. service.CreateHisPsn(psn)
  13818. var rf []*ResultFive
  13819. json.Unmarshal([]byte(infoStr), &rf)
  13820. var insutypes []*ResultFive
  13821. var insutype string
  13822. var is390 int = 0
  13823. var is310 int = 0
  13824. for _, item := range rf {
  13825. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13826. insutypes = append(insutypes, item)
  13827. }
  13828. }
  13829. if len(insutypes) == 1 {
  13830. insutype = insutypes[0].Insutype
  13831. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13832. } else {
  13833. for _, i := range insutypes {
  13834. if i.Insutype == "390" {
  13835. is390 = 1
  13836. }
  13837. if i.Insutype == "310" {
  13838. is310 = 1
  13839. }
  13840. }
  13841. }
  13842. if is390 == 1 {
  13843. insutype = "390"
  13844. }
  13845. if is310 == 1 {
  13846. insutype = "310"
  13847. }
  13848. if len(insutypes) == 0 {
  13849. insutype = "310"
  13850. }
  13851. c.ServeSuccessJSON(map[string]interface{}{
  13852. "patient": patient,
  13853. "number": basNumber,
  13854. "insutype": insutype,
  13855. })
  13856. }
  13857. } else {
  13858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13859. return
  13860. }
  13861. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13862. var api string
  13863. 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 +
  13864. "&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
  13865. fmt.Println(api)
  13866. resp, requestErr := http.Get(api)
  13867. if requestErr != nil {
  13868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13869. return
  13870. }
  13871. body, ioErr := ioutil.ReadAll(resp.Body)
  13872. if ioErr != nil {
  13873. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13875. return
  13876. }
  13877. var respJSON map[string]interface{}
  13878. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13879. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13881. return
  13882. }
  13883. var res ResultTwo //1101结果
  13884. var res10265 ResultTwo10265 //1101结果
  13885. var card_info string //卡信息
  13886. token := respJSON["data"].(map[string]interface{})["token"].(string)
  13887. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13888. result, _ := json.Marshal(respJSON)
  13889. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13890. utils.ErrorLog("解析失败:%v", err)
  13891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13892. return
  13893. }
  13894. res.ErrMsg = res10265.ErrMsg
  13895. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13896. res.Infcode = infocode
  13897. res.Output = res10265.Output
  13898. res.InfRefmsgid = res10265.InfRefmsgid
  13899. if res.Infcode == 0 {
  13900. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13901. if err == gorm.ErrRecordNotFound {
  13902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13903. return
  13904. } else if err != nil {
  13905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13906. return
  13907. } else {
  13908. bas := strings.Split(card_info, "|")
  13909. basNumber := bas[2]
  13910. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13911. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13912. infoStr := string(Iinfos)
  13913. idetinfoStr := string(Idetinfos)
  13914. psn := &models.HisPsn{
  13915. PsnNo: res.Output.Baseinfo.PsnNo,
  13916. PatientId: patient.ID,
  13917. Certno: res.Output.Baseinfo.Certno,
  13918. Gend: res.Output.Baseinfo.Gend,
  13919. Naty: res.Output.Baseinfo.Naty,
  13920. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13921. PsnName: res.Output.Baseinfo.PsnName,
  13922. Idetinfo: idetinfoStr,
  13923. Insuinfo: infoStr,
  13924. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13925. CardInfo: card_info,
  13926. VerifyNumber: token,
  13927. }
  13928. service.CreateHisPsn(psn)
  13929. var rf []*ResultFive
  13930. json.Unmarshal([]byte(infoStr), &rf)
  13931. var insutypes []*ResultFive
  13932. var insutype string
  13933. var is390 int = 0
  13934. var is310 int = 0
  13935. for _, item := range rf {
  13936. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13937. insutypes = append(insutypes, item)
  13938. }
  13939. }
  13940. if len(insutypes) == 1 {
  13941. insutype = insutypes[0].Insutype
  13942. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13943. } else {
  13944. for _, i := range insutypes {
  13945. if i.Insutype == "390" {
  13946. is390 = 1
  13947. }
  13948. if i.Insutype == "310" {
  13949. is310 = 1
  13950. }
  13951. }
  13952. }
  13953. if is390 == 1 {
  13954. insutype = "390"
  13955. }
  13956. if is310 == 1 {
  13957. insutype = "310"
  13958. }
  13959. if len(insutypes) == 0 {
  13960. insutype = "310"
  13961. }
  13962. c.ServeSuccessJSON(map[string]interface{}{
  13963. "patient": patient,
  13964. "number": basNumber,
  13965. "insutype": insutype,
  13966. })
  13967. }
  13968. } else {
  13969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13970. return
  13971. }
  13972. } else if miConfig.MdtrtareaAdmvs == "450721" {
  13973. res := c.GetoleInfo()
  13974. if res.Infcode == 0 {
  13975. var result string
  13976. if res.Output.MdtrtCertType == "01" {
  13977. 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)
  13978. } else if res.Output.MdtrtCertType == "02" {
  13979. 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)
  13980. } else if res.Output.MdtrtCertType == "03" {
  13981. 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)
  13982. }
  13983. var dat map[string]interface{}
  13984. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13985. fmt.Println(dat)
  13986. } else {
  13987. fmt.Println(err)
  13988. }
  13989. userJSONBytes, _ := json.Marshal(dat)
  13990. var res2 ResultTwo
  13991. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13992. utils.ErrorLog("解析失败:%v", err)
  13993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13994. return
  13995. }
  13996. if res2.Infcode == 0 {
  13997. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  13998. if err == gorm.ErrRecordNotFound {
  13999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14000. return
  14001. } else if err != nil {
  14002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14003. return
  14004. } else {
  14005. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14006. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14007. infoStr := string(Iinfos)
  14008. idetinfoStr := string(Idetinfos)
  14009. var rf []*ResultFive
  14010. json.Unmarshal([]byte(infoStr), &rf)
  14011. var insutypes []*ResultFive
  14012. var insutype string
  14013. var is390 int = 0
  14014. var is310 int = 0
  14015. //var insuplc_admdvs string
  14016. for _, item := range rf {
  14017. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14018. insutypes = append(insutypes, item)
  14019. }
  14020. }
  14021. if len(insutypes) == 1 {
  14022. insutype = insutypes[0].Insutype
  14023. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14024. } else {
  14025. for _, i := range insutypes {
  14026. if i.Insutype == "390" {
  14027. is390 = 1
  14028. }
  14029. if i.Insutype == "310" {
  14030. is310 = 1
  14031. }
  14032. }
  14033. }
  14034. if is390 == 1 {
  14035. insutype = "390"
  14036. }
  14037. if is310 == 1 {
  14038. insutype = "310"
  14039. }
  14040. if len(insutypes) == 0 {
  14041. insutype = "310"
  14042. }
  14043. psn := &models.HisPsn{
  14044. PsnNo: res2.Output.Baseinfo.PsnNo,
  14045. PatientId: patient.ID,
  14046. Certno: res2.Output.Baseinfo.Certno,
  14047. Gend: res2.Output.Baseinfo.Gend,
  14048. Naty: res2.Output.Baseinfo.Naty,
  14049. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14050. PsnName: res2.Output.Baseinfo.PsnName,
  14051. Idetinfo: idetinfoStr,
  14052. Insuinfo: infoStr,
  14053. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14054. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14055. VerifyNumber: res.Output.EcToken,
  14056. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14057. }
  14058. if res.Output.MdtrtCertType == "01" {
  14059. psn.VerifyNumber = res.Output.EcToken
  14060. //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)
  14061. } else if res.Output.MdtrtCertType == "02" {
  14062. psn.VerifyNumber = res.Output.MdtrtCertNo
  14063. //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)
  14064. } else if res.Output.MdtrtCertType == "03" {
  14065. psn.VerifyNumber = res.Output.MdtrtCertNo
  14066. //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)
  14067. }
  14068. var balc float64
  14069. for _, item := range rf {
  14070. if item.Insutype == insutype {
  14071. balc = item.Balc
  14072. }
  14073. }
  14074. service.CreateHisPsn(psn)
  14075. c.ServeSuccessJSON(map[string]interface{}{
  14076. "patient": patient,
  14077. "number": res.Output.CardNo,
  14078. "insutype": insutype,
  14079. "blac": balc,
  14080. "desc": idetinfoStr,
  14081. })
  14082. }
  14083. } else {
  14084. c.ServeSuccessJSON(map[string]interface{}{
  14085. "failed_code": -10,
  14086. "msg": res2.ErrMsg,
  14087. })
  14088. }
  14089. } else {
  14090. c.ServeSuccessJSON(map[string]interface{}{
  14091. "failed_code": -10,
  14092. "msg": res.ErrMsg,
  14093. })
  14094. }
  14095. } else if miConfig.MdtrtareaAdmvs == "341203" {
  14096. var api string
  14097. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14098. "&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
  14099. fmt.Println(api)
  14100. resp, requestErr := http.Get(api)
  14101. if requestErr != nil {
  14102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14103. return
  14104. }
  14105. body, ioErr := ioutil.ReadAll(resp.Body)
  14106. if ioErr != nil {
  14107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14109. return
  14110. }
  14111. var respJSON map[string]interface{}
  14112. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14115. return
  14116. }
  14117. var status string
  14118. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14119. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14120. //console.log()
  14121. fmt.Println("type===")
  14122. fmt.Println(card_type)
  14123. var token string
  14124. var res ResultTwo //1101结果
  14125. //var res10265 ResultTwoesultTwo10265 //1101结果
  14126. var card_info string //卡信息
  14127. var busi_card_info string
  14128. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14129. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14130. if status == "0" { //读卡成功
  14131. if card_type == "1" {
  14132. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14133. result, _ := json.Marshal(respJSON)
  14134. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14135. utils.ErrorLog("解析失败:%v", err)
  14136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14137. return
  14138. }
  14139. } else {
  14140. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14141. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14142. result, _ := json.Marshal(respJSON)
  14143. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14144. utils.ErrorLog("解析失败:%v", err)
  14145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14146. return
  14147. }
  14148. }
  14149. if res.Infcode == 0 {
  14150. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14151. if err == gorm.ErrRecordNotFound {
  14152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14153. return
  14154. } else if err != nil {
  14155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14156. return
  14157. } else {
  14158. if card_type == "1" {
  14159. bas := strings.Split(card_info, "|")
  14160. basNumber := bas[2]
  14161. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14162. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14163. infoStr := string(Iinfos)
  14164. idetinfoStr := string(Idetinfos)
  14165. psn := &models.HisPsn{
  14166. PsnNo: res.Output.Baseinfo.PsnNo,
  14167. PatientId: patient.ID,
  14168. Certno: res.Output.Baseinfo.Certno,
  14169. Gend: res.Output.Baseinfo.Gend,
  14170. Naty: res.Output.Baseinfo.Naty,
  14171. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14172. PsnName: res.Output.Baseinfo.PsnName,
  14173. Idetinfo: idetinfoStr,
  14174. Insuinfo: infoStr,
  14175. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14176. CardInfo: card_info,
  14177. VerifyNumber: busi_card_info,
  14178. }
  14179. service.CreateHisPsn(psn)
  14180. var rf []*ResultFive
  14181. json.Unmarshal([]byte(infoStr), &rf)
  14182. var insutypes []*ResultFive
  14183. var insutype string
  14184. var is390 int = 0
  14185. var is310 int = 0
  14186. for _, item := range rf {
  14187. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14188. insutypes = append(insutypes, item)
  14189. }
  14190. }
  14191. if len(insutypes) == 1 {
  14192. insutype = insutypes[0].Insutype
  14193. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14194. } else {
  14195. for _, i := range insutypes {
  14196. if i.Insutype == "390" {
  14197. is390 = 1
  14198. }
  14199. if i.Insutype == "310" {
  14200. is310 = 1
  14201. }
  14202. }
  14203. }
  14204. if is390 == 1 {
  14205. insutype = "390"
  14206. }
  14207. if is310 == 1 {
  14208. insutype = "310"
  14209. }
  14210. if len(insutypes) == 0 {
  14211. insutype = "310"
  14212. }
  14213. c.ServeSuccessJSON(map[string]interface{}{
  14214. "patient": patient,
  14215. "number": basNumber,
  14216. "insutype": insutype,
  14217. })
  14218. } else {
  14219. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14220. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14221. infoStr := string(Iinfos)
  14222. idetinfoStr := string(Idetinfos)
  14223. psn := &models.HisPsn{
  14224. PsnNo: res.Output.Baseinfo.PsnNo,
  14225. PatientId: patient.ID,
  14226. Certno: res.Output.Baseinfo.Certno,
  14227. Gend: res.Output.Baseinfo.Gend,
  14228. Naty: res.Output.Baseinfo.Naty,
  14229. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14230. PsnName: res.Output.Baseinfo.PsnName,
  14231. Idetinfo: idetinfoStr,
  14232. Insuinfo: infoStr,
  14233. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14234. CardInfo: card_info,
  14235. VerifyNumber: token,
  14236. }
  14237. service.CreateHisPsn(psn)
  14238. c.ServeSuccessJSON(map[string]interface{}{
  14239. "patient": patient,
  14240. "number": token,
  14241. })
  14242. }
  14243. }
  14244. } else {
  14245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14246. return
  14247. }
  14248. } else { //读卡失败
  14249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14250. return
  14251. }
  14252. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14253. var api string
  14254. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14255. "&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
  14256. fmt.Println(api)
  14257. resp, requestErr := http.Get(api)
  14258. if requestErr != nil {
  14259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14260. return
  14261. }
  14262. body, ioErr := ioutil.ReadAll(resp.Body)
  14263. if ioErr != nil {
  14264. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14266. return
  14267. }
  14268. var respJSON map[string]interface{}
  14269. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14270. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14272. return
  14273. }
  14274. var status string
  14275. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14276. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14277. //console.log()
  14278. fmt.Println("type===")
  14279. fmt.Println(card_type)
  14280. var token string
  14281. var res ResultTwo //1101结果
  14282. //var res10265 ResultTwoesultTwo10265 //1101结果
  14283. var card_info string //卡信息
  14284. //var busi_card_info string
  14285. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14286. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14287. if status == "0" { //读卡成功
  14288. if card_type == "1" {
  14289. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14290. result, _ := json.Marshal(respJSON)
  14291. fmt.Println(result)
  14292. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14293. utils.ErrorLog("解析失败:%v", err)
  14294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14295. return
  14296. }
  14297. fmt.Println(res)
  14298. } else {
  14299. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14300. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14301. result, _ := json.Marshal(respJSON)
  14302. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14303. utils.ErrorLog("解析失败:%v", err)
  14304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14305. return
  14306. }
  14307. }
  14308. if res.Infcode == 0 {
  14309. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14310. if err == gorm.ErrRecordNotFound {
  14311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14312. return
  14313. } else if err != nil {
  14314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14315. return
  14316. } else {
  14317. if card_type == "1" {
  14318. bas := strings.Split(card_info, "|")
  14319. basNumber := bas[2]
  14320. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14321. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14322. infoStr := string(Iinfos)
  14323. idetinfoStr := string(Idetinfos)
  14324. psn := &models.HisPsn{
  14325. PsnNo: res.Output.Baseinfo.PsnNo,
  14326. PatientId: patient.ID,
  14327. Certno: res.Output.Baseinfo.Certno,
  14328. Gend: res.Output.Baseinfo.Gend,
  14329. Naty: res.Output.Baseinfo.Naty,
  14330. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14331. PsnName: res.Output.Baseinfo.PsnName,
  14332. Idetinfo: idetinfoStr,
  14333. Insuinfo: infoStr,
  14334. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14335. CardInfo: card_info,
  14336. //VerifyNumber: busi_card_info,
  14337. }
  14338. service.CreateHisPsn(psn)
  14339. var rf []*ResultFive
  14340. json.Unmarshal([]byte(infoStr), &rf)
  14341. var insutypes []*ResultFive
  14342. var insutype string
  14343. var is390 int = 0
  14344. var is310 int = 0
  14345. for _, item := range rf {
  14346. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14347. insutypes = append(insutypes, item)
  14348. }
  14349. }
  14350. if len(insutypes) == 1 {
  14351. insutype = insutypes[0].Insutype
  14352. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14353. } else {
  14354. for _, i := range insutypes {
  14355. if i.Insutype == "390" {
  14356. is390 = 1
  14357. }
  14358. if i.Insutype == "310" {
  14359. is310 = 1
  14360. }
  14361. }
  14362. }
  14363. if is390 == 1 {
  14364. insutype = "390"
  14365. }
  14366. if is310 == 1 {
  14367. insutype = "310"
  14368. }
  14369. if len(insutypes) == 0 {
  14370. insutype = "310"
  14371. }
  14372. c.ServeSuccessJSON(map[string]interface{}{
  14373. "patient": patient,
  14374. "number": basNumber,
  14375. "insutype": insutype,
  14376. })
  14377. } else {
  14378. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14379. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14380. infoStr := string(Iinfos)
  14381. idetinfoStr := string(Idetinfos)
  14382. psn := &models.HisPsn{
  14383. PsnNo: res.Output.Baseinfo.PsnNo,
  14384. PatientId: patient.ID,
  14385. Certno: res.Output.Baseinfo.Certno,
  14386. Gend: res.Output.Baseinfo.Gend,
  14387. Naty: res.Output.Baseinfo.Naty,
  14388. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14389. PsnName: res.Output.Baseinfo.PsnName,
  14390. Idetinfo: idetinfoStr,
  14391. Insuinfo: infoStr,
  14392. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14393. CardInfo: card_info,
  14394. VerifyNumber: token,
  14395. }
  14396. service.CreateHisPsn(psn)
  14397. c.ServeSuccessJSON(map[string]interface{}{
  14398. "patient": patient,
  14399. "number": token,
  14400. })
  14401. }
  14402. }
  14403. } else {
  14404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14405. return
  14406. }
  14407. } else { //读卡失败
  14408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14409. return
  14410. }
  14411. } else {
  14412. if initFlag == 0 {
  14413. c.TestGetBasBaseInit()
  14414. }
  14415. basStr := c.GetBasBaseInfo()
  14416. if len(basStr) == 0 {
  14417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14418. return
  14419. }
  14420. fmt.Println(basStr)
  14421. bas := strings.Split(basStr, "|")
  14422. basNumber := bas[1]
  14423. fmt.Println(basNumber)
  14424. card_sn := bas[3]
  14425. fmt.Println(card_sn)
  14426. cardNumber := bas[2]
  14427. fmt.Println(cardNumber)
  14428. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  14429. var result string
  14430. if bas[0][:2] == "44" {
  14431. 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)
  14432. } else {
  14433. 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)
  14434. }
  14435. var dat map[string]interface{}
  14436. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14437. fmt.Println(dat)
  14438. } else {
  14439. fmt.Println(err)
  14440. }
  14441. userJSONBytes, _ := json.Marshal(dat)
  14442. var res ResultTwo
  14443. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14444. utils.ErrorLog("解析失败:%v", err)
  14445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14446. return
  14447. }
  14448. if res.Infcode == 0 {
  14449. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14450. if err == gorm.ErrRecordNotFound {
  14451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14452. return
  14453. } else if err != nil {
  14454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14455. return
  14456. } else {
  14457. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14458. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14459. infoStr := string(Iinfos)
  14460. idetinfoStr := string(Idetinfos)
  14461. var rf []*ResultFive
  14462. json.Unmarshal([]byte(infoStr), &rf)
  14463. var insutypes []*ResultFive
  14464. var insutype string
  14465. var is390 int = 0
  14466. var is310 int = 0
  14467. var insuplc_admdvs string
  14468. for _, item := range rf {
  14469. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14470. insutypes = append(insutypes, item)
  14471. }
  14472. }
  14473. if len(insutypes) == 1 {
  14474. insutype = insutypes[0].Insutype
  14475. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14476. } else {
  14477. for _, i := range insutypes {
  14478. if i.Insutype == "390" {
  14479. is390 = 1
  14480. }
  14481. if i.Insutype == "310" {
  14482. is310 = 1
  14483. }
  14484. }
  14485. }
  14486. if is390 == 1 {
  14487. insutype = "390"
  14488. }
  14489. if is310 == 1 {
  14490. insutype = "310"
  14491. }
  14492. if len(insutypes) == 0 {
  14493. insutype = "310"
  14494. }
  14495. for _, item := range rf {
  14496. if item.Insutype == insutype {
  14497. insuplc_admdvs = item.InsuplcAdmdvs
  14498. }
  14499. }
  14500. psn := &models.HisPsn{
  14501. PsnNo: res.Output.Baseinfo.PsnNo,
  14502. PatientId: patient.ID,
  14503. Certno: res.Output.Baseinfo.Certno,
  14504. Gend: res.Output.Baseinfo.Gend,
  14505. Naty: res.Output.Baseinfo.Naty,
  14506. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14507. PsnName: res.Output.Baseinfo.PsnName,
  14508. Idetinfo: idetinfoStr,
  14509. Insuinfo: infoStr,
  14510. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14511. CardInfo: basStr,
  14512. VerifyNumber: "",
  14513. InsuplcAdmdvs: insuplc_admdvs,
  14514. }
  14515. service.CreateHisPsn(psn)
  14516. c.ServeSuccessJSON(map[string]interface{}{
  14517. "patient": patient,
  14518. "number": basNumber,
  14519. })
  14520. }
  14521. } else {
  14522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14523. return
  14524. }
  14525. break
  14526. }
  14527. case 2:
  14528. if miConfig.MdtrtareaAdmvs == "430800" {
  14529. if initFlag == 0 {
  14530. c.TestGetHnBasBaseInit()
  14531. }
  14532. SFZStr := c.GetSFZBaseInfo()
  14533. if len(SFZStr) == 0 {
  14534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14535. return
  14536. }
  14537. fmt.Println(SFZStr)
  14538. id_card_str := strings.Split(SFZStr, "^")
  14539. card_no := id_card_str[0]
  14540. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14541. //name := id_card_str[1]
  14542. //name = ConvertToString(name, "gbk", "utf-8")
  14543. 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)
  14544. var dat map[string]interface{}
  14545. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14546. fmt.Println(dat)
  14547. } else {
  14548. fmt.Println(err)
  14549. }
  14550. userJSONBytes, _ := json.Marshal(dat)
  14551. var res ResultTwo
  14552. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14553. utils.ErrorLog("解析失败:%v", err)
  14554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14555. return
  14556. }
  14557. if res.Infcode == 0 {
  14558. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  14559. if err == gorm.ErrRecordNotFound {
  14560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14561. return
  14562. } else if err != nil {
  14563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14564. return
  14565. } else {
  14566. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14567. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14568. infoStr := string(Iinfos)
  14569. idetinfoStr := string(Idetinfos)
  14570. var rf []*ResultFive
  14571. json.Unmarshal([]byte(infoStr), &rf)
  14572. var insutypes []*ResultFive
  14573. var insutype string
  14574. var is390 int = 0
  14575. var is310 int = 0
  14576. for _, item := range rf {
  14577. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14578. insutypes = append(insutypes, item)
  14579. }
  14580. }
  14581. if len(insutypes) == 1 {
  14582. insutype = insutypes[0].Insutype
  14583. } else {
  14584. for _, i := range insutypes {
  14585. if i.Insutype == "390" {
  14586. is390 = 1
  14587. }
  14588. if i.Insutype == "310" {
  14589. is310 = 1
  14590. }
  14591. }
  14592. }
  14593. if is390 == 1 {
  14594. insutype = "390"
  14595. }
  14596. if is310 == 1 {
  14597. insutype = "310"
  14598. }
  14599. if len(insutypes) == 0 {
  14600. insutype = "310"
  14601. }
  14602. var InsuplcAdmdvs string
  14603. for _, item := range rf {
  14604. if item.Insutype == insutype {
  14605. InsuplcAdmdvs = item.InsuplcAdmdvs
  14606. }
  14607. }
  14608. psn := &models.HisPsn{
  14609. PsnNo: res.Output.Baseinfo.PsnNo,
  14610. PatientId: patient.ID,
  14611. Certno: res.Output.Baseinfo.Certno,
  14612. Gend: res.Output.Baseinfo.Gend,
  14613. Naty: res.Output.Baseinfo.Naty,
  14614. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14615. PsnName: res.Output.Baseinfo.PsnName,
  14616. Idetinfo: idetinfoStr,
  14617. Insuinfo: infoStr,
  14618. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14619. CardInfo: SFZStr,
  14620. VerifyNumber: "",
  14621. InsuplcAdmdvs: InsuplcAdmdvs,
  14622. }
  14623. service.CreateHisPsn(psn)
  14624. c.ServeSuccessJSON(map[string]interface{}{
  14625. "patient": patient,
  14626. "number": card_no,
  14627. "insutype": insutype,
  14628. })
  14629. }
  14630. } else {
  14631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14632. return
  14633. }
  14634. } else if miConfig.MdtrtareaAdmvs == "420200" {
  14635. var res ResultTwo
  14636. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  14637. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14638. "&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)
  14639. resp, requestErr := http.Get(api)
  14640. if requestErr != nil {
  14641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14642. return
  14643. }
  14644. body, ioErr := ioutil.ReadAll(resp.Body)
  14645. if ioErr != nil {
  14646. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14648. return
  14649. }
  14650. var respJSON map[string]interface{}
  14651. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14652. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14654. return
  14655. }
  14656. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14657. result, _ := json.Marshal(respJSON)
  14658. fmt.Println("log")
  14659. fmt.Println(string(result))
  14660. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14661. utils.ErrorLog("解析失败:%v", err)
  14662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14663. return
  14664. }
  14665. if res.Infcode == 0 {
  14666. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14667. if err == gorm.ErrRecordNotFound {
  14668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14669. return
  14670. } else if err != nil {
  14671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14672. return
  14673. } else {
  14674. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14675. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14676. infoStr := string(Iinfos)
  14677. idetinfoStr := string(Idetinfos)
  14678. psn := &models.HisPsn{
  14679. PsnNo: res.Output.Baseinfo.PsnNo,
  14680. PatientId: patient.ID,
  14681. Certno: res.Output.Baseinfo.Certno,
  14682. Gend: res.Output.Baseinfo.Gend,
  14683. Naty: res.Output.Baseinfo.Naty,
  14684. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14685. PsnName: res.Output.Baseinfo.PsnName,
  14686. Idetinfo: idetinfoStr,
  14687. Insuinfo: infoStr,
  14688. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14689. }
  14690. service.CreateHisPsn(psn)
  14691. c.ServeSuccessJSON(map[string]interface{}{
  14692. "patient": patient,
  14693. "number": res.Output.Baseinfo.Certno,
  14694. })
  14695. }
  14696. } else {
  14697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14698. return
  14699. }
  14700. } else if miConfig.MdtrtareaAdmvs == "421182" {
  14701. var res ResultTwo
  14702. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14703. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14704. "&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)
  14705. resp, requestErr := http.Get(api)
  14706. if requestErr != nil {
  14707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14708. return
  14709. }
  14710. body, ioErr := ioutil.ReadAll(resp.Body)
  14711. if ioErr != nil {
  14712. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14714. return
  14715. }
  14716. var respJSON map[string]interface{}
  14717. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14718. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14720. return
  14721. }
  14722. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14723. result, _ := json.Marshal(respJSON)
  14724. fmt.Println("log")
  14725. fmt.Println(string(result))
  14726. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14727. utils.ErrorLog("解析失败:%v", err)
  14728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14729. return
  14730. }
  14731. if res.Infcode == 0 {
  14732. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14733. if err == gorm.ErrRecordNotFound {
  14734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14735. return
  14736. } else if err != nil {
  14737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14738. return
  14739. } else {
  14740. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14741. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14742. infoStr := string(Iinfos)
  14743. idetinfoStr := string(Idetinfos)
  14744. psn := &models.HisPsn{
  14745. PsnNo: res.Output.Baseinfo.PsnNo,
  14746. PatientId: patient.ID,
  14747. Certno: res.Output.Baseinfo.Certno,
  14748. Gend: res.Output.Baseinfo.Gend,
  14749. Naty: res.Output.Baseinfo.Naty,
  14750. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14751. PsnName: res.Output.Baseinfo.PsnName,
  14752. Idetinfo: idetinfoStr,
  14753. Insuinfo: infoStr,
  14754. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14755. }
  14756. service.CreateHisPsn(psn)
  14757. c.ServeSuccessJSON(map[string]interface{}{
  14758. "patient": patient,
  14759. "number": res.Output.Baseinfo.Certno,
  14760. })
  14761. }
  14762. } else {
  14763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14764. return
  14765. }
  14766. } else if miConfig.MdtrtareaAdmvs == "420902" {
  14767. var res ResultTwo
  14768. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14769. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14770. "&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)
  14771. resp, requestErr := http.Get(api)
  14772. if requestErr != nil {
  14773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14774. return
  14775. }
  14776. body, ioErr := ioutil.ReadAll(resp.Body)
  14777. if ioErr != nil {
  14778. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14780. return
  14781. }
  14782. var respJSON map[string]interface{}
  14783. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14784. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14786. return
  14787. }
  14788. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14789. result, _ := json.Marshal(respJSON)
  14790. fmt.Println("log")
  14791. fmt.Println(string(result))
  14792. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14793. utils.ErrorLog("解析失败:%v", err)
  14794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14795. return
  14796. }
  14797. if res.Infcode == 0 {
  14798. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14799. if err == gorm.ErrRecordNotFound {
  14800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14801. return
  14802. } else if err != nil {
  14803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14804. return
  14805. } else {
  14806. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14807. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14808. infoStr := string(Iinfos)
  14809. idetinfoStr := string(Idetinfos)
  14810. var rf []*ResultFive
  14811. json.Unmarshal([]byte(infoStr), &rf)
  14812. var insutypes []*ResultFive
  14813. var insutype string
  14814. var is390 int = 0
  14815. var is310 int = 0
  14816. for _, item := range rf {
  14817. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14818. insutypes = append(insutypes, item)
  14819. }
  14820. }
  14821. if len(insutypes) == 1 {
  14822. insutype = insutypes[0].Insutype
  14823. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14824. } else {
  14825. for _, i := range insutypes {
  14826. if i.Insutype == "390" {
  14827. is390 = 1
  14828. }
  14829. if i.Insutype == "310" {
  14830. is310 = 1
  14831. }
  14832. }
  14833. }
  14834. if is390 == 1 {
  14835. insutype = "390"
  14836. }
  14837. if is310 == 1 {
  14838. insutype = "310"
  14839. }
  14840. if len(insutypes) == 0 {
  14841. insutype = "390"
  14842. }
  14843. var insuplc_admdvs string
  14844. for _, item := range rf {
  14845. if item.Insutype == insutype {
  14846. insuplc_admdvs = item.InsuplcAdmdvs
  14847. }
  14848. }
  14849. psn := &models.HisPsn{
  14850. PsnNo: res.Output.Baseinfo.PsnNo,
  14851. PatientId: patient.ID,
  14852. Certno: res.Output.Baseinfo.Certno,
  14853. Gend: res.Output.Baseinfo.Gend,
  14854. Naty: res.Output.Baseinfo.Naty,
  14855. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14856. PsnName: res.Output.Baseinfo.PsnName,
  14857. Idetinfo: idetinfoStr,
  14858. Insuinfo: infoStr,
  14859. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14860. InsuplcAdmdvs: insuplc_admdvs,
  14861. }
  14862. service.CreateHisPsn(psn)
  14863. c.ServeSuccessJSON(map[string]interface{}{
  14864. "patient": patient,
  14865. "number": res.Output.Baseinfo.Certno,
  14866. })
  14867. }
  14868. } else {
  14869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14870. return
  14871. }
  14872. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14873. res := c.GetoleInfo()
  14874. if res.Infcode == 0 {
  14875. var result string
  14876. if res.Output.MdtrtCertType == "01" {
  14877. 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)
  14878. } else if res.Output.MdtrtCertType == "02" {
  14879. 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)
  14880. } else if res.Output.MdtrtCertType == "03" {
  14881. 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)
  14882. }
  14883. var dat map[string]interface{}
  14884. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14885. fmt.Println(dat)
  14886. } else {
  14887. fmt.Println(err)
  14888. }
  14889. userJSONBytes, _ := json.Marshal(dat)
  14890. var res2 ResultTwo
  14891. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14892. utils.ErrorLog("解析失败:%v", err)
  14893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14894. return
  14895. }
  14896. if res2.Infcode == 0 {
  14897. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14898. if err == gorm.ErrRecordNotFound {
  14899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14900. return
  14901. } else if err != nil {
  14902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14903. return
  14904. } else {
  14905. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14906. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14907. infoStr := string(Iinfos)
  14908. idetinfoStr := string(Idetinfos)
  14909. var rf []*ResultFive
  14910. json.Unmarshal([]byte(infoStr), &rf)
  14911. var insutypes []*ResultFive
  14912. var insutype string
  14913. var is390 int = 0
  14914. var is310 int = 0
  14915. //var insuplc_admdvs string
  14916. for _, item := range rf {
  14917. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14918. insutypes = append(insutypes, item)
  14919. }
  14920. }
  14921. if len(insutypes) == 1 {
  14922. insutype = insutypes[0].Insutype
  14923. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14924. } else {
  14925. for _, i := range insutypes {
  14926. if i.Insutype == "390" {
  14927. is390 = 1
  14928. }
  14929. if i.Insutype == "310" {
  14930. is310 = 1
  14931. }
  14932. }
  14933. }
  14934. if is390 == 1 {
  14935. insutype = "390"
  14936. }
  14937. if is310 == 1 {
  14938. insutype = "310"
  14939. }
  14940. if len(insutypes) == 0 {
  14941. insutype = "310"
  14942. }
  14943. psn := &models.HisPsn{
  14944. PsnNo: res2.Output.Baseinfo.PsnNo,
  14945. PatientId: patient.ID,
  14946. //Brdy: res2.Output.Baseinfo.Brdy,
  14947. Certno: res2.Output.Baseinfo.Certno,
  14948. Gend: res2.Output.Baseinfo.Gend,
  14949. Naty: res2.Output.Baseinfo.Naty,
  14950. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14951. PsnName: res2.Output.Baseinfo.PsnName,
  14952. Idetinfo: idetinfoStr,
  14953. Insuinfo: infoStr,
  14954. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14955. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14956. VerifyNumber: res.Output.EcToken,
  14957. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14958. }
  14959. service.CreateHisPsn(psn)
  14960. var balc float64
  14961. for _, item := range rf {
  14962. if item.Insutype == insutype {
  14963. balc = item.Balc
  14964. }
  14965. }
  14966. c.ServeSuccessJSON(map[string]interface{}{
  14967. "patient": patient,
  14968. "number": res.Output.CardNo,
  14969. "insutype": insutype,
  14970. "blac": balc,
  14971. "desc": idetinfoStr,
  14972. })
  14973. }
  14974. } else {
  14975. c.ServeSuccessJSON(map[string]interface{}{
  14976. "failed_code": -10,
  14977. "msg": res2.ErrMsg,
  14978. })
  14979. }
  14980. } else {
  14981. c.ServeSuccessJSON(map[string]interface{}{
  14982. "failed_code": -10,
  14983. "msg": res.ErrMsg,
  14984. })
  14985. }
  14986. } else if miConfig.MdtrtareaAdmvs == "340699" {
  14987. var insuplc_admdvs string
  14988. if len(patient.InsuplcAdmdvs) > 0 {
  14989. insuplc_admdvs = patient.InsuplcAdmdvs
  14990. } else {
  14991. if len(insuplc_admdvs_str) > 0 {
  14992. insuplc_admdvs = insuplc_admdvs_str
  14993. } else {
  14994. insuplc_admdvs = miConfig.InsuplcAdmdvs
  14995. }
  14996. }
  14997. //请求内网数据
  14998. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  14999. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15000. "&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=" + ""
  15001. resp, requestErr := http.Get(api)
  15002. if requestErr != nil {
  15003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15004. return
  15005. }
  15006. body, ioErr := ioutil.ReadAll(resp.Body)
  15007. if ioErr != nil {
  15008. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15010. return
  15011. }
  15012. var respJSON map[string]interface{}
  15013. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15014. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15016. return
  15017. }
  15018. status := respJSON["data"].(map[string]interface{})["status"].(string)
  15019. if status == "0" {
  15020. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  15021. c.ServeSuccessJSON(map[string]interface{}{
  15022. "failed_code": -10,
  15023. "msg": err_msg,
  15024. })
  15025. return
  15026. }
  15027. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15028. var res ResultTwo
  15029. result, _ := json.Marshal(respJSON)
  15030. fmt.Println("log")
  15031. fmt.Println(string(result))
  15032. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15033. utils.ErrorLog("解析失败:%v", err)
  15034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15035. return
  15036. }
  15037. if res.Infcode == 0 {
  15038. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15039. if err == gorm.ErrRecordNotFound {
  15040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15041. return
  15042. } else if err != nil {
  15043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15044. return
  15045. } else {
  15046. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15047. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15048. infoStr := string(Iinfos)
  15049. idetinfoStr := string(Idetinfos)
  15050. psn := &models.HisPsn{
  15051. PsnNo: res.Output.Baseinfo.PsnNo,
  15052. PatientId: patient.ID,
  15053. Certno: res.Output.Baseinfo.Certno,
  15054. Gend: res.Output.Baseinfo.Gend,
  15055. Naty: res.Output.Baseinfo.Naty,
  15056. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15057. PsnName: res.Output.Baseinfo.PsnName,
  15058. Idetinfo: idetinfoStr,
  15059. Insuinfo: infoStr,
  15060. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15061. }
  15062. service.CreateHisPsn(psn)
  15063. var rf []*ResultFive
  15064. json.Unmarshal([]byte(infoStr), &rf)
  15065. var insutypes []*ResultFive
  15066. var is390 int = 0
  15067. var is310 int = 0
  15068. var insutype string
  15069. for _, item := range rf {
  15070. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15071. insutypes = append(insutypes, item)
  15072. }
  15073. }
  15074. if len(insutypes) == 1 {
  15075. insutype = insutypes[0].Insutype
  15076. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15077. } else {
  15078. for _, i := range insutypes {
  15079. if i.Insutype == "390" {
  15080. is390 = 1
  15081. }
  15082. if i.Insutype == "310" {
  15083. is310 = 1
  15084. }
  15085. }
  15086. }
  15087. if is390 == 1 {
  15088. insutype = "390"
  15089. }
  15090. if is310 == 1 {
  15091. insutype = "310"
  15092. }
  15093. if len(insutypes) == 0 {
  15094. insutype = "390"
  15095. }
  15096. c.ServeSuccessJSON(map[string]interface{}{
  15097. "patient": patient,
  15098. "insutype": insutype,
  15099. "number": res.Output.Baseinfo.Certno,
  15100. "info": res,
  15101. })
  15102. }
  15103. } else {
  15104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15105. return
  15106. }
  15107. } else {
  15108. SFZStr := c.GetSFZBaseInfo()
  15109. id_card_str := strings.Split(SFZStr, "^")
  15110. id_card_number := id_card_str[0]
  15111. card_sn := ""
  15112. 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)
  15113. var dat map[string]interface{}
  15114. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15115. fmt.Println(dat)
  15116. } else {
  15117. fmt.Println(err)
  15118. }
  15119. userJSONBytes, _ := json.Marshal(dat)
  15120. var res ResultTwo
  15121. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15122. utils.ErrorLog("解析失败:%v", err)
  15123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15124. return
  15125. }
  15126. if res.Infcode == 0 {
  15127. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  15128. if err == gorm.ErrRecordNotFound {
  15129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15130. return
  15131. } else if err != nil {
  15132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15133. return
  15134. } else {
  15135. c.ServeSuccessJSON(map[string]interface{}{
  15136. "patient": patient,
  15137. "number": id_card_number,
  15138. })
  15139. }
  15140. } else {
  15141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15142. return
  15143. }
  15144. }
  15145. break
  15146. case 3:
  15147. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15148. var api string
  15149. if miConfig.MdtrtareaAdmvs == "320921" {
  15150. 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 +
  15151. "&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
  15152. fmt.Println(api)
  15153. } else {
  15154. 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 +
  15155. "&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)
  15156. }
  15157. resp, requestErr := http.Get(api)
  15158. if requestErr != nil {
  15159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15160. return
  15161. }
  15162. body, ioErr := ioutil.ReadAll(resp.Body)
  15163. if ioErr != nil {
  15164. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15166. return
  15167. }
  15168. var respJSON map[string]interface{}
  15169. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15170. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15172. return
  15173. }
  15174. var status string
  15175. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15176. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15177. var token string
  15178. var res ResultTwo //1101结果
  15179. var res10265 ResultTwo10265 //1101结果
  15180. var card_info string //卡信息
  15181. var busi_card_info string
  15182. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15183. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15184. if status == "0" { //读卡成功
  15185. if card_type == "1" {
  15186. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15187. result, _ := json.Marshal(respJSON)
  15188. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15189. utils.ErrorLog("解析失败:%v", err)
  15190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15191. return
  15192. }
  15193. res.ErrMsg = res10265.ErrMsg
  15194. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15195. res.Infcode = infocode
  15196. res.Output = res10265.Output
  15197. res.InfRefmsgid = res10265.InfRefmsgid
  15198. } else {
  15199. //var card_info string //卡信息
  15200. //var busi_card_info string
  15201. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15202. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15203. //fmt.Println(card_info)
  15204. //fmt.Println(busi_card_info)
  15205. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15206. result, _ := json.Marshal(respJSON)
  15207. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15208. utils.ErrorLog("解析失败:%v", err)
  15209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15210. return
  15211. }
  15212. res.ErrMsg = res10265.ErrMsg
  15213. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15214. res.Infcode = infocode
  15215. res.Output = res10265.Output
  15216. res.InfRefmsgid = res10265.InfRefmsgid
  15217. }
  15218. if res.Infcode == 0 {
  15219. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15220. if err == gorm.ErrRecordNotFound {
  15221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15222. return
  15223. } else if err != nil {
  15224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15225. return
  15226. } else {
  15227. if card_type == "1" {
  15228. bas := strings.Split(card_info, "|")
  15229. basNumber := bas[2]
  15230. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15231. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15232. infoStr := string(Iinfos)
  15233. idetinfoStr := string(Idetinfos)
  15234. psn := &models.HisPsn{
  15235. PsnNo: res.Output.Baseinfo.PsnNo,
  15236. PatientId: patient.ID,
  15237. Certno: res.Output.Baseinfo.Certno,
  15238. //Brdy: res.Output.Baseinfo.Brdy,
  15239. Gend: res.Output.Baseinfo.Gend,
  15240. Naty: res.Output.Baseinfo.Naty,
  15241. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15242. PsnName: res.Output.Baseinfo.PsnName,
  15243. Idetinfo: idetinfoStr,
  15244. Insuinfo: infoStr,
  15245. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15246. CardInfo: card_info,
  15247. VerifyNumber: busi_card_info,
  15248. }
  15249. service.CreateHisPsn(psn)
  15250. c.ServeSuccessJSON(map[string]interface{}{
  15251. "patient": patient,
  15252. "number": basNumber,
  15253. })
  15254. } else {
  15255. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15256. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15257. infoStr := string(Iinfos)
  15258. idetinfoStr := string(Idetinfos)
  15259. psn := &models.HisPsn{
  15260. PsnNo: res.Output.Baseinfo.PsnNo,
  15261. PatientId: patient.ID,
  15262. Certno: res.Output.Baseinfo.Certno,
  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: token,
  15272. }
  15273. service.CreateHisPsn(psn)
  15274. var rf []*ResultFive
  15275. json.Unmarshal([]byte(infoStr), &rf)
  15276. var insutypes []*ResultFive
  15277. var insutype string
  15278. var is390 int = 0
  15279. var is310 int = 0
  15280. for _, item := range rf {
  15281. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15282. insutypes = append(insutypes, item)
  15283. }
  15284. }
  15285. if len(insutypes) == 1 {
  15286. insutype = insutypes[0].Insutype
  15287. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15288. } else {
  15289. for _, i := range insutypes {
  15290. if i.Insutype == "390" {
  15291. is390 = 1
  15292. }
  15293. if i.Insutype == "310" {
  15294. is310 = 1
  15295. }
  15296. }
  15297. }
  15298. if is390 == 1 {
  15299. insutype = "390"
  15300. }
  15301. if is310 == 1 {
  15302. insutype = "310"
  15303. }
  15304. if len(insutypes) == 0 {
  15305. insutype = "310"
  15306. }
  15307. c.ServeSuccessJSON(map[string]interface{}{
  15308. "patient": patient,
  15309. "number": token,
  15310. "insutype": insutype,
  15311. })
  15312. }
  15313. }
  15314. } else {
  15315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15316. return
  15317. }
  15318. } else { //读卡失败
  15319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15320. return
  15321. }
  15322. }
  15323. break
  15324. case 4:
  15325. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15326. var api string
  15327. if miConfig.MdtrtareaAdmvs == "320921" {
  15328. 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 +
  15329. "&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
  15330. fmt.Println(api)
  15331. } else {
  15332. 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 +
  15333. "&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)
  15334. }
  15335. resp, requestErr := http.Get(api)
  15336. if requestErr != nil {
  15337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15338. return
  15339. }
  15340. body, ioErr := ioutil.ReadAll(resp.Body)
  15341. if ioErr != nil {
  15342. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15344. return
  15345. }
  15346. var respJSON map[string]interface{}
  15347. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15348. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15350. return
  15351. }
  15352. var status string
  15353. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15354. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15355. var token string
  15356. var res ResultTwo //1101结果
  15357. var res10265 ResultTwo10265 //1101结果
  15358. if status == "0" { //读卡成功
  15359. var card_info string //卡信息
  15360. var busi_card_info string
  15361. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15362. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15363. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15364. fmt.Println(card_info)
  15365. fmt.Println(busi_card_info)
  15366. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15367. result, _ := json.Marshal(respJSON)
  15368. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15369. utils.ErrorLog("解析失败:%v", err)
  15370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15371. return
  15372. }
  15373. res.ErrMsg = res10265.ErrMsg
  15374. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15375. res.Infcode = infocode
  15376. res.Output = res10265.Output
  15377. res.InfRefmsgid = res10265.InfRefmsgid
  15378. if res.Infcode == 0 {
  15379. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15380. if err == gorm.ErrRecordNotFound {
  15381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15382. return
  15383. } else if err != nil {
  15384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15385. return
  15386. } else {
  15387. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15388. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15389. infoStr := string(Iinfos)
  15390. idetinfoStr := string(Idetinfos)
  15391. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  15392. psn := &models.HisPsn{
  15393. PsnNo: res.Output.Baseinfo.PsnNo,
  15394. PatientId: patient.ID,
  15395. Certno: res.Output.Baseinfo.Certno,
  15396. Brdy: b,
  15397. Age: float64(age),
  15398. //Brdy: res.Output.Baseinfo.Brdy,
  15399. Gend: res.Output.Baseinfo.Gend,
  15400. Naty: res.Output.Baseinfo.Naty,
  15401. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15402. PsnName: res.Output.Baseinfo.PsnName,
  15403. Idetinfo: idetinfoStr,
  15404. Insuinfo: infoStr,
  15405. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15406. CardInfo: card_info,
  15407. VerifyNumber: token,
  15408. }
  15409. var rf []*ResultFive
  15410. json.Unmarshal([]byte(infoStr), &rf)
  15411. var insutypes []*ResultFive
  15412. var insutype string
  15413. var is390 int = 0
  15414. var is310 int = 0
  15415. for _, item := range rf {
  15416. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15417. insutypes = append(insutypes, item)
  15418. }
  15419. }
  15420. if len(insutypes) == 1 {
  15421. insutype = insutypes[0].Insutype
  15422. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15423. } else {
  15424. for _, i := range insutypes {
  15425. if i.Insutype == "390" {
  15426. is390 = 1
  15427. }
  15428. if i.Insutype == "310" {
  15429. is310 = 1
  15430. }
  15431. }
  15432. }
  15433. if is390 == 1 {
  15434. insutype = "390"
  15435. }
  15436. if is310 == 1 {
  15437. insutype = "310"
  15438. }
  15439. if len(insutypes) == 0 {
  15440. insutype = "310"
  15441. }
  15442. service.CreateHisPsn(psn)
  15443. c.ServeSuccessJSON(map[string]interface{}{
  15444. "patient": patient,
  15445. "number": token,
  15446. "insutype": insutype,
  15447. })
  15448. }
  15449. } else {
  15450. c.ServeSuccessJSON(map[string]interface{}{
  15451. "failed_code": -10,
  15452. "msg": res.ErrMsg,
  15453. })
  15454. }
  15455. } else { //读卡失败
  15456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15457. return
  15458. }
  15459. } else if miConfig.MdtrtareaAdmvs == "341203" {
  15460. var api string
  15461. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15462. "&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
  15463. resp, requestErr := http.Get(api)
  15464. if requestErr != nil {
  15465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15466. return
  15467. }
  15468. body, ioErr := ioutil.ReadAll(resp.Body)
  15469. if ioErr != nil {
  15470. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15472. return
  15473. }
  15474. var respJSON map[string]interface{}
  15475. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15476. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15478. return
  15479. }
  15480. var status string
  15481. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15482. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15483. var token string
  15484. var res ResultTwo //1101结果
  15485. if status == "1" { //读卡成功
  15486. var card_info string //卡信息
  15487. var busi_card_info string
  15488. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15489. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15490. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15491. fmt.Println(card_info)
  15492. fmt.Println(busi_card_info)
  15493. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15494. result, _ := json.Marshal(respJSON)
  15495. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15496. utils.ErrorLog("解析失败:%v", err)
  15497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15498. return
  15499. }
  15500. if res.Infcode == 0 {
  15501. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15502. if err == gorm.ErrRecordNotFound {
  15503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15504. return
  15505. } else if err != nil {
  15506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15507. return
  15508. } else {
  15509. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15510. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15511. infoStr := string(Iinfos)
  15512. idetinfoStr := string(Idetinfos)
  15513. psn := &models.HisPsn{
  15514. PsnNo: res.Output.Baseinfo.PsnNo,
  15515. PatientId: patient.ID,
  15516. Certno: res.Output.Baseinfo.Certno,
  15517. Gend: res.Output.Baseinfo.Gend,
  15518. Naty: res.Output.Baseinfo.Naty,
  15519. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15520. PsnName: res.Output.Baseinfo.PsnName,
  15521. Idetinfo: idetinfoStr,
  15522. Insuinfo: infoStr,
  15523. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15524. CardInfo: card_info,
  15525. VerifyNumber: token,
  15526. }
  15527. var rf []*ResultFive
  15528. json.Unmarshal([]byte(infoStr), &rf)
  15529. var insutypes []*ResultFive
  15530. var insutype string
  15531. var is390 int = 0
  15532. var is310 int = 0
  15533. for _, item := range rf {
  15534. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15535. insutypes = append(insutypes, item)
  15536. }
  15537. }
  15538. if len(insutypes) == 1 {
  15539. insutype = insutypes[0].Insutype
  15540. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15541. } else {
  15542. for _, i := range insutypes {
  15543. if i.Insutype == "390" {
  15544. is390 = 1
  15545. }
  15546. if i.Insutype == "310" {
  15547. is310 = 1
  15548. }
  15549. }
  15550. }
  15551. if is390 == 1 {
  15552. insutype = "390"
  15553. }
  15554. if is310 == 1 {
  15555. insutype = "310"
  15556. }
  15557. if len(insutypes) == 0 {
  15558. insutype = "310"
  15559. }
  15560. service.CreateHisPsn(psn)
  15561. c.ServeSuccessJSON(map[string]interface{}{
  15562. "patient": patient,
  15563. "number": token,
  15564. "insutype": insutype,
  15565. })
  15566. }
  15567. } else {
  15568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15569. return
  15570. }
  15571. } else { //读卡失败
  15572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15573. return
  15574. }
  15575. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15576. var api string
  15577. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15578. "&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
  15579. resp, requestErr := http.Get(api)
  15580. if requestErr != nil {
  15581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15582. return
  15583. }
  15584. body, ioErr := ioutil.ReadAll(resp.Body)
  15585. if ioErr != nil {
  15586. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15588. return
  15589. }
  15590. var respJSON map[string]interface{}
  15591. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15592. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15594. return
  15595. }
  15596. var status string
  15597. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15598. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15599. var token string
  15600. var res ResultTwo //1101结果
  15601. if status == "1" { //读卡成功
  15602. var card_info string //卡信息
  15603. var busi_card_info string
  15604. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15605. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15606. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15607. fmt.Println(card_info)
  15608. fmt.Println(busi_card_info)
  15609. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15610. result, _ := json.Marshal(respJSON)
  15611. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15612. utils.ErrorLog("解析失败:%v", err)
  15613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15614. return
  15615. }
  15616. if res.Infcode == 0 {
  15617. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15618. if err == gorm.ErrRecordNotFound {
  15619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15620. return
  15621. } else if err != nil {
  15622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15623. return
  15624. } else {
  15625. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15626. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15627. infoStr := string(Iinfos)
  15628. idetinfoStr := string(Idetinfos)
  15629. psn := &models.HisPsn{
  15630. PsnNo: res.Output.Baseinfo.PsnNo,
  15631. PatientId: patient.ID,
  15632. Certno: res.Output.Baseinfo.Certno,
  15633. Gend: res.Output.Baseinfo.Gend,
  15634. Naty: res.Output.Baseinfo.Naty,
  15635. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15636. PsnName: res.Output.Baseinfo.PsnName,
  15637. Idetinfo: idetinfoStr,
  15638. Insuinfo: infoStr,
  15639. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15640. CardInfo: card_info,
  15641. VerifyNumber: token,
  15642. }
  15643. var rf []*ResultFive
  15644. json.Unmarshal([]byte(infoStr), &rf)
  15645. var insutypes []*ResultFive
  15646. var insutype string
  15647. var is390 int = 0
  15648. var is310 int = 0
  15649. for _, item := range rf {
  15650. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15651. insutypes = append(insutypes, item)
  15652. }
  15653. }
  15654. if len(insutypes) == 1 {
  15655. insutype = insutypes[0].Insutype
  15656. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15657. } else {
  15658. for _, i := range insutypes {
  15659. if i.Insutype == "390" {
  15660. is390 = 1
  15661. }
  15662. if i.Insutype == "310" {
  15663. is310 = 1
  15664. }
  15665. }
  15666. }
  15667. if is390 == 1 {
  15668. insutype = "390"
  15669. }
  15670. if is310 == 1 {
  15671. insutype = "310"
  15672. }
  15673. if len(insutypes) == 0 {
  15674. insutype = "310"
  15675. }
  15676. service.CreateHisPsn(psn)
  15677. c.ServeSuccessJSON(map[string]interface{}{
  15678. "patient": patient,
  15679. "number": token,
  15680. "insutype": insutype,
  15681. })
  15682. }
  15683. } else {
  15684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15685. return
  15686. }
  15687. } else { //读卡失败
  15688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15689. return
  15690. }
  15691. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15692. //idNo := c.GetString("idNo")
  15693. //userName := c.GetString("userName")
  15694. //ecToken := c.GetString("ecToken")
  15695. //insuOrg := c.GetString("insuOrg")
  15696. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  15697. utils.ErrorLog("解析失败:%v", json_result)
  15698. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15699. type ELeData struct {
  15700. Data struct {
  15701. IdNo string `json:"idNo"`
  15702. IdType string `json:"idType"`
  15703. UserName string `json:"userName"`
  15704. EcToken string `json:"ecToken"`
  15705. InsuOrg string `json:"insuOrg"`
  15706. Gender string `json:"gender"`
  15707. Birthday string `json:"birthday"`
  15708. Nationality string `json:"nationality"`
  15709. Email string `json:"email"`
  15710. Extra string `json:"extra"`
  15711. } `json:"data"`
  15712. Code int `json:"code"`
  15713. Message string `json:"message"`
  15714. }
  15715. var ele ELeData
  15716. err := json.Unmarshal([]byte(json_result), &ele)
  15717. if err != nil {
  15718. utils.ErrorLog("解析失败:%v", err)
  15719. }
  15720. token := ele.Data.EcToken
  15721. token = Remove0000(token)
  15722. 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)
  15723. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15724. var res ResultTwo
  15725. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15726. utils.ErrorLog("解析失败:%v", err)
  15727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15728. return
  15729. }
  15730. if res.Infcode == 0 {
  15731. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15732. if err == gorm.ErrRecordNotFound {
  15733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15734. return
  15735. } else if err != nil {
  15736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15737. return
  15738. } else {
  15739. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15740. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15741. infoStr := string(Iinfos)
  15742. idetinfoStr := string(Idetinfos)
  15743. psn := &models.HisPsn{
  15744. PsnNo: res.Output.Baseinfo.PsnNo,
  15745. PatientId: patient.ID,
  15746. Certno: res.Output.Baseinfo.Certno,
  15747. Gend: res.Output.Baseinfo.Gend,
  15748. Naty: res.Output.Baseinfo.Naty,
  15749. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15750. PsnName: res.Output.Baseinfo.PsnName,
  15751. Idetinfo: idetinfoStr,
  15752. Insuinfo: infoStr,
  15753. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15754. CardInfo: "",
  15755. Stage: "1",
  15756. VerifyNumber: token,
  15757. InsuplcAdmdvs: ele.Data.InsuOrg,
  15758. }
  15759. service.CreateHisPsn(psn)
  15760. var rf []*ResultFive
  15761. json.Unmarshal([]byte(infoStr), &rf)
  15762. var insutypes []*ResultFive
  15763. var insutype string
  15764. var is390 int = 0
  15765. var is310 int = 0
  15766. for _, item := range rf {
  15767. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15768. insutypes = append(insutypes, item)
  15769. }
  15770. }
  15771. if len(insutypes) == 1 {
  15772. insutype = insutypes[0].Insutype
  15773. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15774. } else {
  15775. for _, i := range insutypes {
  15776. if i.Insutype == "390" {
  15777. is390 = 1
  15778. }
  15779. if i.Insutype == "310" {
  15780. is310 = 1
  15781. }
  15782. }
  15783. }
  15784. if is390 == 1 {
  15785. insutype = "390"
  15786. }
  15787. if is310 == 1 {
  15788. insutype = "310"
  15789. }
  15790. if len(insutypes) == 0 {
  15791. insutype = "310"
  15792. }
  15793. c.ServeSuccessJSON(map[string]interface{}{
  15794. "patient": patient,
  15795. "number": token,
  15796. "insutype": insutype,
  15797. })
  15798. }
  15799. } else {
  15800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15801. return
  15802. }
  15803. } else if miConfig.MdtrtareaAdmvs == "360302" {
  15804. //if initFlag == 0 {
  15805. //c.TestGetJiangXiBasBaseInit()
  15806. //}
  15807. //if initEleFlag == 0 {
  15808. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15809. //}
  15810. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15811. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15812. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15813. type ELeData struct {
  15814. Data struct {
  15815. IdNo string `json:"idNo"`
  15816. IdType string `json:"idType"`
  15817. UserName string `json:"userName"`
  15818. EcToken string `json:"ecToken"`
  15819. InsuOrg string `json:"insuOrg"`
  15820. Gender string `json:"gender"`
  15821. Birthday string `json:"birthday"`
  15822. Nationality string `json:"nationality"`
  15823. Email string `json:"email"`
  15824. Extra string `json:"extra"`
  15825. } `json:"data"`
  15826. Code int `json:"code"`
  15827. Message string `json:"message"`
  15828. }
  15829. var ele ELeData
  15830. err := json.Unmarshal([]byte(result), &ele)
  15831. if err != nil {
  15832. utils.ErrorLog("解析失败:%v", err)
  15833. }
  15834. token := ele.Data.EcToken
  15835. token = Remove0000(token)
  15836. 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)
  15837. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15838. var res ResultTwo
  15839. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15840. utils.ErrorLog("解析失败:%v", err)
  15841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15842. return
  15843. }
  15844. if res.Infcode == 0 {
  15845. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15846. if err == gorm.ErrRecordNotFound {
  15847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15848. return
  15849. } else if err != nil {
  15850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15851. return
  15852. } else {
  15853. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15854. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15855. infoStr := string(Iinfos)
  15856. idetinfoStr := string(Idetinfos)
  15857. psn := &models.HisPsn{
  15858. PsnNo: res.Output.Baseinfo.PsnNo,
  15859. PatientId: patient.ID,
  15860. Certno: res.Output.Baseinfo.Certno,
  15861. Gend: res.Output.Baseinfo.Gend,
  15862. Naty: res.Output.Baseinfo.Naty,
  15863. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15864. PsnName: res.Output.Baseinfo.PsnName,
  15865. Idetinfo: idetinfoStr,
  15866. Insuinfo: infoStr,
  15867. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15868. CardInfo: "",
  15869. VerifyNumber: token,
  15870. InsuplcAdmdvs: ele.Data.InsuOrg,
  15871. }
  15872. service.CreateHisPsn(psn)
  15873. var rf []*ResultFive
  15874. json.Unmarshal([]byte(infoStr), &rf)
  15875. var insutypes []*ResultFive
  15876. var insutype string
  15877. var is390 int = 0
  15878. var is310 int = 0
  15879. for _, item := range rf {
  15880. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15881. insutypes = append(insutypes, item)
  15882. }
  15883. }
  15884. if len(insutypes) == 1 {
  15885. insutype = insutypes[0].Insutype
  15886. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15887. } else {
  15888. for _, i := range insutypes {
  15889. if i.Insutype == "390" {
  15890. is390 = 1
  15891. }
  15892. if i.Insutype == "310" {
  15893. is310 = 1
  15894. }
  15895. }
  15896. }
  15897. if is390 == 1 {
  15898. insutype = "390"
  15899. }
  15900. if is310 == 1 {
  15901. insutype = "310"
  15902. }
  15903. if len(insutypes) == 0 {
  15904. insutype = "310"
  15905. }
  15906. c.ServeSuccessJSON(map[string]interface{}{
  15907. "patient": patient,
  15908. "number": token,
  15909. "insutype": insutype,
  15910. })
  15911. }
  15912. } else {
  15913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15914. return
  15915. }
  15916. } else if miConfig.MdtrtareaAdmvs == "361025" {
  15917. //if initFlag == 0 {
  15918. //c.TestGetJiangXiBasBaseInit()
  15919. //}
  15920. //if initEleFlag == 0 {
  15921. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  15922. //}
  15923. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  15924. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  15925. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  15926. type ELeData struct {
  15927. Data struct {
  15928. IdNo string `json:"idNo"`
  15929. IdType string `json:"idType"`
  15930. UserName string `json:"userName"`
  15931. EcToken string `json:"ecToken"`
  15932. InsuOrg string `json:"insuOrg"`
  15933. Gender string `json:"gender"`
  15934. Birthday string `json:"birthday"`
  15935. Nationality string `json:"nationality"`
  15936. Email string `json:"email"`
  15937. Extra string `json:"extra"`
  15938. } `json:"data"`
  15939. Code int `json:"code"`
  15940. Message string `json:"message"`
  15941. }
  15942. var ele ELeData
  15943. err := json.Unmarshal([]byte(result), &ele)
  15944. if err != nil {
  15945. utils.ErrorLog("解析失败:%v", err)
  15946. }
  15947. token := ele.Data.EcToken
  15948. token = Remove0000(token)
  15949. 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)
  15950. saveLog(result2, requestLog2, "1101", "获取人员信息")
  15951. var res ResultTwo
  15952. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15953. utils.ErrorLog("解析失败:%v", err)
  15954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15955. return
  15956. }
  15957. if res.Infcode == 0 {
  15958. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15959. if err == gorm.ErrRecordNotFound {
  15960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15961. return
  15962. } else if err != nil {
  15963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15964. return
  15965. } else {
  15966. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15967. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15968. infoStr := string(Iinfos)
  15969. idetinfoStr := string(Idetinfos)
  15970. psn := &models.HisPsn{
  15971. PsnNo: res.Output.Baseinfo.PsnNo,
  15972. PatientId: patient.ID,
  15973. Certno: res.Output.Baseinfo.Certno,
  15974. Gend: res.Output.Baseinfo.Gend,
  15975. Naty: res.Output.Baseinfo.Naty,
  15976. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15977. PsnName: res.Output.Baseinfo.PsnName,
  15978. Idetinfo: idetinfoStr,
  15979. Insuinfo: infoStr,
  15980. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15981. CardInfo: "",
  15982. VerifyNumber: token,
  15983. InsuplcAdmdvs: ele.Data.InsuOrg,
  15984. }
  15985. service.CreateHisPsn(psn)
  15986. var rf []*ResultFive
  15987. json.Unmarshal([]byte(infoStr), &rf)
  15988. var insutypes []*ResultFive
  15989. var insutype string
  15990. var is390 int = 0
  15991. var is310 int = 0
  15992. for _, item := range rf {
  15993. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15994. insutypes = append(insutypes, item)
  15995. }
  15996. }
  15997. if len(insutypes) == 1 {
  15998. insutype = insutypes[0].Insutype
  15999. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16000. } else {
  16001. for _, i := range insutypes {
  16002. if i.Insutype == "390" {
  16003. is390 = 1
  16004. }
  16005. if i.Insutype == "310" {
  16006. is310 = 1
  16007. }
  16008. }
  16009. }
  16010. if is390 == 1 {
  16011. insutype = "390"
  16012. }
  16013. if is310 == 1 {
  16014. insutype = "310"
  16015. }
  16016. if len(insutypes) == 0 {
  16017. insutype = "310"
  16018. }
  16019. c.ServeSuccessJSON(map[string]interface{}{
  16020. "patient": patient,
  16021. "number": token,
  16022. "insutype": insutype,
  16023. })
  16024. }
  16025. } else {
  16026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16027. return
  16028. }
  16029. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16030. //if initFlag == 0 {
  16031. c.TestGetJiangXiBasBaseInit()
  16032. //}
  16033. //if initEleFlag == 0 {
  16034. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16035. //}
  16036. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16037. type ELeData struct {
  16038. Data struct {
  16039. IdNo string `json:"idNo"`
  16040. IdType string `json:"idType"`
  16041. UserName string `json:"userName"`
  16042. EcToken string `json:"ecToken"`
  16043. InsuOrg string `json:"insuOrg"`
  16044. Gender string `json:"gender"`
  16045. Birthday string `json:"birthday"`
  16046. Nationality string `json:"nationality"`
  16047. Email string `json:"email"`
  16048. Extra string `json:"extra"`
  16049. } `json:"data"`
  16050. Code int `json:"code"`
  16051. Message string `json:"message"`
  16052. }
  16053. var ele ELeData
  16054. err := json.Unmarshal([]byte(json_result), &ele)
  16055. if err != nil {
  16056. utils.ErrorLog("解析失败:%v", err)
  16057. }
  16058. token := ele.Data.EcToken
  16059. token = Remove0000(token)
  16060. 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)
  16061. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16062. var res ResultTwo
  16063. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16064. utils.ErrorLog("解析失败:%v", err)
  16065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16066. return
  16067. }
  16068. if res.Infcode == 0 {
  16069. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16070. if err == gorm.ErrRecordNotFound {
  16071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16072. return
  16073. } else if err != nil {
  16074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16075. return
  16076. } else {
  16077. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16078. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16079. infoStr := string(Iinfos)
  16080. idetinfoStr := string(Idetinfos)
  16081. psn := &models.HisPsn{
  16082. PsnNo: res.Output.Baseinfo.PsnNo,
  16083. PatientId: patient.ID,
  16084. Certno: res.Output.Baseinfo.Certno,
  16085. Gend: res.Output.Baseinfo.Gend,
  16086. Naty: res.Output.Baseinfo.Naty,
  16087. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16088. PsnName: res.Output.Baseinfo.PsnName,
  16089. Idetinfo: idetinfoStr,
  16090. Insuinfo: infoStr,
  16091. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16092. CardInfo: "",
  16093. VerifyNumber: token,
  16094. }
  16095. service.CreateHisPsn(psn)
  16096. var rf []*ResultFive
  16097. json.Unmarshal([]byte(infoStr), &rf)
  16098. var insutypes []*ResultFive
  16099. var insutype string
  16100. var is390 int = 0
  16101. var is310 int = 0
  16102. for _, item := range rf {
  16103. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16104. insutypes = append(insutypes, item)
  16105. }
  16106. }
  16107. if len(insutypes) == 1 {
  16108. insutype = insutypes[0].Insutype
  16109. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16110. } else {
  16111. for _, i := range insutypes {
  16112. if i.Insutype == "390" {
  16113. is390 = 1
  16114. }
  16115. if i.Insutype == "310" {
  16116. is310 = 1
  16117. }
  16118. }
  16119. }
  16120. if is390 == 1 {
  16121. insutype = "390"
  16122. }
  16123. if is310 == 1 {
  16124. insutype = "310"
  16125. }
  16126. if len(insutypes) == 0 {
  16127. insutype = "310"
  16128. }
  16129. c.ServeSuccessJSON(map[string]interface{}{
  16130. "patient": patient,
  16131. "number": token,
  16132. "insutype": insutype,
  16133. })
  16134. }
  16135. } else {
  16136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16137. return
  16138. }
  16139. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16140. type ELeData struct {
  16141. Code string `json:"code"`
  16142. Data struct {
  16143. Aac002 string `json:"aac002"`
  16144. Aaz500 string `json:"aaz500"`
  16145. ActCardNo string `json:"actCardNo"`
  16146. Bab520 string `json:"bab520"`
  16147. Bkz543 string `json:"bkz543"`
  16148. BusinessType string `json:"businessType"`
  16149. CertfCodg string `json:"certfCodg"`
  16150. EcIndexNo string `json:"ecIndexNo"`
  16151. EcToken string `json:"ecToken"`
  16152. ID0000 string `json:"id0000"`
  16153. IDNo string `json:"idNo"`
  16154. IDType string `json:"idType"`
  16155. Idcode string `json:"idcode"`
  16156. IdentityToken string `json:"identity_token"`
  16157. InsuOrg string `json:"insuOrg"`
  16158. OfficeID string `json:"officeId"`
  16159. OfficeName string `json:"officeName"`
  16160. OperatorID string `json:"operatorId"`
  16161. OperatorName string `json:"operatorName"`
  16162. OrgID string `json:"orgId"`
  16163. UserName string `json:"userName"`
  16164. } `json:"data"`
  16165. Infno interface{} `json:"infno"`
  16166. Message string `json:"message"`
  16167. OrgID string `json:"orgId"`
  16168. TransType string `json:"transType"`
  16169. }
  16170. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  16171. outPutInfo = Remove0000(outPutInfo)
  16172. if len(outPutInfo) > 0 {
  16173. var ele ELeData
  16174. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16175. if err != nil {
  16176. utils.ErrorLog("解析失败:%v", err)
  16177. }
  16178. token := ele.Data.EcToken
  16179. fmt.Println(inputInfo)
  16180. fmt.Println(outPutInfo)
  16181. 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)
  16182. saveLog(result, requestLog, "1101", "获取人员信息")
  16183. var dat map[string]interface{}
  16184. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16185. fmt.Println(dat)
  16186. } else {
  16187. fmt.Println(err)
  16188. }
  16189. userJSONBytes, _ := json.Marshal(dat)
  16190. var res ResultTwo
  16191. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16192. utils.ErrorLog("解析失败:%v", err)
  16193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16194. return
  16195. }
  16196. res.ErrMsg = errMsgLog
  16197. if res.Infcode == 0 {
  16198. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16199. if err == gorm.ErrRecordNotFound {
  16200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16201. return
  16202. } else if err != nil {
  16203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16204. return
  16205. } else {
  16206. fmt.Println(res)
  16207. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16208. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16209. infoStr := string(Iinfos)
  16210. idetinfoStr := string(Idetinfos)
  16211. psn := &models.HisPsn{
  16212. PsnNo: res.Output.Baseinfo.PsnNo,
  16213. PatientId: patient.ID,
  16214. Certno: res.Output.Baseinfo.Certno,
  16215. Gend: res.Output.Baseinfo.Gend,
  16216. Naty: res.Output.Baseinfo.Naty,
  16217. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16218. PsnName: res.Output.Baseinfo.PsnName,
  16219. Idetinfo: idetinfoStr,
  16220. Insuinfo: infoStr,
  16221. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16222. CardInfo: outPutInfo,
  16223. VerifyNumber: token,
  16224. InsuplcAdmdvs: ele.Data.InsuOrg,
  16225. }
  16226. service.CreateHisPsn(psn)
  16227. var rf []*ResultFive
  16228. json.Unmarshal([]byte(infoStr), &rf)
  16229. var insutypes []*ResultFive
  16230. var insutype string
  16231. var is390 int = 0
  16232. var is310 int = 0
  16233. for _, item := range rf {
  16234. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16235. insutypes = append(insutypes, item)
  16236. }
  16237. }
  16238. if len(insutypes) == 1 {
  16239. insutype = insutypes[0].Insutype
  16240. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16241. } else {
  16242. for _, i := range insutypes {
  16243. if i.Insutype == "390" {
  16244. is390 = 1
  16245. }
  16246. if i.Insutype == "310" {
  16247. is310 = 1
  16248. }
  16249. }
  16250. }
  16251. if is390 == 1 {
  16252. insutype = "390"
  16253. }
  16254. if is310 == 1 {
  16255. insutype = "310"
  16256. }
  16257. if len(insutypes) == 0 {
  16258. insutype = "310"
  16259. }
  16260. c.ServeSuccessJSON(map[string]interface{}{
  16261. "patient": patient,
  16262. "number": token,
  16263. "insutype": insutype,
  16264. })
  16265. }
  16266. } else {
  16267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16268. return
  16269. }
  16270. }
  16271. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16272. var api string
  16273. 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 +
  16274. "&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
  16275. resp, requestErr := http.Get(api)
  16276. if requestErr != nil {
  16277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16278. return
  16279. }
  16280. body, ioErr := ioutil.ReadAll(resp.Body)
  16281. if ioErr != nil {
  16282. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16284. return
  16285. }
  16286. var respJSON map[string]interface{}
  16287. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16290. return
  16291. }
  16292. var status string
  16293. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16294. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16295. var token string
  16296. var res ResultTwo //1101结果
  16297. var res10265 ResultTwo10265 //1101结果
  16298. if status == "0" { //读卡成功
  16299. var card_info string //卡信息
  16300. var busi_card_info string
  16301. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16302. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16303. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16304. fmt.Println(card_info)
  16305. fmt.Println(busi_card_info)
  16306. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16307. result, _ := json.Marshal(respJSON)
  16308. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16309. utils.ErrorLog("解析失败:%v", err)
  16310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16311. return
  16312. }
  16313. res.ErrMsg = res10265.ErrMsg
  16314. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16315. res.Infcode = infocode
  16316. res.Output = res10265.Output
  16317. res.InfRefmsgid = res10265.InfRefmsgid
  16318. if res.Infcode == 0 {
  16319. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16320. if err == gorm.ErrRecordNotFound {
  16321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16322. return
  16323. } else if err != nil {
  16324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16325. return
  16326. } else {
  16327. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16328. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16329. infoStr := string(Iinfos)
  16330. idetinfoStr := string(Idetinfos)
  16331. psn := &models.HisPsn{
  16332. PsnNo: res.Output.Baseinfo.PsnNo,
  16333. PatientId: patient.ID,
  16334. Certno: res.Output.Baseinfo.Certno,
  16335. Gend: res.Output.Baseinfo.Gend,
  16336. Naty: res.Output.Baseinfo.Naty,
  16337. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16338. PsnName: res.Output.Baseinfo.PsnName,
  16339. Idetinfo: idetinfoStr,
  16340. Insuinfo: infoStr,
  16341. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16342. CardInfo: card_info,
  16343. VerifyNumber: token,
  16344. }
  16345. var rf []*ResultFive
  16346. json.Unmarshal([]byte(infoStr), &rf)
  16347. var insutypes []*ResultFive
  16348. var insutype string
  16349. var is390 int = 0
  16350. var is310 int = 0
  16351. for _, item := range rf {
  16352. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16353. insutypes = append(insutypes, item)
  16354. }
  16355. }
  16356. if len(insutypes) == 1 {
  16357. insutype = insutypes[0].Insutype
  16358. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16359. } else {
  16360. for _, i := range insutypes {
  16361. if i.Insutype == "390" {
  16362. is390 = 1
  16363. }
  16364. if i.Insutype == "310" {
  16365. is310 = 1
  16366. }
  16367. }
  16368. }
  16369. if is390 == 1 {
  16370. insutype = "390"
  16371. }
  16372. if is310 == 1 {
  16373. insutype = "310"
  16374. }
  16375. if len(insutypes) == 0 {
  16376. insutype = "310"
  16377. }
  16378. service.CreateHisPsn(psn)
  16379. c.ServeSuccessJSON(map[string]interface{}{
  16380. "patient": patient,
  16381. "number": token,
  16382. "insutype": insutype,
  16383. })
  16384. }
  16385. } else {
  16386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16387. return
  16388. }
  16389. } else { //读卡失败
  16390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16391. return
  16392. }
  16393. } else if miConfig.MdtrtareaAdmvs == "450721" {
  16394. res := c.GetoleInfo()
  16395. if res.Infcode == 0 {
  16396. var result string
  16397. if res.Output.MdtrtCertType == "01" {
  16398. 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)
  16399. } else if res.Output.MdtrtCertType == "02" {
  16400. 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)
  16401. } else if res.Output.MdtrtCertType == "03" {
  16402. 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)
  16403. }
  16404. var dat map[string]interface{}
  16405. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16406. fmt.Println(dat)
  16407. } else {
  16408. fmt.Println(err)
  16409. }
  16410. userJSONBytes, _ := json.Marshal(dat)
  16411. var res2 ResultTwo
  16412. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  16413. utils.ErrorLog("解析失败:%v", err)
  16414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16415. return
  16416. }
  16417. if res2.Infcode == 0 {
  16418. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  16419. if err == gorm.ErrRecordNotFound {
  16420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16421. return
  16422. } else if err != nil {
  16423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16424. return
  16425. } else {
  16426. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  16427. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  16428. infoStr := string(Iinfos)
  16429. idetinfoStr := string(Idetinfos)
  16430. var rf []*ResultFive
  16431. json.Unmarshal([]byte(infoStr), &rf)
  16432. var insutypes []*ResultFive
  16433. var insutype string
  16434. var is390 int = 0
  16435. var is310 int = 0
  16436. //var insuplc_admdvs string
  16437. for _, item := range rf {
  16438. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16439. insutypes = append(insutypes, item)
  16440. }
  16441. }
  16442. if len(insutypes) == 1 {
  16443. insutype = insutypes[0].Insutype
  16444. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16445. } else {
  16446. for _, i := range insutypes {
  16447. if i.Insutype == "390" {
  16448. is390 = 1
  16449. }
  16450. if i.Insutype == "310" {
  16451. is310 = 1
  16452. }
  16453. }
  16454. }
  16455. if is390 == 1 {
  16456. insutype = "390"
  16457. }
  16458. if is310 == 1 {
  16459. insutype = "310"
  16460. }
  16461. if len(insutypes) == 0 {
  16462. insutype = "310"
  16463. }
  16464. psn := &models.HisPsn{
  16465. PsnNo: res2.Output.Baseinfo.PsnNo,
  16466. PatientId: patient.ID,
  16467. Certno: res2.Output.Baseinfo.Certno,
  16468. Gend: res2.Output.Baseinfo.Gend,
  16469. Naty: res2.Output.Baseinfo.Naty,
  16470. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  16471. PsnName: res2.Output.Baseinfo.PsnName,
  16472. Idetinfo: idetinfoStr,
  16473. Insuinfo: infoStr,
  16474. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16475. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  16476. VerifyNumber: res.Output.EcToken,
  16477. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  16478. }
  16479. if res.Output.MdtrtCertType == "01" {
  16480. psn.VerifyNumber = res.Output.EcToken
  16481. //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)
  16482. } else if res.Output.MdtrtCertType == "02" {
  16483. psn.VerifyNumber = res.Output.CardNo
  16484. //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)
  16485. } else if res.Output.MdtrtCertType == "03" {
  16486. psn.VerifyNumber = res.Output.MdtrtCertNo
  16487. //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)
  16488. }
  16489. service.CreateHisPsn(psn)
  16490. var balc float64
  16491. for _, item := range rf {
  16492. if item.Insutype == insutype {
  16493. balc = item.Balc
  16494. }
  16495. }
  16496. c.ServeSuccessJSON(map[string]interface{}{
  16497. "patient": patient,
  16498. "number": res.Output.CardNo,
  16499. "insutype": insutype,
  16500. "blac": balc,
  16501. "desc": idetinfoStr,
  16502. })
  16503. }
  16504. } else {
  16505. c.ServeSuccessJSON(map[string]interface{}{
  16506. "failed_code": -10,
  16507. "msg": res2.ErrMsg,
  16508. })
  16509. }
  16510. } else {
  16511. c.ServeSuccessJSON(map[string]interface{}{
  16512. "failed_code": -10,
  16513. "msg": res.ErrMsg,
  16514. })
  16515. }
  16516. } else if miConfig.MdtrtareaAdmvs == "420902" {
  16517. var res ResultTwo
  16518. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  16519. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16520. "&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)
  16521. resp, requestErr := http.Get(api)
  16522. if requestErr != nil {
  16523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16524. return
  16525. }
  16526. body, ioErr := ioutil.ReadAll(resp.Body)
  16527. if ioErr != nil {
  16528. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16530. return
  16531. }
  16532. var respJSON map[string]interface{}
  16533. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16534. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16536. return
  16537. }
  16538. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16539. result, _ := json.Marshal(respJSON)
  16540. fmt.Println("log")
  16541. fmt.Println(string(result))
  16542. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16543. utils.ErrorLog("解析失败:%v", err)
  16544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16545. return
  16546. }
  16547. if res.Infcode == 0 {
  16548. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16549. if err == gorm.ErrRecordNotFound {
  16550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16551. return
  16552. } else if err != nil {
  16553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16554. return
  16555. } else {
  16556. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16557. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16558. infoStr := string(Iinfos)
  16559. idetinfoStr := string(Idetinfos)
  16560. var rf []*ResultFive
  16561. json.Unmarshal([]byte(infoStr), &rf)
  16562. var insutypes []*ResultFive
  16563. var insutype string
  16564. var is390 int = 0
  16565. var is310 int = 0
  16566. for _, item := range rf {
  16567. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  16568. insutypes = append(insutypes, item)
  16569. }
  16570. }
  16571. if len(insutypes) == 1 {
  16572. insutype = insutypes[0].Insutype
  16573. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16574. } else {
  16575. for _, i := range insutypes {
  16576. if i.Insutype == "390" {
  16577. is390 = 1
  16578. }
  16579. if i.Insutype == "310" {
  16580. is310 = 1
  16581. }
  16582. }
  16583. }
  16584. if is390 == 1 {
  16585. insutype = "390"
  16586. }
  16587. if is310 == 1 {
  16588. insutype = "310"
  16589. }
  16590. if len(insutypes) == 0 {
  16591. insutype = "390"
  16592. }
  16593. var insuplc_admdvs string
  16594. for _, item := range rf {
  16595. if item.Insutype == insutype {
  16596. insuplc_admdvs = item.InsuplcAdmdvs
  16597. }
  16598. }
  16599. psn := &models.HisPsn{
  16600. PsnNo: res.Output.Baseinfo.PsnNo,
  16601. PatientId: patient.ID,
  16602. Certno: res.Output.Baseinfo.Certno,
  16603. Gend: res.Output.Baseinfo.Gend,
  16604. Naty: res.Output.Baseinfo.Naty,
  16605. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16606. PsnName: res.Output.Baseinfo.PsnName,
  16607. Idetinfo: idetinfoStr,
  16608. Insuinfo: infoStr,
  16609. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16610. InsuplcAdmdvs: insuplc_admdvs,
  16611. }
  16612. service.CreateHisPsn(psn)
  16613. c.ServeSuccessJSON(map[string]interface{}{
  16614. "patient": patient,
  16615. "number": res.Output.Baseinfo.Certno,
  16616. })
  16617. }
  16618. } else {
  16619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16620. return
  16621. }
  16622. } else {
  16623. type ELeData struct {
  16624. Code string `json:"code"`
  16625. Data struct {
  16626. Aac002 string `json:"aac002"`
  16627. Aaz500 string `json:"aaz500"`
  16628. ActCardNo string `json:"actCardNo"`
  16629. Bab520 string `json:"bab520"`
  16630. Bkz543 string `json:"bkz543"`
  16631. BusinessType string `json:"businessType"`
  16632. CertfCodg string `json:"certfCodg"`
  16633. EcIndexNo string `json:"ecIndexNo"`
  16634. EcToken string `json:"ecToken"`
  16635. ID0000 string `json:"id0000"`
  16636. IDNo string `json:"idNo"`
  16637. IDType string `json:"idType"`
  16638. Idcode string `json:"idcode"`
  16639. IdentityToken string `json:"identity_token"`
  16640. InsuOrg string `json:"insuOrg"`
  16641. OfficeID string `json:"officeId"`
  16642. OfficeName string `json:"officeName"`
  16643. OperatorID string `json:"operatorId"`
  16644. OperatorName string `json:"operatorName"`
  16645. OrgID string `json:"orgId"`
  16646. UserName string `json:"userName"`
  16647. } `json:"data"`
  16648. Infno interface{} `json:"infno"`
  16649. Message string `json:"message"`
  16650. OrgID string `json:"orgId"`
  16651. TransType string `json:"transType"`
  16652. }
  16653. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  16654. fmt.Println(result)
  16655. outPutInfo := Remove0000(result)
  16656. fmt.Println(outPutInfo)
  16657. if len(outPutInfo) > 0 {
  16658. var ele ELeData
  16659. err := json.Unmarshal([]byte(outPutInfo), &ele)
  16660. if err != nil {
  16661. utils.ErrorLog("解析失败:%v", err)
  16662. }
  16663. token := ele.Data.EcToken
  16664. fmt.Println(outPutInfo)
  16665. 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)
  16666. saveLog(result, requestLog, "1101", "获取人员信息")
  16667. var dat map[string]interface{}
  16668. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16669. fmt.Println(dat)
  16670. } else {
  16671. fmt.Println(err)
  16672. }
  16673. userJSONBytes, _ := json.Marshal(dat)
  16674. var res ResultTwo
  16675. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16676. utils.ErrorLog("解析失败:%v", err)
  16677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16678. return
  16679. }
  16680. if res.Infcode == 0 {
  16681. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  16682. if err == gorm.ErrRecordNotFound {
  16683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16684. return
  16685. } else if err != nil {
  16686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16687. return
  16688. } else {
  16689. fmt.Println(res)
  16690. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16691. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16692. infoStr := string(Iinfos)
  16693. idetinfoStr := string(Idetinfos)
  16694. psn := &models.HisPsn{
  16695. PsnNo: res.Output.Baseinfo.PsnNo,
  16696. PatientId: patient.ID,
  16697. Certno: res.Output.Baseinfo.Certno,
  16698. Gend: res.Output.Baseinfo.Gend,
  16699. Naty: res.Output.Baseinfo.Naty,
  16700. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16701. PsnName: res.Output.Baseinfo.PsnName,
  16702. Idetinfo: idetinfoStr,
  16703. Insuinfo: infoStr,
  16704. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16705. CardInfo: outPutInfo,
  16706. VerifyNumber: token,
  16707. InsuplcAdmdvs: ele.Data.InsuOrg,
  16708. }
  16709. service.CreateHisPsn(psn)
  16710. var rf []*ResultFive
  16711. json.Unmarshal([]byte(infoStr), &rf)
  16712. var insutypes []*ResultFive
  16713. var insutype string
  16714. var is390 int = 0
  16715. var is310 int = 0
  16716. for _, item := range rf {
  16717. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16718. insutypes = append(insutypes, item)
  16719. }
  16720. }
  16721. if len(insutypes) == 1 {
  16722. insutype = insutypes[0].Insutype
  16723. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16724. } else {
  16725. for _, i := range insutypes {
  16726. if i.Insutype == "390" {
  16727. is390 = 1
  16728. }
  16729. if i.Insutype == "310" {
  16730. is310 = 1
  16731. }
  16732. }
  16733. }
  16734. if is390 == 1 {
  16735. insutype = "390"
  16736. }
  16737. if is310 == 1 {
  16738. insutype = "310"
  16739. }
  16740. if len(insutypes) == 0 {
  16741. insutype = "310"
  16742. }
  16743. c.ServeSuccessJSON(map[string]interface{}{
  16744. "patient": patient,
  16745. "number": token,
  16746. "insutype": insutype,
  16747. })
  16748. }
  16749. } else {
  16750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16751. return
  16752. }
  16753. }
  16754. //fmt.Println(result)
  16755. //
  16756. //if initFlag == 0 {
  16757. // c.TestGetBasBaseInit()
  16758. //}
  16759. //token := c.GetEleBaseInfo()
  16760. //
  16761. //token = Remove0000(token)
  16762. //
  16763. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  16764. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  16765. ////
  16766. //var res ResultTwo
  16767. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16768. // utils.ErrorLog("解析失败:%v", err)
  16769. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16770. // return
  16771. //}
  16772. //
  16773. //if res.Infcode == 0 {
  16774. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16775. // if err == gorm.ErrRecordNotFound {
  16776. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16777. // return
  16778. // } else if err != nil {
  16779. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16780. // return
  16781. //
  16782. // } else {
  16783. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16784. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16785. // infoStr := string(Iinfos)
  16786. // idetinfoStr := string(Idetinfos)
  16787. //
  16788. //
  16789. //
  16790. //
  16791. // var rf []*ResultFive
  16792. // json.Unmarshal([]byte(infoStr), &rf)
  16793. //
  16794. // var insutypes []*ResultFive
  16795. // var insutype string
  16796. // var is390 int = 0
  16797. // var is310 int = 0
  16798. // var insuplc_admdvs string
  16799. //
  16800. // for _, item := range rf {
  16801. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16802. // insutypes = append(insutypes, item)
  16803. // }
  16804. // }
  16805. //
  16806. // if len(insutypes) == 1 {
  16807. // insutype = insutypes[0].Insutype
  16808. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16809. // } else {
  16810. // for _, i := range insutypes {
  16811. // if i.Insutype == "390" {
  16812. // is390 = 1
  16813. // }
  16814. //
  16815. // if i.Insutype == "310" {
  16816. // is310 = 1
  16817. // }
  16818. // }
  16819. // }
  16820. // if is390 == 1 {
  16821. // insutype = "390"
  16822. // }
  16823. //
  16824. // if is310 == 1 {
  16825. // insutype = "310"
  16826. // }
  16827. // if len(insutypes) == 0 {
  16828. // insutype = "310"
  16829. // }
  16830. // for _, item := range rf {
  16831. // if item.Insutype == insutype {
  16832. // insuplc_admdvs = item.InsuplcAdmdvs
  16833. // }
  16834. // }
  16835. // psn := &models.HisPsn{
  16836. // PsnNo: res.Output.Baseinfo.PsnNo,
  16837. // Age: res.Output.Baseinfo.Age,
  16838. // PatientId: patient.ID,
  16839. // Certno: res.Output.Baseinfo.Certno,
  16840. // Brdy: res.Output.Baseinfo.Brdy,
  16841. // Gend: res.Output.Baseinfo.Gend,
  16842. // Naty: res.Output.Baseinfo.Naty,
  16843. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  16844. // PsnName: res.Output.Baseinfo.PsnName,
  16845. // Idetinfo: idetinfoStr,
  16846. // Insuinfo: infoStr,
  16847. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16848. // CardInfo: "",
  16849. // VerifyNumber: token,
  16850. // InsuplcAdmdvs: insuplc_admdvs,
  16851. // }
  16852. // service.CreateHisPsn(psn)
  16853. //
  16854. // c.ServeSuccessJSON(map[string]interface{}{
  16855. // "patient": patient,
  16856. // "number": token,
  16857. // })
  16858. // }
  16859. //} else {
  16860. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16861. // return
  16862. //}
  16863. }
  16864. break
  16865. case 5:
  16866. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16867. var api string
  16868. if miConfig.MdtrtareaAdmvs == "320921" {
  16869. 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 +
  16870. "&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
  16871. fmt.Println(api)
  16872. } else {
  16873. 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 +
  16874. "&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)
  16875. }
  16876. resp, requestErr := http.Get(api)
  16877. if requestErr != nil {
  16878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16879. return
  16880. }
  16881. body, ioErr := ioutil.ReadAll(resp.Body)
  16882. if ioErr != nil {
  16883. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16885. return
  16886. }
  16887. var respJSON map[string]interface{}
  16888. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16889. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16891. return
  16892. }
  16893. var status string
  16894. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16895. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16896. var token string
  16897. var res ResultTwo //1101结果
  16898. var res10265 ResultTwo10265 //1101结果
  16899. if status == "0" { //读卡成功
  16900. var card_info string //卡信息
  16901. //var busi_card_info string
  16902. var auth_info string
  16903. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16904. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16905. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16906. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  16907. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16908. result, _ := json.Marshal(respJSON)
  16909. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16910. utils.ErrorLog("解析失败:%v", err)
  16911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16912. return
  16913. }
  16914. res.ErrMsg = res10265.ErrMsg
  16915. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16916. res.Infcode = infocode
  16917. res.Output = res10265.Output
  16918. res.InfRefmsgid = res10265.InfRefmsgid
  16919. if res.Infcode == 0 {
  16920. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16921. if err == gorm.ErrRecordNotFound {
  16922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16923. return
  16924. } else if err != nil {
  16925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16926. return
  16927. } else {
  16928. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16929. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16930. infoStr := string(Iinfos)
  16931. idetinfoStr := string(Idetinfos)
  16932. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  16933. psn := &models.HisPsn{
  16934. PsnNo: res.Output.Baseinfo.PsnNo,
  16935. PatientId: patient.ID,
  16936. Certno: res.Output.Baseinfo.Certno,
  16937. Gend: res.Output.Baseinfo.Gend,
  16938. Brdy: b,
  16939. Age: float64(age),
  16940. Naty: res.Output.Baseinfo.Naty,
  16941. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16942. PsnName: res.Output.Baseinfo.PsnName,
  16943. Idetinfo: idetinfoStr,
  16944. Insuinfo: infoStr,
  16945. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16946. CardInfo: card_info,
  16947. VerifyNumber: token,
  16948. AuthInfo: auth_info,
  16949. }
  16950. var rf []*ResultFive
  16951. json.Unmarshal([]byte(infoStr), &rf)
  16952. var insutypes []*ResultFive
  16953. var insutype string
  16954. var is390 int = 0
  16955. var is310 int = 0
  16956. for _, item := range rf {
  16957. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16958. insutypes = append(insutypes, item)
  16959. }
  16960. }
  16961. if len(insutypes) == 1 {
  16962. insutype = insutypes[0].Insutype
  16963. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16964. } else {
  16965. for _, i := range insutypes {
  16966. if i.Insutype == "390" {
  16967. is390 = 1
  16968. }
  16969. if i.Insutype == "310" {
  16970. is310 = 1
  16971. }
  16972. }
  16973. }
  16974. if is390 == 1 {
  16975. insutype = "390"
  16976. }
  16977. if is310 == 1 {
  16978. insutype = "310"
  16979. }
  16980. if len(insutypes) == 0 {
  16981. insutype = "310"
  16982. }
  16983. service.CreateHisPsn(psn)
  16984. c.ServeSuccessJSON(map[string]interface{}{
  16985. "patient": patient,
  16986. "number": token,
  16987. "insutype": insutype,
  16988. })
  16989. }
  16990. } else {
  16991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16992. return
  16993. }
  16994. } else { //读卡失败
  16995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16996. return
  16997. }
  16998. }
  16999. break
  17000. }
  17001. }
  17002. var initFlag int64 = 0
  17003. var initEleFlag int64 = 0
  17004. func (c *HisApiController) TestGetBasBaseInit() {
  17005. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17006. Iinit := DllDef.MustFindProc("Init")
  17007. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17008. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  17009. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  17010. if ret != 0 {
  17011. fmt.Println("SSCard的报错原因:", err)
  17012. fmt.Println("SSCard的运算结果为:", ret)
  17013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17014. return
  17015. }
  17016. result := int(ret)
  17017. fmt.Println("SSCard的运算结果为1:", result)
  17018. initFlag = 1
  17019. return
  17020. }
  17021. func (c *HisApiController) HandleJiangXiReadCard() {
  17022. fmt.Println("~~~~~~")
  17023. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17024. admin_user_id, _ := c.GetInt64("admin_user_id")
  17025. id_card_type, _ := c.GetInt64("id_card_type")
  17026. //certificates, _ := c.GetInt64("certificates")
  17027. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17028. if initFlag == 0 {
  17029. c.TestGetJiangXiBasBaseInit()
  17030. }
  17031. basStr := c.GetBasBaseInfo()
  17032. if len(basStr) == 0 {
  17033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17034. return
  17035. }
  17036. fmt.Println(basStr)
  17037. bas := strings.Split(basStr, "|")
  17038. basNumber := bas[1]
  17039. fmt.Println(basNumber)
  17040. card_sn := bas[3]
  17041. fmt.Println(card_sn)
  17042. 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, "")
  17043. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  17044. var dat map[string]interface{}
  17045. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17046. fmt.Println(dat)
  17047. } else {
  17048. fmt.Println(err)
  17049. }
  17050. userJSONBytes, _ := json.Marshal(dat)
  17051. var res ResultTwo
  17052. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17053. utils.ErrorLog("解析失败:%v", err)
  17054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17055. return
  17056. }
  17057. if res.Infcode == 0 {
  17058. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  17059. if err == gorm.ErrRecordNotFound {
  17060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17061. return
  17062. } else if err != nil {
  17063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17064. return
  17065. } else {
  17066. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17067. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17068. infoStr := string(Iinfos)
  17069. idetinfoStr := string(Idetinfos)
  17070. psn := &models.HisPsn{
  17071. PsnNo: res.Output.Baseinfo.PsnNo,
  17072. PatientId: patient.ID,
  17073. Certno: res.Output.Baseinfo.Certno,
  17074. Gend: res.Output.Baseinfo.Gend,
  17075. Naty: res.Output.Baseinfo.Naty,
  17076. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17077. PsnName: res.Output.Baseinfo.PsnName,
  17078. Idetinfo: idetinfoStr,
  17079. Insuinfo: infoStr,
  17080. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17081. CardInfo: basStr,
  17082. VerifyNumber: "",
  17083. }
  17084. service.CreateHisPsn(psn)
  17085. c.ServeSuccessJSON(map[string]interface{}{
  17086. "patient": patient,
  17087. "number": basNumber,
  17088. })
  17089. }
  17090. } else {
  17091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17092. return
  17093. }
  17094. }
  17095. func (c *HisApiController) TestGetHnBasBaseInit() {
  17096. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17097. Iinit := DllDef.MustFindProc("Init")
  17098. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17099. //http://10.77.211.236/CSB/hsa-fsi-1303
  17100. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  17101. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  17102. // 调用 Init 函数
  17103. 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"))))
  17104. //if ret != 0 {
  17105. fmt.Println("SSCard的报错原因:", err)
  17106. fmt.Println("SSCard的运算结果为:", ret)
  17107. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17108. // return
  17109. //}
  17110. result := int(ret)
  17111. fmt.Println("SSCard的运算结果为1:", result)
  17112. initFlag = 1
  17113. return
  17114. }
  17115. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  17116. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17117. Iinit := DllDef.MustFindProc("Init")
  17118. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17119. //http://10.77.211.236/CSB/hsa-fsi-1303
  17120. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  17121. if ret != 0 {
  17122. fmt.Println("SSCard的报错原因:", err)
  17123. fmt.Println("SSCard的运算结果为:", ret)
  17124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17125. return
  17126. }
  17127. result := int(ret)
  17128. fmt.Println("SSCard的运算结果为1:", result)
  17129. initFlag = 1
  17130. return
  17131. }
  17132. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  17133. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17134. Iinit := DllDef.MustFindProc("Init")
  17135. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17136. //http://10.77.211.236/CSB/hsa-fsi-1303
  17137. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  17138. if ret != 0 {
  17139. fmt.Println("SSCard的报错原因:", err)
  17140. fmt.Println("SSCard的运算结果为:", ret)
  17141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  17142. return
  17143. }
  17144. result := int(ret)
  17145. fmt.Println("SSCard的运算结果为1:", result)
  17146. initFlag = 1
  17147. return
  17148. }
  17149. func (c *HisApiController) GetSFZBaseInfo() string {
  17150. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17151. readCard := DllDef.MustFindProc("ReadSFZ")
  17152. if readCard == nil {
  17153. fmt.Println("readcard is nil")
  17154. readCard = DllDef.MustFindProc("ReadSFZ")
  17155. }
  17156. str := make([]byte, 8096)
  17157. str1 := make([]byte, 8096)
  17158. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  17159. fmt.Println(r)
  17160. return Remove0000(string(str))
  17161. }
  17162. func (c *HisApiController) GetEleBaseInfo() string {
  17163. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17164. readCard := DllDef.MustFindProc("GetQRBase")
  17165. fmt.Println(readCard)
  17166. if readCard == nil {
  17167. fmt.Println("readcard is nil")
  17168. readCard = DllDef.MustFindProc("GetQRBase")
  17169. }
  17170. str := make([]byte, 1024)
  17171. str1 := make([]byte, 1024)
  17172. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17173. fmt.Println(ret2)
  17174. fmt.Println(string(str1))
  17175. fmt.Println(string(str))
  17176. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17177. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17178. if ret2 != 0 {
  17179. return ""
  17180. }
  17181. return string(str)
  17182. }
  17183. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17184. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17185. readCard := DllDef.MustFindProc("NationEcTrans")
  17186. fmt.Println(readCard)
  17187. fmt.Println("!!!!!")
  17188. pBusiCardInfo := make([]byte, 2048)
  17189. input := make(map[string]interface{})
  17190. inputData := make(map[string]interface{})
  17191. inputData["orgId"] = code
  17192. inputData["businessType"] = "01101"
  17193. inputData["operatorId"] = "1"
  17194. inputData["operatorName"] = "admin"
  17195. inputData["officeId"] = "001"
  17196. inputData["officeName"] = "血透室"
  17197. inputData["deviceType"] = ""
  17198. input["data"] = inputData
  17199. input["orgId"] = code
  17200. input["transType"] = "ec.query"
  17201. bytesData, _ := json.Marshal(input)
  17202. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  17203. fmt.Println(ret2)
  17204. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17205. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17206. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  17207. }
  17208. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  17209. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17210. readCard := DllDef.MustFindProc("NationEcTrans")
  17211. fmt.Println(readCard)
  17212. fmt.Println("!!!!!")
  17213. pBusiCardInfo := make([]byte, 2048)
  17214. input := make(map[string]interface{})
  17215. inputData := make(map[string]interface{})
  17216. inputData["orgId"] = code
  17217. inputData["businessType"] = "01101"
  17218. inputData["operatorId"] = "9"
  17219. inputData["operatorName"] = "admin"
  17220. inputData["officeId"] = "001"
  17221. inputData["officeName"] = "血透室"
  17222. inputData["deviceType"] = ""
  17223. input["data"] = inputData
  17224. input["orgId"] = code
  17225. input["transType"] = "ec.query"
  17226. bytesData, _ := json.Marshal(input)
  17227. 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])))
  17228. fmt.Println(ret2)
  17229. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17230. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17231. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17232. }
  17233. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  17234. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  17235. readCard := DllDef.MustFindProc("NationEcTrans")
  17236. fmt.Println(readCard)
  17237. fmt.Println("!!!!!")
  17238. pBusiCardInfo := make([]byte, 2048)
  17239. input := make(map[string]interface{})
  17240. inputData := make(map[string]interface{})
  17241. inputData["orgId"] = code
  17242. inputData["businessType"] = "01301"
  17243. inputData["operatorId"] = "9"
  17244. inputData["operatorName"] = "admin"
  17245. inputData["officeId"] = "001"
  17246. inputData["officeName"] = "血透室"
  17247. inputData["deviceType"] = ""
  17248. input["data"] = inputData
  17249. input["orgId"] = code
  17250. input["transType"] = "ec.query"
  17251. bytesData, _ := json.Marshal(input)
  17252. 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])))
  17253. fmt.Println(ret2)
  17254. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  17255. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  17256. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  17257. }
  17258. func GetJxEleBaseInfo(org_id int64) string {
  17259. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17260. readCard := DllDef.MustFindProc("NationEcTrans")
  17261. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17262. if readCard == nil {
  17263. fmt.Println("readcard is nil")
  17264. readCard = DllDef.MustFindProc("NationEcTrans")
  17265. }
  17266. str1 := make([]byte, 1024)
  17267. data := make(map[string]interface{})
  17268. inputData := make(map[string]interface{})
  17269. inputData["orgId"] = miConfig.Code
  17270. inputData["businessType"] = "01101"
  17271. inputData["operatorId"] = "test001"
  17272. inputData["operatorName"] = "cn"
  17273. inputData["officeId"] = "32760"
  17274. inputData["officeName"] = "waike"
  17275. inputData["deviceType"] = ""
  17276. data["data"] = inputData
  17277. data["transType"] = "ec.query"
  17278. data["extra "] = ""
  17279. data["orgId"] = miConfig.Code
  17280. bytesData, _ := json.Marshal(data)
  17281. //bytesData, _ := json.Marshal(data)
  17282. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17283. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17284. fmt.Println(ret2)
  17285. fmt.Println(string(str1))
  17286. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17287. if ret2 != 0 {
  17288. return ""
  17289. }
  17290. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17291. }
  17292. //func GetJxEleBaseInfoTWO(org_id int64) string {
  17293. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  17294. // readCard := DllDef.MustFindProc("NationEcTrans")
  17295. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17296. //
  17297. // if readCard == nil {
  17298. // fmt.Println("readcard is nil")
  17299. // readCard = DllDef.MustFindProc("NationEcTrans")
  17300. // }
  17301. // str1 := make([]byte, 1024)
  17302. //
  17303. // data := make(map[string]interface{})
  17304. //
  17305. // inputData := make(map[string]interface{})
  17306. // inputData["orgId"] = miConfig.Code
  17307. // inputData["businessType"] = "01101"
  17308. // inputData["operatorId"] = "test001"
  17309. // inputData["operatorName"] = "cn"
  17310. // inputData["officeId"] = "32760"
  17311. // inputData["officeName"] = "waike"
  17312. // inputData["deviceType"] = ""
  17313. //
  17314. // data["data"] = inputData
  17315. // data["transType"] = "ec.query"
  17316. // data["extra "] = ""
  17317. // data["orgId"] = miConfig.Code
  17318. // bytesData, _ := json.Marshal(data)
  17319. // //bytesData, _ := json.Marshal(data)
  17320. //
  17321. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17322. //
  17323. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17324. // fmt.Println(ret2)
  17325. // fmt.Println(string(str1))
  17326. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17327. //
  17328. // if ret2 != 0 {
  17329. // return ""
  17330. // }
  17331. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17332. //}
  17333. func GetJxEleBaseInitInfo(org_id int64) string {
  17334. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17335. readCard := DllDef.MustFindProc("NationEcTrans")
  17336. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  17337. if readCard == nil {
  17338. fmt.Println("readcard is nil")
  17339. readCard = DllDef.MustFindProc("NationEcTrans")
  17340. }
  17341. str1 := make([]byte, 2048)
  17342. data := make(map[string]interface{})
  17343. inputData := make(map[string]interface{})
  17344. inputData["orgId"] = miConfig.Code
  17345. inputData["businessType"] = "01101"
  17346. inputData["operatorId"] = "1"
  17347. inputData["operatorName"] = "huangchuang"
  17348. inputData["officeId"] = "101"
  17349. inputData["officeName"] = "xuetou"
  17350. inputData["deviceType"] = ""
  17351. data["data"] = inputData
  17352. data["transType"] = "ec.query"
  17353. data["orgId"] = miConfig.Code
  17354. bytesData, _ := json.Marshal(data)
  17355. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  17356. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17357. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  17358. fmt.Println(ret2)
  17359. fmt.Println(string(str1))
  17360. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17361. if ret2 != 0 {
  17362. return ""
  17363. }
  17364. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  17365. initEleFlag = 1
  17366. }
  17367. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  17368. }
  17369. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  17370. // // 构建命令
  17371. // cmd := exec.Command("python", "b.py")
  17372. //
  17373. // // 执行命令并等待完成
  17374. // output, err := cmd.CombinedOutput()
  17375. // if err != nil {
  17376. // fmt.Println("Error executing Python script:", err)
  17377. // return
  17378. // }
  17379. //
  17380. // // 打印Python脚本的输出
  17381. // fmt.Println(string(output))
  17382. //}
  17383. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  17384. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  17385. readCard := DllDef.MustFindProc("gxyb_call")
  17386. if readCard == nil {
  17387. fmt.Println("readcard is nil")
  17388. readCard = DllDef.MustFindProc("gxyb_call")
  17389. }
  17390. str := make([]byte, 1024)
  17391. str1 := make([]byte, 1024)
  17392. //data := make(map[string]interface{})
  17393. currentTime := time.Now()
  17394. // 格式化时间为 "YYYYMMDDHH24MISS"
  17395. formattedTime := currentTime.Format("20060102150405")
  17396. inputData := make(map[string]interface{})
  17397. inputData2 := make(map[string]interface{})
  17398. inputData["transNo"] = "1401"
  17399. inputData["transType"] = "passwordCheck"
  17400. inputData["timestamp"] = formattedTime
  17401. inputData2["fixmedinsCode"] = code
  17402. inputData2["psnNo"] = ""
  17403. inputData["data"] = inputData2
  17404. jsonBytes, err := json.Marshal(inputData)
  17405. if err != nil {
  17406. fmt.Println("Error encoding map to JSON:", err)
  17407. }
  17408. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17409. fmt.Println(string(str1))
  17410. fmt.Println(string(str))
  17411. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17412. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17413. if ret2 != 0 {
  17414. return ""
  17415. }
  17416. return string(str)
  17417. }
  17418. func (c *HisApiController) GetoleInfo() Response {
  17419. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  17420. defer ole.CoUninitialize()
  17421. // Replace with the ProgID or CLSID of your COM object
  17422. progID := "YinHai.XJ.Actual.Interface.New"
  17423. // Create COM object
  17424. unknown, err := oleutil.CreateObject(progID)
  17425. if err != nil {
  17426. fmt.Println("Unable to create COM object:", err)
  17427. }
  17428. defer unknown.Release()
  17429. // Query for the IDispatch interface
  17430. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  17431. if err != nil {
  17432. fmt.Println("Unable to get IDispatch interface:", err)
  17433. }
  17434. defer dispatch.Release()
  17435. // Prepare parameters
  17436. transNo := "1401"
  17437. transType := "passwordCheck"
  17438. timestamp := time.Now().Unix()
  17439. fixmedinsCode := "H45072101171"
  17440. psnNo := ""
  17441. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  17442. result2 := ""
  17443. // Call COM object's method using the IDispatch interface
  17444. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  17445. fmt.Println(resulr)
  17446. fmt.Println(result2)
  17447. if err != nil {
  17448. fmt.Println("调用COM对象方法失败:", err)
  17449. }
  17450. var response Response
  17451. err2 := json.Unmarshal([]byte(result2), &response)
  17452. if err2 != nil {
  17453. fmt.Println("解析JSON失败:", err)
  17454. }
  17455. return response
  17456. }
  17457. func (c *HisApiController) GetBasBaseInfo() string {
  17458. DllDef := syscall.MustLoadDLL("SSCard.dll")
  17459. readCard := DllDef.MustFindProc("ReadCardBas")
  17460. if readCard == nil {
  17461. fmt.Println("readcard is nil")
  17462. readCard = DllDef.MustFindProc("ReadCardBas")
  17463. }
  17464. str := make([]byte, 1024)
  17465. str1 := make([]byte, 1024)
  17466. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  17467. fmt.Println(string(str1))
  17468. fmt.Println(string(str))
  17469. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17470. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17471. if ret2 != 0 {
  17472. return ""
  17473. }
  17474. return string(str)
  17475. }
  17476. type Program struct {
  17477. FunctionID string `xml:"function_id"`
  17478. CardInfo string `xml:"cardinfo"`
  17479. User string `xml:"user"`
  17480. }
  17481. func (c *HisApiController) GetBasBaseInfo1111() string {
  17482. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  17483. readCard := DllDef.MustFindProc("ReadSICardInfo")
  17484. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  17485. if readCard == nil {
  17486. fmt.Println("readcard is nil")
  17487. readCard = DllDef.MustFindProc("ReadSICardInfo")
  17488. }
  17489. if readCard2 == nil {
  17490. fmt.Println("readcard is nil")
  17491. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  17492. }
  17493. str := make([]byte, 1024)
  17494. str1 := make([]byte, 1024)
  17495. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  17496. str3 := make([]byte, 1024)
  17497. str4 := make([]byte, 1024)
  17498. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  17499. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17500. //if err != nil {
  17501. // fmt.Println("Error opening file:", err)
  17502. //}
  17503. //defer file.Close()
  17504. //
  17505. //var lastProgram Program
  17506. //scanner := bufio.NewScanner(file)
  17507. //inProgram := false
  17508. //
  17509. //for scanner.Scan() {
  17510. // line := scanner.Text()
  17511. // if strings.Contains(line, "<program>") {
  17512. // inProgram = true
  17513. // programXML := "<program>"
  17514. // for scanner.Scan() {
  17515. // line = scanner.Text()
  17516. // programXML += line
  17517. // if strings.Contains(line, "</program>") {
  17518. // programXML += "</program>"
  17519. // break
  17520. // }
  17521. // }
  17522. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17523. // // 解析成功,更新最后的 Program
  17524. // }
  17525. // inProgram = false
  17526. // }
  17527. //}
  17528. //
  17529. // fmt.Println("Error reading file:", inProgram)
  17530. //
  17531. //if err := scanner.Err(); err != nil {
  17532. // fmt.Println("Error reading file:", err)
  17533. //}
  17534. // 输出最后一次的 Program
  17535. //fmt.Printf("最后一次的 <program>:\n")
  17536. //fmt.Printf("<program>\n")
  17537. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17538. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17539. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17540. //fmt.Printf("</program>\n")
  17541. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17542. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17543. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17544. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17545. return ConvertToString(string(str), "gbk", "utf-8")
  17546. }
  17547. func (c *HisApiController) GetBasBaseInfo22222() string {
  17548. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17549. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17550. if readCard == nil {
  17551. fmt.Println("readcard is nil")
  17552. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  17553. }
  17554. str := make([]byte, 1024)
  17555. str1 := make([]byte, 1024)
  17556. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  17557. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17558. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17559. //if err != nil {
  17560. // fmt.Println("Error opening file:", err)
  17561. //}
  17562. //defer file.Close()
  17563. //
  17564. //var lastProgram Program
  17565. //scanner := bufio.NewScanner(file)
  17566. //inProgram := false
  17567. //
  17568. //for scanner.Scan() {
  17569. // line := scanner.Text()
  17570. // if strings.Contains(line, "<program>") {
  17571. // inProgram = true
  17572. // programXML := "<program>"
  17573. // for scanner.Scan() {
  17574. // line = scanner.Text()
  17575. // programXML += line
  17576. // if strings.Contains(line, "</program>") {
  17577. // programXML += "</program>"
  17578. // break
  17579. // }
  17580. // }
  17581. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17582. // // 解析成功,更新最后的 Program
  17583. // }
  17584. // inProgram = false
  17585. // }
  17586. //}
  17587. //
  17588. // fmt.Println("Error reading file:", inProgram)
  17589. //
  17590. //if err := scanner.Err(); err != nil {
  17591. // fmt.Println("Error reading file:", err)
  17592. //}
  17593. // 输出最后一次的 Program
  17594. //fmt.Printf("最后一次的 <program>:\n")
  17595. //fmt.Printf("<program>\n")
  17596. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17597. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17598. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17599. //fmt.Printf("</program>\n")
  17600. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17601. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17602. return ConvertToString(string(str1), "gbk", "utf-8")
  17603. }
  17604. func (c *HisApiController) GetahBasBaseInfo() string {
  17605. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  17606. readCard := DllDef.MustFindProc("iReadCardBas")
  17607. if readCard == nil {
  17608. fmt.Println("readcard is nil")
  17609. readCard = DllDef.MustFindProc("iReadCardBas")
  17610. }
  17611. //str := make([]byte, 1024)
  17612. str1 := make([]byte, 1024)
  17613. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  17614. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  17615. //if err != nil {
  17616. // fmt.Println("Error opening file:", err)
  17617. //}
  17618. //defer file.Close()
  17619. //
  17620. //var lastProgram Program
  17621. //scanner := bufio.NewScanner(file)
  17622. //inProgram := false
  17623. //
  17624. //for scanner.Scan() {
  17625. // line := scanner.Text()
  17626. // if strings.Contains(line, "<program>") {
  17627. // inProgram = true
  17628. // programXML := "<program>"
  17629. // for scanner.Scan() {
  17630. // line = scanner.Text()
  17631. // programXML += line
  17632. // if strings.Contains(line, "</program>") {
  17633. // programXML += "</program>"
  17634. // break
  17635. // }
  17636. // }
  17637. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  17638. // // 解析成功,更新最后的 Program
  17639. // }
  17640. // inProgram = false
  17641. // }
  17642. //}
  17643. //
  17644. // fmt.Println("Error reading file:", inProgram)
  17645. //
  17646. //if err := scanner.Err(); err != nil {
  17647. // fmt.Println("Error reading file:", err)
  17648. //}
  17649. // 输出最后一次的 Program
  17650. //fmt.Printf("最后一次的 <program>:\n")
  17651. //fmt.Printf("<program>\n")
  17652. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  17653. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  17654. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  17655. //fmt.Printf("</program>\n")
  17656. fmt.Println(string(str1))
  17657. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17658. if ret2 != 0 {
  17659. return ""
  17660. }
  17661. return string(str1)
  17662. }
  17663. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  17664. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  17665. readCard := DllDef.MustFindProc("read_cardinfo")
  17666. if readCard == nil {
  17667. fmt.Println("readcard is nil")
  17668. readCard = DllDef.MustFindProc("read_cardinfo")
  17669. }
  17670. str := make([]byte, 1024) //卡号
  17671. str1 := make([]byte, 1024) //卡识别码
  17672. str2 := make([]byte, 1024) //身份证号
  17673. str3 := make([]byte, 1024) //姓名
  17674. str4 := make([]byte, 1024) //错误信息
  17675. 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])))
  17676. fmt.Println(string(str1))
  17677. fmt.Println(string(str))
  17678. fmt.Println(string(str2))
  17679. fmt.Println(string(str3))
  17680. fmt.Println(string(str4))
  17681. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  17682. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  17683. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  17684. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  17685. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  17686. if ret2 != 0 {
  17687. return "", "", "", "", ""
  17688. }
  17689. return string(str), string(str1), string(str2), string(str3), string(str4)
  17690. }
  17691. type CustomFundPay struct {
  17692. FundPayType string `json:"fund_pay_type"`
  17693. FundPayamt float64 `json:"fund_payamt"`
  17694. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17695. }
  17696. //func (c *HisApiController) GetBatchSettleList() {
  17697. // start_time_str := c.GetString("start_time")
  17698. // //end_time_str := c.GetString("end_time")
  17699. // admin_user_id, _ := c.GetInt64("admin_user_id")
  17700. //
  17701. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  17702. //
  17703. // for _, item := range orders {
  17704. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  17705. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17706. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17707. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17708. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17709. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17710. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17711. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  17712. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  17713. //
  17714. // if order.ID == 0 {
  17715. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  17716. // return
  17717. // }
  17718. //
  17719. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17720. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17721. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  17722. // //fmt.Println(count)
  17723. // //var zero string
  17724. // //number := count + 1
  17725. // //if number >= 1000 {
  17726. // // zero = "0000" + strconv.FormatInt(number, 10)
  17727. // //} else if number >= 10000 {
  17728. // // zero = "000" + strconv.FormatInt(number, 10)
  17729. // //} else if number >= 100000 {
  17730. // // zero = "00" + strconv.FormatInt(number, 10)
  17731. // //} else if number >= 1000000 {
  17732. // // zero = "0" + strconv.FormatInt(number, 10)
  17733. // //} else {
  17734. // // zero = strconv.FormatInt(number, 10)
  17735. // //}
  17736. // //fmt.Println(zero)
  17737. //
  17738. // struct4101 := service.Struct4101{
  17739. // PsnNo: order.PsnNo,
  17740. // MdtrtId: order.MdtrtId,
  17741. // SetlId: order.SetlId,
  17742. // PsnName: order.PsnName,
  17743. // Gend: order.Gend,
  17744. // Brdy: his.Brdy,
  17745. // Age: his.Age,
  17746. // Naty: order.Naty,
  17747. // PatnCertType: "01",
  17748. // Certno: order.Certno,
  17749. // Prfs: "90",
  17750. // ConerName: roles[0].UserName,
  17751. // PatnRlts: "99",
  17752. // ConerAddr: miConfig.OrgName,
  17753. // ConerTel: admin.Mobile,
  17754. // HiType: order.Insutype,
  17755. // Insuplc: miConfig.InsuplcAdmdvs,
  17756. // MaindiagFlag: "1",
  17757. // BillCode: order.SetlId,
  17758. // BillNo: order.SetlId,
  17759. // BizSn: order.Number,
  17760. // PsnSelfPay: order.PsnPartAmt,
  17761. // PsnOwnPay: order.PsnPartAmt,
  17762. // AcctPay: order.AcctPay,
  17763. // PsnCashpay: order.PsnCashPay,
  17764. // HiPaymtd: "1",
  17765. // Hsorg: miConfig.InsuplcAdmdvs,
  17766. // HsorgOpter: miConfig.InsuplcAdmdvs,
  17767. // MedinsFillPsn: curRoles.UserName,
  17768. // MedinsFillDept: miConfig.OrgName,
  17769. // IptMedType: "2",
  17770. // }
  17771. // struct4101.SetlBegnDate = order.SetlTime
  17772. // struct4101.SetlEndDate = order.SetlTime
  17773. // time_arr := strings.Split(order.SetlTime, " ")
  17774. // struct4101.AdmTime = time_arr[0]
  17775. // struct4101.AdmEndTime = time_arr[0]
  17776. //
  17777. // var rf []CustomFundPay
  17778. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  17779. //
  17780. // var tempFunPays []service.CustomStruct
  17781. // for _, item := range rf {
  17782. // var tempFunPay service.CustomStruct
  17783. // tempFunPay.FundPayamt = item.FundPayamt
  17784. // tempFunPay.FundPayType = item.FundPayType
  17785. // tempFunPays = append(tempFunPays, tempFunPay)
  17786. // }
  17787. // struct4101.CustomStruct = tempFunPays
  17788. //
  17789. // var tempDiaginfos []service.DiaginfoStructTwo
  17790. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  17791. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  17792. //
  17793. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  17794. // var config []*models.HisXtDiagnoseConfig
  17795. // for _, item := range diagnosis_ids {
  17796. // id, _ := strconv.ParseInt(item, 10, 64)
  17797. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  17798. // config = append(config, &diagnosisConfig)
  17799. // }
  17800. //
  17801. // for index, item := range config {
  17802. // if index == 0 {
  17803. // var tempDiaginfo service.DiaginfoStructTwo
  17804. // tempDiaginfo.DiagCode = item.CountryCode
  17805. // tempDiaginfo.DiagName = item.CountryContentName
  17806. // tempDiaginfo.DiagType = "1"
  17807. // tempDiaginfo.MaindiagFlag = "1"
  17808. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17809. // } else {
  17810. // var tempDiaginfo service.DiaginfoStructTwo
  17811. // tempDiaginfo.DiagCode = item.CountryCode
  17812. // tempDiaginfo.DiagName = item.CountryContentName
  17813. // tempDiaginfo.DiagType = "1"
  17814. // tempDiaginfo.MaindiagFlag = "0"
  17815. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17816. // }
  17817. // }
  17818. // struct4101.Diseinfo = tempDiaginfos
  17819. //
  17820. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  17821. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  17822. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  17823. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  17824. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  17825. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  17826. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  17827. //
  17828. // var iteminfo service.IteminfoStruct
  17829. //
  17830. // var bedCostTotal float64 = 0 //床位总费
  17831. // var bedCostSelfTotal float64 = 0 //床位自费
  17832. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  17833. //
  17834. // var operationCostTotal float64 = 0 //手术费
  17835. // var operationCostSelfTotal float64 = 0 //手术费
  17836. // var operationCostPartSelfTotal float64 = 0 //手术费
  17837. //
  17838. // var otherCostTotal float64 = 0 //其他费用
  17839. // var otherCostSelfTotal float64 = 0 //其他费用
  17840. // var otherCostPartSelfTotal float64 = 0 //其他费用
  17841. //
  17842. // var materialCostTotal float64 = 0 //材料费
  17843. // var materialCostSelfTotal float64 = 0 //材料费
  17844. // var materialCostPartSelfTotal float64 = 0 //材料费
  17845. //
  17846. // var westernMedicineCostTotal float64 = 0 //西药费
  17847. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  17848. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  17849. //
  17850. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  17851. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  17852. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  17853. //
  17854. // var checkCostTotal float64 = 0 //检查费
  17855. // var checkCostSelfTotal float64 = 0 //检查费
  17856. // var checkCostPartSelfTotal float64 = 0 //检查费
  17857. //
  17858. // var laboratoryCostTotal float64 = 0 //化验费
  17859. // var laboratoryCostSelfTotal float64 = 0 //化验费
  17860. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  17861. //
  17862. // var treatCostTotal float64 = 0 //治疗费用
  17863. // var treatCostSelfTotal float64 = 0 //治疗费用
  17864. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  17865. //
  17866. // decimal.DivisionPrecision = 2
  17867. //
  17868. // var bed_fulamt_ownpay_amt float64 = 0
  17869. // var operation_fulamt_ownpay_amt float64 = 0
  17870. // var other_fulamt_ownpay_amt float64 = 0
  17871. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  17872. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  17873. // var check_fulamt_ownpay_amt float64 = 0
  17874. // var material_fulamt_ownpay_amt float64 = 0
  17875. // var laboratory_fulamt_ownpay_amt float64 = 0
  17876. // var treat_fulamt_ownpay_amt float64 = 0
  17877. //
  17878. // var bed_claa_sunmfee float64 = 0
  17879. // var bed_clab_amt float64 = 0
  17880. // var bed_other_amt float64 = 0
  17881. //
  17882. // var operation_claa_sunmfee float64 = 0
  17883. // var operation_clab_amt float64 = 0
  17884. // var operation_other_amt float64 = 0
  17885. //
  17886. // var other_claa_sunmfee float64 = 0
  17887. // var other_clab_amt float64 = 0
  17888. // var other_other_amt float64 = 0
  17889. //
  17890. // var westernMedicine_claa_sunmfee float64 = 0
  17891. // var westernMedicine_clab_amt float64 = 0
  17892. // var westernMedicine_other_amt float64 = 0
  17893. //
  17894. // var chineseTraditional_claa_sunmfee float64 = 0
  17895. // var chineseTraditional_clab_amt float64 = 0
  17896. // var chineseTraditional_other_amt float64 = 0
  17897. //
  17898. // var check_claa_sunmfee float64 = 0
  17899. // var check_clab_amt float64 = 0
  17900. // var check_other_amt float64 = 0
  17901. //
  17902. // var material_claa_sunmfee float64 = 0
  17903. // var material_clab_amt float64 = 0
  17904. // var material_other_amt float64 = 0
  17905. //
  17906. // var laboratory_claa_sunmfee float64 = 0
  17907. // var laboratory_clab_amt float64 = 0
  17908. // var laboratory_other_amt float64 = 0
  17909. //
  17910. // var treat_claa_sunmfee float64 = 0
  17911. // var treat_clab_amt float64 = 0
  17912. // var treat_other_amt float64 = 0
  17913. //
  17914. // for _, item := range order.HisOrderInfo {
  17915. // if item.MedChrgitmType == "01" { //床位费
  17916. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17917. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17918. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17919. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17920. // if item.ChrgitmLv == "1" {
  17921. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17922. // }
  17923. // if item.ChrgitmLv == "2" {
  17924. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17925. //
  17926. // }
  17927. // if item.ChrgitmLv == "3" {
  17928. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17929. // }
  17930. //
  17931. // }
  17932. //
  17933. // if item.MedChrgitmType == "03" { //检查费
  17934. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17935. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17936. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17937. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17938. // if item.ChrgitmLv == "1" {
  17939. //
  17940. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17941. //
  17942. // }
  17943. // if item.ChrgitmLv == "2" {
  17944. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17945. //
  17946. // }
  17947. // if item.ChrgitmLv == "3" {
  17948. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17949. // }
  17950. // }
  17951. //
  17952. // if item.MedChrgitmType == "04" { //化验费
  17953. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17954. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17955. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17956. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17957. // if item.ChrgitmLv == "1" {
  17958. //
  17959. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17960. //
  17961. // }
  17962. // if item.ChrgitmLv == "2" {
  17963. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17964. //
  17965. // }
  17966. // if item.ChrgitmLv == "3" {
  17967. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17968. // }
  17969. // }
  17970. //
  17971. // if item.MedChrgitmType == "05" { //治疗费
  17972. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17973. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17974. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17975. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17976. // if item.ChrgitmLv == "1" {
  17977. //
  17978. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17979. //
  17980. // }
  17981. // if item.ChrgitmLv == "2" {
  17982. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17983. //
  17984. // }
  17985. // if item.ChrgitmLv == "3" {
  17986. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17987. // }
  17988. // }
  17989. //
  17990. // if item.MedChrgitmType == "06" { //手术费
  17991. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17992. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17993. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17994. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17995. //
  17996. // if item.ChrgitmLv == "1" {
  17997. //
  17998. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17999. //
  18000. // }
  18001. // if item.ChrgitmLv == "2" {
  18002. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18003. //
  18004. // }
  18005. // if item.ChrgitmLv == "3" {
  18006. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18007. // }
  18008. // }
  18009. //
  18010. // if item.MedChrgitmType == "08" { //材料费
  18011. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18012. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18013. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18014. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18015. // if item.ChrgitmLv == "1" {
  18016. //
  18017. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18018. //
  18019. // }
  18020. // if item.ChrgitmLv == "2" {
  18021. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18022. //
  18023. // }
  18024. // if item.ChrgitmLv == "3" {
  18025. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18026. // }
  18027. // }
  18028. //
  18029. // if item.MedChrgitmType == "09" { //西药费
  18030. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18031. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18032. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18033. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18034. // if item.ChrgitmLv == "1" {
  18035. //
  18036. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18037. //
  18038. // }
  18039. // if item.ChrgitmLv == "2" {
  18040. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18041. //
  18042. // }
  18043. // if item.ChrgitmLv == "3" {
  18044. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18045. // }
  18046. // }
  18047. //
  18048. // if item.MedChrgitmType == "11" { //中成费
  18049. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18050. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18051. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18052. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18053. // if item.ChrgitmLv == "1" {
  18054. //
  18055. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18056. //
  18057. // }
  18058. // if item.ChrgitmLv == "2" {
  18059. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18060. //
  18061. // }
  18062. // if item.ChrgitmLv == "3" {
  18063. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18064. // }
  18065. // }
  18066. //
  18067. // if item.MedChrgitmType == "14" { //其他费
  18068. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18069. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18070. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18071. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18072. // if item.ChrgitmLv == "1" {
  18073. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18074. //
  18075. // }
  18076. // if item.ChrgitmLv == "2" {
  18077. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18078. //
  18079. // }
  18080. // if item.ChrgitmLv == "3" {
  18081. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18082. // }
  18083. // }
  18084. //
  18085. // }
  18086. //
  18087. // var iteminfoStructs []service.IteminfoStruct
  18088. //
  18089. // if bedCostTotal != 0 {
  18090. // iteminfo.MedChrgitm = "01"
  18091. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18092. // iteminfo.Amt = bedCostTotal
  18093. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  18094. // iteminfo.ClabAmt = bed_clab_amt
  18095. // iteminfo.OthAmt = bed_other_amt
  18096. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18097. // }
  18098. //
  18099. // if checkCostTotal != 0 {
  18100. // iteminfo.MedChrgitm = "03"
  18101. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18102. // iteminfo.Amt = checkCostTotal
  18103. // iteminfo.ClaaSumfee = check_claa_sunmfee
  18104. // iteminfo.ClabAmt = check_clab_amt
  18105. // iteminfo.OthAmt = check_other_amt
  18106. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18107. //
  18108. // }
  18109. //
  18110. // if laboratoryCostTotal != 0 {
  18111. // iteminfo.MedChrgitm = "04"
  18112. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18113. // iteminfo.Amt = laboratoryCostTotal
  18114. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18115. // iteminfo.ClabAmt = laboratory_clab_amt
  18116. // iteminfo.OthAmt = laboratory_other_amt
  18117. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18118. //
  18119. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18120. //
  18121. // }
  18122. //
  18123. // if treatCostTotal != 0 {
  18124. // iteminfo.MedChrgitm = "05"
  18125. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18126. // iteminfo.Amt = treatCostTotal
  18127. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  18128. // iteminfo.ClabAmt = treat_clab_amt
  18129. // iteminfo.OthAmt = treat_other_amt
  18130. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18131. // //(struct4101.IteminfoStruct, iteminfo)
  18132. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18133. // }
  18134. //
  18135. // if operationCostTotal != 0 {
  18136. // iteminfo.MedChrgitm = "06"
  18137. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18138. // iteminfo.Amt = operationCostTotal
  18139. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  18140. // iteminfo.ClabAmt = operation_clab_amt
  18141. // iteminfo.OthAmt = operation_other_amt
  18142. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18143. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18144. // }
  18145. //
  18146. // if materialCostTotal != 0 {
  18147. // iteminfo.MedChrgitm = "08"
  18148. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18149. // iteminfo.Amt = materialCostTotal
  18150. // iteminfo.ClaaSumfee = material_claa_sunmfee
  18151. // iteminfo.ClabAmt = material_clab_amt
  18152. // iteminfo.OthAmt = material_other_amt
  18153. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18154. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18155. // }
  18156. //
  18157. // if westernMedicineCostTotal != 0 {
  18158. // iteminfo.MedChrgitm = "09"
  18159. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18160. // iteminfo.Amt = westernMedicineCostTotal
  18161. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18162. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18163. // iteminfo.OthAmt = westernMedicine_other_amt
  18164. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18165. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18166. //
  18167. // }
  18168. // if chineseTraditionalMedicineCostTotal != 0 {
  18169. // iteminfo.MedChrgitm = "11"
  18170. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18171. // iteminfo.Amt = westernMedicineCostTotal
  18172. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18173. // iteminfo.ClabAmt = westernMedicine_clab_amt
  18174. // iteminfo.OthAmt = westernMedicine_other_amt
  18175. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18176. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18177. //
  18178. // }
  18179. // if otherCostTotal != 0 {
  18180. // iteminfo.MedChrgitm = "14"
  18181. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18182. // iteminfo.Amt = otherCostTotal
  18183. // iteminfo.ClaaSumfee = other_claa_sunmfee
  18184. // iteminfo.ClabAmt = other_clab_amt
  18185. // iteminfo.OthAmt = other_other_amt
  18186. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18187. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  18188. //
  18189. // }
  18190. // struct4101.IteminfoStruct = iteminfoStructs
  18191. // struct4101.Ntly = "中国"
  18192. // struct4101.AdmCaty = "A03.06"
  18193. //
  18194. // struct4101.DoctorName = doctor.UserName
  18195. // struct4101.DoctorCode = doctor.DoctorNumber
  18196. //
  18197. // var res ResultSeventeen
  18198. //
  18199. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18200. // struct4101.BillCode = order.Number
  18201. // struct4101.BillNo = order.SetlId
  18202. // var resOther ResultSeventeenOther
  18203. // var pp models.PublicParams
  18204. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18205. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18206. // pp.FixmedinsName = miConfig.OrgName
  18207. // pp.FixmedinsCode = miConfig.Code
  18208. // pp.RequestUrl = miConfig.Url
  18209. // pp.Cainfo = miConfig.Cainfo
  18210. // pp.SecretKey = miConfig.SecretKey
  18211. // pp.AccessKey = miConfig.AccessKey
  18212. // pp.OpterName = curRoles.UserName
  18213. //
  18214. // client := &http.Client{}
  18215. // var req *http.Request
  18216. // data := make(map[string]interface{})
  18217. // data["struct4101"] = struct4101
  18218. // data["pp"] = pp
  18219. // bytesData, _ := json.Marshal(data)
  18220. // if miConfig.MdtrtareaAdmvs == "320921" {
  18221. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18222. // } else {
  18223. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18224. // }
  18225. // resp, _ := client.Do(req)
  18226. // defer resp.Body.Close()
  18227. // body, ioErr := ioutil.ReadAll(resp.Body)
  18228. // if ioErr != nil {
  18229. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18230. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18231. // return
  18232. // }
  18233. // var respJSON map[string]interface{}
  18234. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18235. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18236. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18237. // return
  18238. // }
  18239. //
  18240. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18241. // userJSONBytes, _ := json.Marshal(respJSON)
  18242. // fmt.Println("log")
  18243. // fmt.Println(string(userJSONBytes))
  18244. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18245. // utils.ErrorLog("解析失败:%v", err)
  18246. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18247. // return
  18248. // }
  18249. // res.InfRefmsgid = resOther.InfRefmsgid
  18250. // res.Output = resOther.Output
  18251. // res.ErrMsg = resOther.ErrMsg
  18252. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18253. // res.Infcode = infocode
  18254. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  18255. //
  18256. // var pp models.PublicParams
  18257. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18258. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18259. // pp.FixmedinsName = miConfig.OrgName
  18260. // pp.FixmedinsCode = miConfig.Code
  18261. // pp.RequestUrl = miConfig.Url
  18262. // pp.Cainfo = miConfig.Cainfo
  18263. // pp.SecretKey = miConfig.SecretKey
  18264. // pp.AccessKey = miConfig.AccessKey
  18265. // pp.OpterName = curRoles.UserName
  18266. // result, _ := service.Jxyb4101(struct4101, pp)
  18267. // var dat map[string]interface{}
  18268. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18269. // fmt.Println(dat)
  18270. // } else {
  18271. // fmt.Println(err)
  18272. // }
  18273. // userJSONBytes, _ := json.Marshal(dat)
  18274. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18275. // utils.ErrorLog("解析失败:%v", err)
  18276. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18277. // return
  18278. // }
  18279. //
  18280. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  18281. // var pp models.PublicParams
  18282. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18283. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18284. // pp.FixmedinsName = miConfig.OrgName
  18285. // pp.FixmedinsCode = miConfig.Code
  18286. // pp.RequestUrl = miConfig.Url
  18287. // pp.Cainfo = miConfig.Cainfo
  18288. // pp.SecretKey = miConfig.SecretKey
  18289. // pp.AccessKey = miConfig.AccessKey
  18290. // pp.OpterName = curRoles.UserName
  18291. // result, _ := service.Hnyb4101(struct4101, pp)
  18292. // var dat map[string]interface{}
  18293. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18294. // fmt.Println(dat)
  18295. // } else {
  18296. // fmt.Println(err)
  18297. // }
  18298. // userJSONBytes, _ := json.Marshal(dat)
  18299. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18300. // utils.ErrorLog("解析失败:%v", err)
  18301. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18302. // return
  18303. // }
  18304. //
  18305. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  18306. // var resOther ResultSeventeenOther
  18307. //
  18308. // var pp models.PublicParams
  18309. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18310. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18311. // pp.FixmedinsName = miConfig.OrgName
  18312. // pp.FixmedinsCode = miConfig.Code
  18313. // pp.RequestUrl = miConfig.Url
  18314. // pp.Cainfo = miConfig.Cainfo
  18315. // pp.SecretKey = miConfig.SecretKey
  18316. // pp.AccessKey = miConfig.AccessKey
  18317. // pp.OpterName = curRoles.UserName
  18318. // client := &http.Client{}
  18319. // var req *http.Request
  18320. // data := make(map[string]interface{})
  18321. // data["struct4101"] = struct4101
  18322. // data["pp"] = pp
  18323. // bytesData, _ := json.Marshal(data)
  18324. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18325. // resp, _ := client.Do(req)
  18326. // defer resp.Body.Close()
  18327. // body, ioErr := ioutil.ReadAll(resp.Body)
  18328. // if ioErr != nil {
  18329. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18330. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18331. // return
  18332. // }
  18333. // var respJSON map[string]interface{}
  18334. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18335. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18336. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18337. // return
  18338. // }
  18339. //
  18340. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18341. // userJSONBytes, _ := json.Marshal(respJSON)
  18342. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18343. // utils.ErrorLog("解析失败:%v", err)
  18344. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18345. // return
  18346. // }
  18347. // res.InfRefmsgid = resOther.InfRefmsgid
  18348. // res.Output = resOther.Output
  18349. // res.ErrMsg = resOther.ErrMsg
  18350. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18351. // res.Infcode = infocode
  18352. //
  18353. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  18354. // var pp models.PublicParams
  18355. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18356. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18357. // pp.FixmedinsName = miConfig.OrgName
  18358. // pp.FixmedinsCode = miConfig.Code
  18359. // pp.RequestUrl = miConfig.Url
  18360. // pp.Cainfo = miConfig.Cainfo
  18361. // pp.SecretKey = miConfig.SecretKey
  18362. // pp.AccessKey = miConfig.AccessKey
  18363. // pp.OpterName = curRoles.UserName
  18364. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18365. // fmt.Println(requestLog)
  18366. // fmt.Println(errMsgLog)
  18367. //
  18368. // saveLog(result, requestLog, "4101a", "上传清单")
  18369. //
  18370. // var dat map[string]interface{}
  18371. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18372. // fmt.Println(dat)
  18373. // } else {
  18374. // fmt.Println(err)
  18375. // }
  18376. // userJSONBytes, _ := json.Marshal(dat)
  18377. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18378. // utils.ErrorLog("解析失败:%v", err)
  18379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18380. // return
  18381. // }
  18382. //
  18383. // } else {
  18384. //
  18385. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  18386. // var dat map[string]interface{}
  18387. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18388. // fmt.Println(dat)
  18389. // } else {
  18390. // fmt.Println(err)
  18391. // }
  18392. // userJSONBytes, _ := json.Marshal(dat)
  18393. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18394. // utils.ErrorLog("解析失败:%v", err)
  18395. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18396. // return
  18397. // }
  18398. // }
  18399. //
  18400. // if res.Infcode != 0 {
  18401. // adminUser := c.GetAdminUserInfo()
  18402. // errlog := &models.HisOrderError{
  18403. // UserOrgId: adminUser.CurrentOrgId,
  18404. // Ctime: time.Now().Unix(),
  18405. // Mtime: time.Now().Unix(),
  18406. // ErrMsg: res.ErrMsg,
  18407. // Status: 1,
  18408. // PatientId: order.ID,
  18409. // Stage: 10265,
  18410. // }
  18411. // service.CreateErrMsgLog(errlog)
  18412. // continue
  18413. // } else {
  18414. // //order.FaPiaoNumber = zero
  18415. // //order.FaPiaoCode = last_order.FaPiaoCode
  18416. // //service.UpdateOrder(order)
  18417. // hisFundSettleListResult := &models.HisFundSettleListResult{
  18418. // Number: res.Output.SetlListId,
  18419. // Status: 1,
  18420. // Ctime: time.Now().Unix(),
  18421. // Mtime: time.Now().Unix(),
  18422. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18423. // IsUpload: 1,
  18424. // OrderId: order.ID,
  18425. // }
  18426. // service.CreateUploadRecord(hisFundSettleListResult)
  18427. // c.ServeSuccessJSON(map[string]interface{}{
  18428. // "msg": "上传成功",
  18429. // "result": hisFundSettleListResult,
  18430. // })
  18431. // continue
  18432. // }
  18433. // }
  18434. //}
  18435. func (c *HisApiController) GetbatchSettleList() {
  18436. //order_id, _ := c.GetInt64("order_id")
  18437. admin_user_id, _ := c.GetInt64("admin_user_id")
  18438. orders, _ := service.GetAllHisOrderTwo10485()
  18439. for _, item := range orders {
  18440. order, _ := service.GetHisOrderByIDTwo(item.ID)
  18441. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18442. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18443. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18444. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18445. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18446. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18447. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18448. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18449. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18450. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18451. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18452. //fmt.Println(count)
  18453. //var zero string
  18454. //number := count + 1
  18455. //if number >= 1000 {
  18456. // zero = "0000" + strconv.FormatInt(number, 10)
  18457. //} else if number >= 10000 {
  18458. // zero = "000" + strconv.FormatInt(number, 10)
  18459. //} else if number >= 100000 {
  18460. // zero = "00" + strconv.FormatInt(number, 10)
  18461. //} else if number >= 1000000 {
  18462. // zero = "0" + strconv.FormatInt(number, 10)
  18463. //} else {
  18464. // zero = strconv.FormatInt(number, 10)
  18465. //}
  18466. //fmt.Println(zero)
  18467. struct4101 := service.Struct4101{
  18468. PsnNo: order.PsnNo,
  18469. MdtrtId: order.MdtrtId,
  18470. SetlId: order.SetlId,
  18471. PsnName: order.PsnName,
  18472. Gend: order.Gend,
  18473. Brdy: his.Brdy,
  18474. Age: his.Age,
  18475. Naty: order.Naty,
  18476. PatnCertType: "01",
  18477. Certno: order.Certno,
  18478. Prfs: "90",
  18479. ConerName: roles[0].UserName,
  18480. PatnRlts: "99",
  18481. ConerAddr: miConfig.OrgName,
  18482. ConerTel: admin.Mobile,
  18483. HiType: order.Insutype,
  18484. Insuplc: miConfig.InsuplcAdmdvs,
  18485. MaindiagFlag: "1",
  18486. BillCode: order.SetlId,
  18487. BillNo: order.SetlId,
  18488. BizSn: order.Number,
  18489. PsnSelfPay: order.PsnPartAmt,
  18490. PsnOwnPay: order.PsnPartAmt,
  18491. AcctPay: order.AcctPay,
  18492. PsnCashpay: order.PsnCashPay,
  18493. HiPaymtd: "1",
  18494. Hsorg: miConfig.InsuplcAdmdvs,
  18495. HsorgOpter: miConfig.InsuplcAdmdvs,
  18496. MedinsFillPsn: curRoles.UserName,
  18497. MedinsFillDept: miConfig.OrgName,
  18498. IptMedType: "2",
  18499. }
  18500. struct4101.SetlBegnDate = order.SetlTime
  18501. struct4101.SetlEndDate = order.SetlTime
  18502. time_arr := strings.Split(order.SetlTime, " ")
  18503. struct4101.AdmTime = time_arr[0]
  18504. struct4101.AdmEndTime = time_arr[0]
  18505. //var rf []CustomFundPay
  18506. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  18507. //
  18508. //var tempFunPays []service.CustomStruct
  18509. //for _, item := range rf {
  18510. // var tempFunPay service.CustomStruct
  18511. // tempFunPay.FundPayamt = item.FundPayamt
  18512. // tempFunPay.FundPayType = item.FundPayType
  18513. // tempFunPays = append(tempFunPays, tempFunPay)
  18514. //}
  18515. //struct4101.CustomStruct = tempFunPays
  18516. var tempDiaginfos []service.DiaginfoStructTwo
  18517. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18518. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18519. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18520. var config []*models.HisXtDiagnoseConfig
  18521. for _, item := range diagnosis_ids {
  18522. id, _ := strconv.ParseInt(item, 10, 64)
  18523. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18524. config = append(config, &diagnosisConfig)
  18525. }
  18526. for index, item := range config {
  18527. if index == 0 {
  18528. var tempDiaginfo service.DiaginfoStructTwo
  18529. tempDiaginfo.DiagCode = item.CountryCode
  18530. tempDiaginfo.DiagName = item.CountryContentName
  18531. tempDiaginfo.DiagType = "1"
  18532. tempDiaginfo.MaindiagFlag = "1"
  18533. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18534. } else {
  18535. var tempDiaginfo service.DiaginfoStructTwo
  18536. tempDiaginfo.DiagCode = item.CountryCode
  18537. tempDiaginfo.DiagName = item.CountryContentName
  18538. tempDiaginfo.DiagType = "1"
  18539. tempDiaginfo.MaindiagFlag = "0"
  18540. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18541. }
  18542. }
  18543. struct4101.Diseinfo = tempDiaginfos
  18544. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18545. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18546. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18547. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18548. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18549. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18550. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18551. var iteminfo service.IteminfoStruct
  18552. var bedCostTotal float64 = 0 //床位总费
  18553. var bedCostSelfTotal float64 = 0 //床位自费
  18554. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18555. var operationCostTotal float64 = 0 //手术费
  18556. var operationCostSelfTotal float64 = 0 //手术费
  18557. var operationCostPartSelfTotal float64 = 0 //手术费
  18558. var otherCostTotal float64 = 0 //其他费用
  18559. var otherCostSelfTotal float64 = 0 //其他费用
  18560. var otherCostPartSelfTotal float64 = 0 //其他费用
  18561. var materialCostTotal float64 = 0 //材料费
  18562. var materialCostSelfTotal float64 = 0 //材料费
  18563. var materialCostPartSelfTotal float64 = 0 //材料费
  18564. var westernMedicineCostTotal float64 = 0 //西药费
  18565. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18566. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18567. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18568. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18569. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18570. var checkCostTotal float64 = 0 //检查费
  18571. var checkCostSelfTotal float64 = 0 //检查费
  18572. var checkCostPartSelfTotal float64 = 0 //检查费
  18573. var laboratoryCostTotal float64 = 0 //化验费
  18574. var laboratoryCostSelfTotal float64 = 0 //化验费
  18575. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18576. var treatCostTotal float64 = 0 //治疗费用
  18577. var treatCostSelfTotal float64 = 0 //治疗费用
  18578. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18579. decimal.DivisionPrecision = 2
  18580. var bed_fulamt_ownpay_amt float64 = 0
  18581. var operation_fulamt_ownpay_amt float64 = 0
  18582. var other_fulamt_ownpay_amt float64 = 0
  18583. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18584. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18585. var check_fulamt_ownpay_amt float64 = 0
  18586. var material_fulamt_ownpay_amt float64 = 0
  18587. var laboratory_fulamt_ownpay_amt float64 = 0
  18588. var treat_fulamt_ownpay_amt float64 = 0
  18589. var bed_claa_sunmfee float64 = 0
  18590. var bed_clab_amt float64 = 0
  18591. var bed_other_amt float64 = 0
  18592. var operation_claa_sunmfee float64 = 0
  18593. var operation_clab_amt float64 = 0
  18594. var operation_other_amt float64 = 0
  18595. var other_claa_sunmfee float64 = 0
  18596. var other_clab_amt float64 = 0
  18597. var other_other_amt float64 = 0
  18598. var westernMedicine_claa_sunmfee float64 = 0
  18599. var westernMedicine_clab_amt float64 = 0
  18600. var westernMedicine_other_amt float64 = 0
  18601. var chineseTraditional_claa_sunmfee float64 = 0
  18602. var chineseTraditional_clab_amt float64 = 0
  18603. var chineseTraditional_other_amt float64 = 0
  18604. var check_claa_sunmfee float64 = 0
  18605. var check_clab_amt float64 = 0
  18606. var check_other_amt float64 = 0
  18607. var material_claa_sunmfee float64 = 0
  18608. var material_clab_amt float64 = 0
  18609. var material_other_amt float64 = 0
  18610. var laboratory_claa_sunmfee float64 = 0
  18611. var laboratory_clab_amt float64 = 0
  18612. var laboratory_other_amt float64 = 0
  18613. var treat_claa_sunmfee float64 = 0
  18614. var treat_clab_amt float64 = 0
  18615. var treat_other_amt float64 = 0
  18616. for _, item := range order.HisOrderInfo {
  18617. if item.MedChrgitmType == "01" { //床位费
  18618. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18619. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18620. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18621. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18622. if item.ChrgitmLv == "1" {
  18623. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18624. }
  18625. if item.ChrgitmLv == "2" {
  18626. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18627. }
  18628. if item.ChrgitmLv == "3" {
  18629. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18630. }
  18631. }
  18632. if item.MedChrgitmType == "03" { //检查费
  18633. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18634. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18635. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18636. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18637. if item.ChrgitmLv == "1" {
  18638. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18639. }
  18640. if item.ChrgitmLv == "2" {
  18641. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18642. }
  18643. if item.ChrgitmLv == "3" {
  18644. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18645. }
  18646. }
  18647. if item.MedChrgitmType == "04" { //化验费
  18648. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18649. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18650. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18651. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18652. if item.ChrgitmLv == "1" {
  18653. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18654. }
  18655. if item.ChrgitmLv == "2" {
  18656. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18657. }
  18658. if item.ChrgitmLv == "3" {
  18659. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18660. }
  18661. }
  18662. if item.MedChrgitmType == "05" { //治疗费
  18663. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18664. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18665. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18666. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18667. if item.ChrgitmLv == "1" {
  18668. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18669. }
  18670. if item.ChrgitmLv == "2" {
  18671. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18672. }
  18673. if item.ChrgitmLv == "3" {
  18674. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18675. }
  18676. }
  18677. if item.MedChrgitmType == "06" { //手术费
  18678. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18679. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18680. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18681. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18682. if item.ChrgitmLv == "1" {
  18683. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18684. }
  18685. if item.ChrgitmLv == "2" {
  18686. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18687. }
  18688. if item.ChrgitmLv == "3" {
  18689. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18690. }
  18691. }
  18692. if item.MedChrgitmType == "08" { //材料费
  18693. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18694. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18695. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18696. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18697. if item.ChrgitmLv == "1" {
  18698. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18699. }
  18700. if item.ChrgitmLv == "2" {
  18701. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18702. }
  18703. if item.ChrgitmLv == "3" {
  18704. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18705. }
  18706. }
  18707. if item.MedChrgitmType == "09" { //西药费
  18708. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18709. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18710. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18711. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18712. if item.ChrgitmLv == "1" {
  18713. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18714. }
  18715. if item.ChrgitmLv == "2" {
  18716. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18717. }
  18718. if item.ChrgitmLv == "3" {
  18719. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18720. }
  18721. }
  18722. if item.MedChrgitmType == "11" { //中成费
  18723. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18724. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18725. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18726. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18727. if item.ChrgitmLv == "1" {
  18728. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18729. }
  18730. if item.ChrgitmLv == "2" {
  18731. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18732. }
  18733. if item.ChrgitmLv == "3" {
  18734. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18735. }
  18736. }
  18737. if item.MedChrgitmType == "14" { //其他费
  18738. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18739. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18740. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18741. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18742. if item.ChrgitmLv == "1" {
  18743. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18744. }
  18745. if item.ChrgitmLv == "2" {
  18746. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18747. }
  18748. if item.ChrgitmLv == "3" {
  18749. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18750. }
  18751. }
  18752. }
  18753. var iteminfoStructs []service.IteminfoStruct
  18754. if bedCostTotal != 0 {
  18755. iteminfo.MedChrgitm = "01"
  18756. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18757. iteminfo.Amt = bedCostTotal
  18758. iteminfo.ClaaSumfee = bed_claa_sunmfee
  18759. iteminfo.ClabAmt = bed_clab_amt
  18760. iteminfo.OthAmt = bed_other_amt
  18761. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18762. }
  18763. if checkCostTotal != 0 {
  18764. iteminfo.MedChrgitm = "03"
  18765. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18766. iteminfo.Amt = checkCostTotal
  18767. iteminfo.ClaaSumfee = check_claa_sunmfee
  18768. iteminfo.ClabAmt = check_clab_amt
  18769. iteminfo.OthAmt = check_other_amt
  18770. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18771. }
  18772. if laboratoryCostTotal != 0 {
  18773. iteminfo.MedChrgitm = "04"
  18774. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18775. iteminfo.Amt = laboratoryCostTotal
  18776. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18777. iteminfo.ClabAmt = laboratory_clab_amt
  18778. iteminfo.OthAmt = laboratory_other_amt
  18779. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18780. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18781. }
  18782. if treatCostTotal != 0 {
  18783. iteminfo.MedChrgitm = "05"
  18784. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18785. iteminfo.Amt = treatCostTotal
  18786. iteminfo.ClaaSumfee = treat_claa_sunmfee
  18787. iteminfo.ClabAmt = treat_clab_amt
  18788. iteminfo.OthAmt = treat_other_amt
  18789. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18790. //(struct4101.IteminfoStruct, iteminfo)
  18791. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18792. }
  18793. if operationCostTotal != 0 {
  18794. iteminfo.MedChrgitm = "06"
  18795. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18796. iteminfo.Amt = operationCostTotal
  18797. iteminfo.ClaaSumfee = operation_claa_sunmfee
  18798. iteminfo.ClabAmt = operation_clab_amt
  18799. iteminfo.OthAmt = operation_other_amt
  18800. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18801. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18802. }
  18803. if materialCostTotal != 0 {
  18804. iteminfo.MedChrgitm = "08"
  18805. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18806. iteminfo.Amt = materialCostTotal
  18807. iteminfo.ClaaSumfee = material_claa_sunmfee
  18808. iteminfo.ClabAmt = material_clab_amt
  18809. iteminfo.OthAmt = material_other_amt
  18810. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18811. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18812. }
  18813. if westernMedicineCostTotal != 0 {
  18814. iteminfo.MedChrgitm = "09"
  18815. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18816. iteminfo.Amt = westernMedicineCostTotal
  18817. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18818. iteminfo.ClabAmt = westernMedicine_clab_amt
  18819. iteminfo.OthAmt = westernMedicine_other_amt
  18820. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18821. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18822. }
  18823. if chineseTraditionalMedicineCostTotal != 0 {
  18824. iteminfo.MedChrgitm = "11"
  18825. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18826. iteminfo.Amt = westernMedicineCostTotal
  18827. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18828. iteminfo.ClabAmt = westernMedicine_clab_amt
  18829. iteminfo.OthAmt = westernMedicine_other_amt
  18830. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18831. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18832. }
  18833. if otherCostTotal != 0 {
  18834. iteminfo.MedChrgitm = "14"
  18835. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18836. iteminfo.Amt = otherCostTotal
  18837. iteminfo.ClaaSumfee = other_claa_sunmfee
  18838. iteminfo.ClabAmt = other_clab_amt
  18839. iteminfo.OthAmt = other_other_amt
  18840. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18841. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18842. }
  18843. struct4101.IteminfoStruct = iteminfoStructs
  18844. struct4101.Ntly = "中国"
  18845. struct4101.AdmCaty = "A03.06"
  18846. struct4101.DoctorName = doctor.UserName
  18847. struct4101.DoctorCode = doctor.DoctorNumber
  18848. var res ResultSeventeen
  18849. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18850. struct4101.BillCode = order.Number
  18851. struct4101.BillNo = order.SetlId
  18852. var resOther ResultSeventeenOther
  18853. var pp models.PublicParams
  18854. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18855. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18856. pp.FixmedinsName = miConfig.OrgName
  18857. pp.FixmedinsCode = miConfig.Code
  18858. pp.RequestUrl = miConfig.Url
  18859. pp.Cainfo = miConfig.Cainfo
  18860. pp.SecretKey = miConfig.SecretKey
  18861. pp.AccessKey = miConfig.AccessKey
  18862. pp.OpterName = curRoles.UserName
  18863. client := &http.Client{}
  18864. var req *http.Request
  18865. data := make(map[string]interface{})
  18866. data["struct4101"] = struct4101
  18867. data["pp"] = pp
  18868. bytesData, _ := json.Marshal(data)
  18869. if miConfig.MdtrtareaAdmvs == "320921" {
  18870. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18871. } else {
  18872. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  18873. }
  18874. resp, _ := client.Do(req)
  18875. defer resp.Body.Close()
  18876. body, ioErr := ioutil.ReadAll(resp.Body)
  18877. if ioErr != nil {
  18878. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18880. return
  18881. }
  18882. var respJSON map[string]interface{}
  18883. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18884. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18886. return
  18887. }
  18888. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  18889. userJSONBytes, _ := json.Marshal(respJSON)
  18890. fmt.Println("log")
  18891. fmt.Println(string(userJSONBytes))
  18892. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18893. utils.ErrorLog("解析失败:%v", err)
  18894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18895. return
  18896. }
  18897. res.InfRefmsgid = resOther.InfRefmsgid
  18898. res.Output = resOther.Output
  18899. res.ErrMsg = resOther.ErrMsg
  18900. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18901. res.Infcode = infocode
  18902. } else if miConfig.MdtrtareaAdmvs == "360302" {
  18903. var pp models.PublicParams
  18904. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18905. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18906. pp.FixmedinsName = miConfig.OrgName
  18907. pp.FixmedinsCode = miConfig.Code
  18908. pp.RequestUrl = miConfig.Url
  18909. pp.Cainfo = miConfig.Cainfo
  18910. pp.SecretKey = miConfig.SecretKey
  18911. pp.AccessKey = miConfig.AccessKey
  18912. pp.OpterName = curRoles.UserName
  18913. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18914. result, _ := service.Jxyb4101(struct4101, pp)
  18915. var dat map[string]interface{}
  18916. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18917. fmt.Println(dat)
  18918. } else {
  18919. fmt.Println(err)
  18920. }
  18921. userJSONBytes, _ := json.Marshal(dat)
  18922. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18923. utils.ErrorLog("解析失败:%v", err)
  18924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18925. return
  18926. }
  18927. } else if miConfig.MdtrtareaAdmvs == "361025" {
  18928. var pp models.PublicParams
  18929. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18930. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18931. pp.FixmedinsName = miConfig.OrgName
  18932. pp.FixmedinsCode = miConfig.Code
  18933. pp.RequestUrl = miConfig.Url
  18934. pp.Cainfo = miConfig.Cainfo
  18935. pp.SecretKey = miConfig.SecretKey
  18936. pp.AccessKey = miConfig.AccessKey
  18937. pp.OpterName = curRoles.UserName
  18938. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  18939. result, _ := service.Jxyb4101(struct4101, pp)
  18940. var dat map[string]interface{}
  18941. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18942. fmt.Println(dat)
  18943. } else {
  18944. fmt.Println(err)
  18945. }
  18946. userJSONBytes, _ := json.Marshal(dat)
  18947. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18948. utils.ErrorLog("解析失败:%v", err)
  18949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18950. return
  18951. }
  18952. } else if miConfig.MdtrtareaAdmvs == "430800" {
  18953. var pp models.PublicParams
  18954. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18955. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18956. pp.FixmedinsName = miConfig.OrgName
  18957. pp.FixmedinsCode = miConfig.Code
  18958. pp.RequestUrl = miConfig.Url
  18959. pp.Cainfo = miConfig.Cainfo
  18960. pp.SecretKey = miConfig.SecretKey
  18961. pp.AccessKey = miConfig.AccessKey
  18962. pp.OpterName = curRoles.UserName
  18963. result, _ := service.Hnyb4101(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 == "150499" {
  18977. var resOther ResultSeventeenOther
  18978. var pp models.PublicParams
  18979. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18980. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18981. pp.FixmedinsName = miConfig.OrgName
  18982. pp.FixmedinsCode = miConfig.Code
  18983. pp.RequestUrl = miConfig.Url
  18984. pp.Cainfo = miConfig.Cainfo
  18985. pp.SecretKey = miConfig.SecretKey
  18986. pp.AccessKey = miConfig.AccessKey
  18987. pp.OpterName = curRoles.UserName
  18988. client := &http.Client{}
  18989. var req *http.Request
  18990. data := make(map[string]interface{})
  18991. data["struct4101"] = struct4101
  18992. data["pp"] = pp
  18993. bytesData, _ := json.Marshal(data)
  18994. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18995. resp, _ := client.Do(req)
  18996. defer resp.Body.Close()
  18997. body, ioErr := ioutil.ReadAll(resp.Body)
  18998. if ioErr != nil {
  18999. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19001. return
  19002. }
  19003. var respJSON map[string]interface{}
  19004. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19005. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19007. return
  19008. }
  19009. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19010. userJSONBytes, _ := json.Marshal(respJSON)
  19011. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19012. utils.ErrorLog("解析失败:%v", err)
  19013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19014. return
  19015. }
  19016. res.InfRefmsgid = resOther.InfRefmsgid
  19017. res.Output = resOther.Output
  19018. res.ErrMsg = resOther.ErrMsg
  19019. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19020. res.Infcode = infocode
  19021. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19022. var pp models.PublicParams
  19023. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19024. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19025. pp.FixmedinsName = miConfig.OrgName
  19026. pp.FixmedinsCode = miConfig.Code
  19027. pp.RequestUrl = miConfig.Url
  19028. pp.Cainfo = miConfig.Cainfo
  19029. pp.SecretKey = miConfig.SecretKey
  19030. pp.AccessKey = miConfig.AccessKey
  19031. pp.OpterName = curRoles.UserName
  19032. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19033. fmt.Println(requestLog)
  19034. fmt.Println(errMsgLog)
  19035. saveLog(result, requestLog, "4101a", "上传清单")
  19036. var dat map[string]interface{}
  19037. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19038. fmt.Println(dat)
  19039. } else {
  19040. fmt.Println(err)
  19041. }
  19042. userJSONBytes, _ := json.Marshal(dat)
  19043. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19044. utils.ErrorLog("解析失败:%v", err)
  19045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19046. return
  19047. }
  19048. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19049. var pp models.PublicParams
  19050. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19051. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19052. pp.FixmedinsName = miConfig.OrgName
  19053. pp.FixmedinsCode = miConfig.Code
  19054. pp.RequestUrl = miConfig.Url
  19055. pp.Cainfo = miConfig.Cainfo
  19056. pp.SecretKey = miConfig.SecretKey
  19057. pp.AccessKey = miConfig.AccessKey
  19058. pp.OpterName = curRoles.UserName
  19059. client := &http.Client{}
  19060. var req *http.Request
  19061. data := make(map[string]interface{})
  19062. data["struct4101"] = struct4101
  19063. data["pp"] = pp
  19064. bytesData, _ := json.Marshal(data)
  19065. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  19066. resp, _ := client.Do(req)
  19067. defer resp.Body.Close()
  19068. body, ioErr := ioutil.ReadAll(resp.Body)
  19069. if ioErr != nil {
  19070. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19072. return
  19073. }
  19074. var respJSON map[string]interface{}
  19075. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19076. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19078. return
  19079. }
  19080. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19081. userJSONBytes, _ := json.Marshal(respJSON)
  19082. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19083. utils.ErrorLog("解析失败:%v", err)
  19084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19085. return
  19086. }
  19087. } else {
  19088. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19089. var dat map[string]interface{}
  19090. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19091. fmt.Println(dat)
  19092. } else {
  19093. fmt.Println(err)
  19094. }
  19095. userJSONBytes, _ := json.Marshal(dat)
  19096. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19097. utils.ErrorLog("解析失败:%v", err)
  19098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19099. return
  19100. }
  19101. }
  19102. if res.Infcode != 0 {
  19103. errlog := &models.HisOrderError{
  19104. UserOrgId: order.UserOrgId,
  19105. Ctime: time.Now().Unix(),
  19106. Mtime: time.Now().Unix(),
  19107. ErrMsg: res.ErrMsg + "解析失败",
  19108. Status: 1,
  19109. PatientId: order.ID,
  19110. Stage: 10485,
  19111. }
  19112. service.CreateErrMsgLog(errlog)
  19113. continue
  19114. //c.ServeSuccessJSON(map[string]interface{}{
  19115. // "failed_code": -10,
  19116. // "msg": res.ErrMsg,
  19117. //})
  19118. } else {
  19119. //order.FaPiaoNumber = zero
  19120. //order.FaPiaoCode = last_order.FaPiaoCode
  19121. //service.UpdateOrder(order)
  19122. hisFundSettleListResult := &models.HisFundSettleListResult{
  19123. Number: res.Output.SetlListId,
  19124. Status: 1,
  19125. Ctime: time.Now().Unix(),
  19126. Mtime: time.Now().Unix(),
  19127. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19128. IsUpload: 1,
  19129. OrderId: order.ID,
  19130. }
  19131. service.CreateUploadRecord(hisFundSettleListResult)
  19132. continue
  19133. }
  19134. }
  19135. }
  19136. func (c *HisApiController) GetSettleList() {
  19137. order_id, _ := c.GetInt64("order_id")
  19138. admin_user_id, _ := c.GetInt64("admin_user_id")
  19139. order, _ := service.GetHisOrderByIDTwo(order_id)
  19140. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19141. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19142. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19143. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19144. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19145. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19146. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19147. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19148. if order.ID == 0 {
  19149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19150. return
  19151. }
  19152. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19153. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19154. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19155. //fmt.Println(count)
  19156. //var zero string
  19157. //number := count + 1
  19158. //if number >= 1000 {
  19159. // zero = "0000" + strconv.FormatInt(number, 10)
  19160. //} else if number >= 10000 {
  19161. // zero = "000" + strconv.FormatInt(number, 10)
  19162. //} else if number >= 100000 {
  19163. // zero = "00" + strconv.FormatInt(number, 10)
  19164. //} else if number >= 1000000 {
  19165. // zero = "0" + strconv.FormatInt(number, 10)
  19166. //} else {
  19167. // zero = strconv.FormatInt(number, 10)
  19168. //}
  19169. //fmt.Println(zero)
  19170. struct4101 := service.Struct4101{
  19171. PsnNo: order.PsnNo,
  19172. MdtrtId: order.MdtrtId,
  19173. SetlId: order.SetlId,
  19174. PsnName: order.PsnName,
  19175. Gend: order.Gend,
  19176. Brdy: his.Brdy,
  19177. Age: his.Age,
  19178. Naty: order.Naty,
  19179. PatnCertType: "01",
  19180. Certno: order.Certno,
  19181. Prfs: "90",
  19182. ConerName: roles[0].UserName,
  19183. PatnRlts: "99",
  19184. ConerAddr: miConfig.OrgName,
  19185. ConerTel: admin.Mobile,
  19186. HiType: order.Insutype,
  19187. Insuplc: miConfig.InsuplcAdmdvs,
  19188. MaindiagFlag: "1",
  19189. BillCode: order.SetlId,
  19190. BillNo: order.SetlId,
  19191. BizSn: order.Number,
  19192. PsnSelfPay: order.PsnPartAmt,
  19193. PsnOwnPay: order.PsnPartAmt,
  19194. AcctPay: order.AcctPay,
  19195. PsnCashpay: order.PsnCashPay,
  19196. HiPaymtd: "1",
  19197. Hsorg: miConfig.InsuplcAdmdvs,
  19198. HsorgOpter: miConfig.InsuplcAdmdvs,
  19199. MedinsFillPsn: curRoles.UserName,
  19200. MedinsFillDept: miConfig.OrgName,
  19201. IptMedType: "2",
  19202. }
  19203. struct4101.SetlBegnDate = order.SetlTime
  19204. struct4101.SetlEndDate = order.SetlTime
  19205. time_arr := strings.Split(order.SetlTime, " ")
  19206. struct4101.AdmTime = time_arr[0]
  19207. struct4101.AdmEndTime = time_arr[0]
  19208. //
  19209. //var rf []CustomFundPay
  19210. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19211. //
  19212. //var tempFunPays []service.CustomStruct
  19213. //for _, item := range rf {
  19214. // var tempFunPay service.CustomStruct
  19215. // tempFunPay.FundPayamt = item.FundPayamt
  19216. // tempFunPay.FundPayType = item.FundPayType
  19217. // tempFunPays = append(tempFunPays, tempFunPay)
  19218. //}
  19219. //struct4101.CustomStruct = tempFunPays
  19220. var tempDiaginfos []service.DiaginfoStructTwo
  19221. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19222. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19223. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  19224. var config []*models.HisXtDiagnoseConfig
  19225. for _, item := range diagnosis_ids {
  19226. id, _ := strconv.ParseInt(item, 10, 64)
  19227. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19228. config = append(config, &diagnosisConfig)
  19229. }
  19230. if miConfig.Code == "H15049901371" {
  19231. //for _, item := range config {
  19232. // if item.ID == 138 {
  19233. diagnosisConfig, _ := service.FindDiagnoseById(138)
  19234. var tempDiaginfo service.DiaginfoStructTwo
  19235. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  19236. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  19237. tempDiaginfo.DiagType = "1"
  19238. tempDiaginfo.MaindiagFlag = "1"
  19239. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19240. //}
  19241. //}
  19242. for _, item := range config {
  19243. if item.ID != 138 {
  19244. var tempDiaginfo service.DiaginfoStructTwo
  19245. tempDiaginfo.DiagCode = item.CountryCode
  19246. tempDiaginfo.DiagName = item.CountryContentName
  19247. tempDiaginfo.DiagType = "1"
  19248. tempDiaginfo.MaindiagFlag = "0"
  19249. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19250. }
  19251. }
  19252. } else {
  19253. for index, item := range config {
  19254. if index == 0 {
  19255. var tempDiaginfo service.DiaginfoStructTwo
  19256. tempDiaginfo.DiagCode = item.CountryCode
  19257. tempDiaginfo.DiagName = item.CountryContentName
  19258. tempDiaginfo.DiagType = "1"
  19259. tempDiaginfo.MaindiagFlag = "1"
  19260. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19261. } else {
  19262. var tempDiaginfo service.DiaginfoStructTwo
  19263. tempDiaginfo.DiagCode = item.CountryCode
  19264. tempDiaginfo.DiagName = item.CountryContentName
  19265. tempDiaginfo.DiagType = "1"
  19266. tempDiaginfo.MaindiagFlag = "0"
  19267. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19268. }
  19269. }
  19270. }
  19271. struct4101.Diseinfo = tempDiaginfos
  19272. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19273. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19274. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19275. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19276. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19277. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19278. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19279. var iteminfo service.IteminfoStruct
  19280. var bedCostTotal float64 = 0 //床位总费
  19281. var bedCostSelfTotal float64 = 0 //床位自费
  19282. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19283. var operationCostTotal float64 = 0 //手术费
  19284. var operationCostSelfTotal float64 = 0 //手术费
  19285. var operationCostPartSelfTotal float64 = 0 //手术费
  19286. var otherCostTotal float64 = 0 //其他费用
  19287. var otherCostSelfTotal float64 = 0 //其他费用
  19288. var otherCostPartSelfTotal float64 = 0 //其他费用
  19289. var materialCostTotal float64 = 0 //材料费
  19290. var materialCostSelfTotal float64 = 0 //材料费
  19291. var materialCostPartSelfTotal float64 = 0 //材料费
  19292. var westernMedicineCostTotal float64 = 0 //西药费
  19293. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19294. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19295. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19296. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19297. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19298. var checkCostTotal float64 = 0 //检查费
  19299. var checkCostSelfTotal float64 = 0 //检查费
  19300. var checkCostPartSelfTotal float64 = 0 //检查费
  19301. var laboratoryCostTotal float64 = 0 //化验费
  19302. var laboratoryCostSelfTotal float64 = 0 //化验费
  19303. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19304. var treatCostTotal float64 = 0 //治疗费用
  19305. var treatCostSelfTotal float64 = 0 //治疗费用
  19306. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19307. decimal.DivisionPrecision = 2
  19308. var bed_fulamt_ownpay_amt float64 = 0
  19309. var operation_fulamt_ownpay_amt float64 = 0
  19310. var other_fulamt_ownpay_amt float64 = 0
  19311. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19312. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19313. var check_fulamt_ownpay_amt float64 = 0
  19314. var material_fulamt_ownpay_amt float64 = 0
  19315. var laboratory_fulamt_ownpay_amt float64 = 0
  19316. var treat_fulamt_ownpay_amt float64 = 0
  19317. var bed_claa_sunmfee float64 = 0
  19318. var bed_clab_amt float64 = 0
  19319. var bed_other_amt float64 = 0
  19320. var operation_claa_sunmfee float64 = 0
  19321. var operation_clab_amt float64 = 0
  19322. var operation_other_amt float64 = 0
  19323. var other_claa_sunmfee float64 = 0
  19324. var other_clab_amt float64 = 0
  19325. var other_other_amt float64 = 0
  19326. var westernMedicine_claa_sunmfee float64 = 0
  19327. var westernMedicine_clab_amt float64 = 0
  19328. var westernMedicine_other_amt float64 = 0
  19329. var chineseTraditional_claa_sunmfee float64 = 0
  19330. var chineseTraditional_clab_amt float64 = 0
  19331. var chineseTraditional_other_amt float64 = 0
  19332. var check_claa_sunmfee float64 = 0
  19333. var check_clab_amt float64 = 0
  19334. var check_other_amt float64 = 0
  19335. var material_claa_sunmfee float64 = 0
  19336. var material_clab_amt float64 = 0
  19337. var material_other_amt float64 = 0
  19338. var laboratory_claa_sunmfee float64 = 0
  19339. var laboratory_clab_amt float64 = 0
  19340. var laboratory_other_amt float64 = 0
  19341. var treat_claa_sunmfee float64 = 0
  19342. var treat_clab_amt float64 = 0
  19343. var treat_other_amt float64 = 0
  19344. for _, item := range order.HisOrderInfo {
  19345. if item.MedChrgitmType == "01" { //床位费
  19346. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19347. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19348. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19349. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19350. if item.ChrgitmLv == "1" {
  19351. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19352. }
  19353. if item.ChrgitmLv == "2" {
  19354. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19355. }
  19356. if item.ChrgitmLv == "3" {
  19357. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19358. }
  19359. }
  19360. if item.MedChrgitmType == "03" { //检查费
  19361. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19362. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19363. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19364. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19365. if item.ChrgitmLv == "1" {
  19366. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19367. }
  19368. if item.ChrgitmLv == "2" {
  19369. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19370. }
  19371. if item.ChrgitmLv == "3" {
  19372. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19373. }
  19374. }
  19375. if item.MedChrgitmType == "04" { //化验费
  19376. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19377. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19378. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19379. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19380. if item.ChrgitmLv == "1" {
  19381. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19382. }
  19383. if item.ChrgitmLv == "2" {
  19384. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19385. }
  19386. if item.ChrgitmLv == "3" {
  19387. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19388. }
  19389. }
  19390. if item.MedChrgitmType == "05" { //治疗费
  19391. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19392. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19393. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19394. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19395. if item.ChrgitmLv == "1" {
  19396. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19397. }
  19398. if item.ChrgitmLv == "2" {
  19399. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19400. }
  19401. if item.ChrgitmLv == "3" {
  19402. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19403. }
  19404. }
  19405. if item.MedChrgitmType == "06" { //手术费
  19406. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19407. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19408. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19409. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19410. if item.ChrgitmLv == "1" {
  19411. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19412. }
  19413. if item.ChrgitmLv == "2" {
  19414. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19415. }
  19416. if item.ChrgitmLv == "3" {
  19417. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19418. }
  19419. }
  19420. if item.MedChrgitmType == "08" { //材料费
  19421. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19422. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19423. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19424. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19425. if item.ChrgitmLv == "1" {
  19426. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19427. }
  19428. if item.ChrgitmLv == "2" {
  19429. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19430. }
  19431. if item.ChrgitmLv == "3" {
  19432. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19433. }
  19434. }
  19435. if item.MedChrgitmType == "09" { //西药费
  19436. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19437. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19438. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19439. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19440. if item.ChrgitmLv == "1" {
  19441. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19442. }
  19443. if item.ChrgitmLv == "2" {
  19444. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19445. }
  19446. if item.ChrgitmLv == "3" {
  19447. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19448. }
  19449. }
  19450. if item.MedChrgitmType == "11" { //中成费
  19451. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19452. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19453. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19454. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19455. if item.ChrgitmLv == "1" {
  19456. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19457. }
  19458. if item.ChrgitmLv == "2" {
  19459. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19460. }
  19461. if item.ChrgitmLv == "3" {
  19462. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19463. }
  19464. }
  19465. if item.MedChrgitmType == "14" { //其他费
  19466. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19467. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19468. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19469. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19470. if item.ChrgitmLv == "1" {
  19471. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19472. }
  19473. if item.ChrgitmLv == "2" {
  19474. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19475. }
  19476. if item.ChrgitmLv == "3" {
  19477. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19478. }
  19479. }
  19480. }
  19481. var iteminfoStructs []service.IteminfoStruct
  19482. if bedCostTotal != 0 {
  19483. iteminfo.MedChrgitm = "01"
  19484. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19485. iteminfo.Amt = bedCostTotal
  19486. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19487. iteminfo.ClabAmt = bed_clab_amt
  19488. iteminfo.OthAmt = bed_other_amt
  19489. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19490. }
  19491. if checkCostTotal != 0 {
  19492. iteminfo.MedChrgitm = "03"
  19493. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19494. iteminfo.Amt = checkCostTotal
  19495. iteminfo.ClaaSumfee = check_claa_sunmfee
  19496. iteminfo.ClabAmt = check_clab_amt
  19497. iteminfo.OthAmt = check_other_amt
  19498. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19499. }
  19500. if laboratoryCostTotal != 0 {
  19501. iteminfo.MedChrgitm = "04"
  19502. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19503. iteminfo.Amt = laboratoryCostTotal
  19504. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19505. iteminfo.ClabAmt = laboratory_clab_amt
  19506. iteminfo.OthAmt = laboratory_other_amt
  19507. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19508. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19509. }
  19510. if treatCostTotal != 0 {
  19511. iteminfo.MedChrgitm = "05"
  19512. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19513. iteminfo.Amt = treatCostTotal
  19514. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19515. iteminfo.ClabAmt = treat_clab_amt
  19516. iteminfo.OthAmt = treat_other_amt
  19517. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19518. //(struct4101.IteminfoStruct, iteminfo)
  19519. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19520. }
  19521. if operationCostTotal != 0 {
  19522. iteminfo.MedChrgitm = "06"
  19523. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19524. iteminfo.Amt = operationCostTotal
  19525. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19526. iteminfo.ClabAmt = operation_clab_amt
  19527. iteminfo.OthAmt = operation_other_amt
  19528. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19529. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19530. }
  19531. if materialCostTotal != 0 {
  19532. iteminfo.MedChrgitm = "08"
  19533. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19534. iteminfo.Amt = materialCostTotal
  19535. iteminfo.ClaaSumfee = material_claa_sunmfee
  19536. iteminfo.ClabAmt = material_clab_amt
  19537. iteminfo.OthAmt = material_other_amt
  19538. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19539. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19540. }
  19541. if westernMedicineCostTotal != 0 {
  19542. iteminfo.MedChrgitm = "09"
  19543. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19544. iteminfo.Amt = westernMedicineCostTotal
  19545. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19546. iteminfo.ClabAmt = westernMedicine_clab_amt
  19547. iteminfo.OthAmt = westernMedicine_other_amt
  19548. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19549. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19550. }
  19551. if chineseTraditionalMedicineCostTotal != 0 {
  19552. iteminfo.MedChrgitm = "11"
  19553. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19554. iteminfo.Amt = westernMedicineCostTotal
  19555. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19556. iteminfo.ClabAmt = westernMedicine_clab_amt
  19557. iteminfo.OthAmt = westernMedicine_other_amt
  19558. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19559. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19560. }
  19561. if otherCostTotal != 0 {
  19562. iteminfo.MedChrgitm = "14"
  19563. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19564. iteminfo.Amt = otherCostTotal
  19565. iteminfo.ClaaSumfee = other_claa_sunmfee
  19566. iteminfo.ClabAmt = other_clab_amt
  19567. iteminfo.OthAmt = other_other_amt
  19568. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19569. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19570. }
  19571. struct4101.IteminfoStruct = iteminfoStructs
  19572. struct4101.Ntly = "中国"
  19573. struct4101.AdmCaty = "A03.06"
  19574. struct4101.DoctorName = doctor.UserName
  19575. struct4101.DoctorCode = doctor.DoctorNumber
  19576. var res ResultSeventeen
  19577. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19578. struct4101.BillCode = order.Number
  19579. struct4101.BillNo = order.SetlId
  19580. var resOther ResultSeventeenOther
  19581. var pp models.PublicParams
  19582. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19583. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19584. pp.FixmedinsName = miConfig.OrgName
  19585. pp.FixmedinsCode = miConfig.Code
  19586. pp.RequestUrl = miConfig.Url
  19587. pp.Cainfo = miConfig.Cainfo
  19588. pp.SecretKey = miConfig.SecretKey
  19589. pp.AccessKey = miConfig.AccessKey
  19590. pp.OpterName = curRoles.UserName
  19591. client := &http.Client{}
  19592. var req *http.Request
  19593. data := make(map[string]interface{})
  19594. data["struct4101"] = struct4101
  19595. data["pp"] = pp
  19596. bytesData, _ := json.Marshal(data)
  19597. if miConfig.MdtrtareaAdmvs == "320921" {
  19598. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19599. } else {
  19600. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19601. }
  19602. resp, _ := client.Do(req)
  19603. defer resp.Body.Close()
  19604. body, ioErr := ioutil.ReadAll(resp.Body)
  19605. if ioErr != nil {
  19606. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19608. return
  19609. }
  19610. var respJSON map[string]interface{}
  19611. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19612. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19614. return
  19615. }
  19616. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19617. userJSONBytes, _ := json.Marshal(respJSON)
  19618. fmt.Println("log")
  19619. fmt.Println(string(userJSONBytes))
  19620. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19621. utils.ErrorLog("解析失败:%v", err)
  19622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19623. return
  19624. }
  19625. res.InfRefmsgid = resOther.InfRefmsgid
  19626. res.Output = resOther.Output
  19627. res.ErrMsg = resOther.ErrMsg
  19628. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19629. res.Infcode = infocode
  19630. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19631. var pp models.PublicParams
  19632. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19633. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19634. pp.FixmedinsName = miConfig.OrgName
  19635. pp.FixmedinsCode = miConfig.Code
  19636. pp.RequestUrl = miConfig.Url
  19637. pp.Cainfo = miConfig.Cainfo
  19638. pp.SecretKey = miConfig.SecretKey
  19639. pp.AccessKey = miConfig.AccessKey
  19640. pp.OpterName = curRoles.UserName
  19641. result, _ := service.Jxyb4101(struct4101, pp)
  19642. var dat map[string]interface{}
  19643. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19644. fmt.Println(dat)
  19645. } else {
  19646. fmt.Println(err)
  19647. }
  19648. userJSONBytes, _ := json.Marshal(dat)
  19649. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19650. utils.ErrorLog("解析失败:%v", err)
  19651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19652. return
  19653. }
  19654. } else if miConfig.MdtrtareaAdmvs == "361025" {
  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 == "430800" {
  19679. var pp models.PublicParams
  19680. pp.InsuplcAdmdvs = miConfig.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.Hnyb4101(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 == "150499" {
  19703. var resOther ResultSeventeenOther
  19704. var pp models.PublicParams
  19705. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19706. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19707. pp.FixmedinsName = miConfig.OrgName
  19708. pp.FixmedinsCode = miConfig.Code
  19709. pp.RequestUrl = miConfig.Url
  19710. pp.Cainfo = miConfig.Cainfo
  19711. pp.SecretKey = miConfig.SecretKey
  19712. pp.AccessKey = miConfig.AccessKey
  19713. pp.OpterName = curRoles.UserName
  19714. client := &http.Client{}
  19715. var req *http.Request
  19716. data := make(map[string]interface{})
  19717. data["struct4101"] = struct4101
  19718. data["pp"] = pp
  19719. bytesData, _ := json.Marshal(data)
  19720. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19721. resp, _ := client.Do(req)
  19722. defer resp.Body.Close()
  19723. body, ioErr := ioutil.ReadAll(resp.Body)
  19724. if ioErr != nil {
  19725. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19727. return
  19728. }
  19729. var respJSON map[string]interface{}
  19730. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19731. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19733. return
  19734. }
  19735. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19736. userJSONBytes, _ := json.Marshal(respJSON)
  19737. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19738. utils.ErrorLog("解析失败:%v", err)
  19739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19740. return
  19741. }
  19742. res.InfRefmsgid = resOther.InfRefmsgid
  19743. res.Output = resOther.Output
  19744. res.ErrMsg = resOther.ErrMsg
  19745. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19746. res.Infcode = infocode
  19747. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19748. var pp models.PublicParams
  19749. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19750. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19751. pp.FixmedinsName = miConfig.OrgName
  19752. pp.FixmedinsCode = miConfig.Code
  19753. pp.RequestUrl = miConfig.Url
  19754. pp.Cainfo = miConfig.Cainfo
  19755. pp.SecretKey = miConfig.SecretKey
  19756. pp.AccessKey = miConfig.AccessKey
  19757. pp.OpterName = curRoles.UserName
  19758. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19759. fmt.Println(requestLog)
  19760. fmt.Println(errMsgLog)
  19761. saveLog(result, requestLog, "4101a", "上传清单")
  19762. var dat map[string]interface{}
  19763. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19764. fmt.Println(dat)
  19765. } else {
  19766. fmt.Println(err)
  19767. }
  19768. userJSONBytes, _ := json.Marshal(dat)
  19769. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19770. utils.ErrorLog("解析失败:%v", err)
  19771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19772. return
  19773. }
  19774. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19775. var pp models.PublicParams
  19776. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19777. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19778. pp.FixmedinsName = miConfig.OrgName
  19779. pp.FixmedinsCode = miConfig.Code
  19780. pp.RequestUrl = miConfig.Url
  19781. pp.Cainfo = miConfig.Cainfo
  19782. pp.SecretKey = miConfig.SecretKey
  19783. pp.AccessKey = miConfig.AccessKey
  19784. pp.OpterName = curRoles.UserName
  19785. client := &http.Client{}
  19786. var req *http.Request
  19787. data := make(map[string]interface{})
  19788. data["struct4101"] = struct4101
  19789. data["pp"] = pp
  19790. bytesData, _ := json.Marshal(data)
  19791. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  19792. resp, _ := client.Do(req)
  19793. defer resp.Body.Close()
  19794. body, ioErr := ioutil.ReadAll(resp.Body)
  19795. if ioErr != nil {
  19796. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19798. return
  19799. }
  19800. var respJSON map[string]interface{}
  19801. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19802. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19804. return
  19805. }
  19806. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19807. userJSONBytes, _ := json.Marshal(respJSON)
  19808. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19809. utils.ErrorLog("解析失败:%v", err)
  19810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19811. return
  19812. }
  19813. } else {
  19814. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  19815. var dat map[string]interface{}
  19816. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19817. fmt.Println(dat)
  19818. } else {
  19819. fmt.Println(err)
  19820. }
  19821. userJSONBytes, _ := json.Marshal(dat)
  19822. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19823. utils.ErrorLog("解析失败:%v", err)
  19824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19825. return
  19826. }
  19827. }
  19828. if res.Infcode != 0 {
  19829. c.ServeSuccessJSON(map[string]interface{}{
  19830. "failed_code": -10,
  19831. "msg": res.ErrMsg,
  19832. })
  19833. return
  19834. } else {
  19835. //order.FaPiaoNumber = zero
  19836. //order.FaPiaoCode = last_order.FaPiaoCode
  19837. //service.UpdateOrder(order)
  19838. hisFundSettleListResult := &models.HisFundSettleListResult{
  19839. Number: res.Output.SetlListId,
  19840. Status: 1,
  19841. Ctime: time.Now().Unix(),
  19842. Mtime: time.Now().Unix(),
  19843. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19844. IsUpload: 1,
  19845. OrderId: order_id,
  19846. }
  19847. service.CreateUploadRecord(hisFundSettleListResult)
  19848. c.ServeSuccessJSON(map[string]interface{}{
  19849. "msg": "上传成功",
  19850. "result": hisFundSettleListResult,
  19851. })
  19852. return
  19853. }
  19854. }
  19855. func (c *HisApiController) GetSettleListHospital() {
  19856. order_id, _ := c.GetInt64("order_id")
  19857. admin_user_id, _ := c.GetInt64("admin_user_id")
  19858. order, _ := service.GetHisOrderByIDTwo(order_id)
  19859. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19860. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  19861. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19862. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19863. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19864. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19865. if order.ID == 0 {
  19866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  19867. return
  19868. }
  19869. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19870. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19871. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19872. fmt.Println(count)
  19873. var zero string
  19874. number := count + 1
  19875. if number >= 1000 {
  19876. zero = "0000" + strconv.FormatInt(number, 10)
  19877. } else if number >= 10000 {
  19878. zero = "000" + strconv.FormatInt(number, 10)
  19879. } else if number >= 100000 {
  19880. zero = "00" + strconv.FormatInt(number, 10)
  19881. } else if number >= 1000000 {
  19882. zero = "0" + strconv.FormatInt(number, 10)
  19883. } else {
  19884. zero = strconv.FormatInt(number, 10)
  19885. }
  19886. fmt.Println(zero)
  19887. struct4101 := service.Struct4101{
  19888. PsnNo: order.PsnNo,
  19889. MdtrtId: order.MdtrtId,
  19890. SetlId: order.SetlId,
  19891. PsnName: order.PsnName,
  19892. Gend: order.Gend,
  19893. Brdy: his.Brdy,
  19894. Age: int64(order.Age),
  19895. Naty: order.Naty,
  19896. PatnCertType: "01",
  19897. Certno: order.Certno,
  19898. Prfs: "90",
  19899. ConerName: roles[0].UserName,
  19900. PatnRlts: "99",
  19901. ConerAddr: miConfig.OrgName,
  19902. ConerTel: admin.Mobile,
  19903. HiType: order.Insutype,
  19904. Insuplc: miConfig.InsuplcAdmdvs,
  19905. MaindiagFlag: "1",
  19906. BillCode: order.SetlId,
  19907. BillNo: order.SetlId,
  19908. BizSn: order.Number,
  19909. PsnSelfPay: order.PsnPartAmt,
  19910. PsnOwnPay: order.PsnPartAmt,
  19911. AcctPay: order.AcctPay,
  19912. PsnCashpay: order.PsnCashPay,
  19913. HiPaymtd: "1",
  19914. Hsorg: miConfig.InsuplcAdmdvs,
  19915. HsorgOpter: miConfig.InsuplcAdmdvs,
  19916. MedinsFillPsn: curRoles.UserName,
  19917. MedinsFillDept: depart.Name,
  19918. IptMedType: "2",
  19919. AdmTime: his.InHosptialTime,
  19920. AdmEndTime: his.OutHosptialTime,
  19921. }
  19922. struct4101.SetlBegnDate = order.SetlTime
  19923. struct4101.SetlEndDate = order.SetlTime
  19924. //var rf []CustomFundPay
  19925. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19926. //
  19927. //var tempFunPays []service.CustomStruct
  19928. //for _, item := range rf {
  19929. // var tempFunPay service.CustomStruct
  19930. // tempFunPay.FundPayamt = item.FundPayamt
  19931. // tempFunPay.FundPayType = item.FundPayType
  19932. // tempFunPays = append(tempFunPays, tempFunPay)
  19933. //}
  19934. //struct4101.CustomStruct = tempFunPays
  19935. var tempDiaginfos []service.DiaginfoStructTwo
  19936. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19937. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19938. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  19939. //for _, item := range infos {
  19940. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  19941. //}
  19942. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  19943. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  19944. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19945. fmt.Println(diagnosis_ids_arr)
  19946. if order.UserOrgId == 10210 {
  19947. var diagnosis_ids_arr_two []int64
  19948. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  19949. var config []*models.HisXtDiagnoseConfig
  19950. for _, id := range diagnosis_ids_arr_two {
  19951. //id, _ := strconv.ParseInt(item, 10, 64)
  19952. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19953. if diagnosisConfig.ID > 0 {
  19954. config = append(config, &diagnosisConfig)
  19955. }
  19956. }
  19957. for index, item := range config {
  19958. if item.ID > 0 {
  19959. if index == 0 {
  19960. var tempDiaginfo service.DiaginfoStructTwo
  19961. tempDiaginfo.DiagCode = item.CountryCode
  19962. tempDiaginfo.DiagName = item.CountryContentName
  19963. tempDiaginfo.DiagType = "1"
  19964. tempDiaginfo.MaindiagFlag = "1"
  19965. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19966. } else {
  19967. var tempDiaginfo service.DiaginfoStructTwo
  19968. tempDiaginfo.DiagCode = item.CountryCode
  19969. tempDiaginfo.DiagName = item.CountryContentName
  19970. tempDiaginfo.DiagType = "1"
  19971. tempDiaginfo.MaindiagFlag = "0"
  19972. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19973. }
  19974. }
  19975. }
  19976. struct4101.Diseinfo = tempDiaginfos
  19977. } else {
  19978. var config []*models.HisXtDiagnoseConfig
  19979. for _, item := range diagnosis_ids_arr {
  19980. id, _ := strconv.ParseInt(item, 10, 64)
  19981. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19982. if diagnosisConfig.ID > 0 {
  19983. config = append(config, &diagnosisConfig)
  19984. }
  19985. }
  19986. for index, item := range config {
  19987. if item.ID > 0 {
  19988. if index == 0 {
  19989. var tempDiaginfo service.DiaginfoStructTwo
  19990. tempDiaginfo.DiagCode = item.CountryCode
  19991. tempDiaginfo.DiagName = item.CountryContentName
  19992. tempDiaginfo.DiagType = "1"
  19993. tempDiaginfo.MaindiagFlag = "1"
  19994. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19995. } else {
  19996. var tempDiaginfo service.DiaginfoStructTwo
  19997. tempDiaginfo.DiagCode = item.CountryCode
  19998. tempDiaginfo.DiagName = item.CountryContentName
  19999. tempDiaginfo.DiagType = "1"
  20000. tempDiaginfo.MaindiagFlag = "0"
  20001. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20002. }
  20003. }
  20004. }
  20005. struct4101.Diseinfo = tempDiaginfos
  20006. }
  20007. sickConfigTwo, _ := service.FindSickById(his.SickType)
  20008. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20009. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20010. tempOpspdiseinfo2.OprnOprtCode = ""
  20011. tempOpspdiseinfo2.OprnOprtName = ""
  20012. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20013. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20014. var iteminfo service.IteminfoStruct
  20015. var bedCostTotal float64 = 0 //床位总费
  20016. var bedCostSelfTotal float64 = 0 //床位自费
  20017. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20018. var operationCostTotal float64 = 0 //手术费
  20019. var operationCostSelfTotal float64 = 0 //手术费
  20020. var operationCostPartSelfTotal float64 = 0 //手术费
  20021. var otherCostTotal float64 = 0 //其他费用
  20022. var otherCostSelfTotal float64 = 0 //其他费用
  20023. var otherCostPartSelfTotal float64 = 0 //其他费用
  20024. var materialCostTotal float64 = 0 //材料费
  20025. var materialCostSelfTotal float64 = 0 //材料费
  20026. var materialCostPartSelfTotal float64 = 0 //材料费
  20027. var westernMedicineCostTotal float64 = 0 //西药费
  20028. var westernMedicineCostSelfTotal float64 = 0 //西药费
  20029. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20030. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20031. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20032. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20033. var checkCostTotal float64 = 0 //检查费
  20034. var checkCostSelfTotal float64 = 0 //检查费
  20035. var checkCostPartSelfTotal float64 = 0 //检查费
  20036. var laboratoryCostTotal float64 = 0 //化验费
  20037. var laboratoryCostSelfTotal float64 = 0 //化验费
  20038. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20039. var treatCostTotal float64 = 0 //治疗费用
  20040. var treatCostSelfTotal float64 = 0 //治疗费用
  20041. var treatCostPartSelfTotal float64 = 0 //治疗费用
  20042. decimal.DivisionPrecision = 2
  20043. var bed_fulamt_ownpay_amt float64 = 0
  20044. var operation_fulamt_ownpay_amt float64 = 0
  20045. var other_fulamt_ownpay_amt float64 = 0
  20046. var westernMedicine_fulamt_ownpay_amt float64 = 0
  20047. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20048. var check_fulamt_ownpay_amt float64 = 0
  20049. var material_fulamt_ownpay_amt float64 = 0
  20050. var laboratory_fulamt_ownpay_amt float64 = 0
  20051. var treat_fulamt_ownpay_amt float64 = 0
  20052. var bed_claa_sunmfee float64 = 0
  20053. var bed_clab_amt float64 = 0
  20054. var bed_other_amt float64 = 0
  20055. var operation_claa_sunmfee float64 = 0
  20056. var operation_clab_amt float64 = 0
  20057. var operation_other_amt float64 = 0
  20058. var other_claa_sunmfee float64 = 0
  20059. var other_clab_amt float64 = 0
  20060. var other_other_amt float64 = 0
  20061. var westernMedicine_claa_sunmfee float64 = 0
  20062. var westernMedicine_clab_amt float64 = 0
  20063. var westernMedicine_other_amt float64 = 0
  20064. var chineseTraditional_claa_sunmfee float64 = 0
  20065. var chineseTraditional_clab_amt float64 = 0
  20066. var chineseTraditional_other_amt float64 = 0
  20067. var check_claa_sunmfee float64 = 0
  20068. var check_clab_amt float64 = 0
  20069. var check_other_amt float64 = 0
  20070. var material_claa_sunmfee float64 = 0
  20071. var material_clab_amt float64 = 0
  20072. var material_other_amt float64 = 0
  20073. var laboratory_claa_sunmfee float64 = 0
  20074. var laboratory_clab_amt float64 = 0
  20075. var laboratory_other_amt float64 = 0
  20076. var treat_claa_sunmfee float64 = 0
  20077. var treat_clab_amt float64 = 0
  20078. var treat_other_amt float64 = 0
  20079. for _, item := range order.HisOrderInfo {
  20080. if item.MedChrgitmType == "01" { //床位费
  20081. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20082. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20083. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20084. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20085. if item.ChrgitmLv == "1" {
  20086. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20087. }
  20088. if item.ChrgitmLv == "2" {
  20089. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20090. }
  20091. if item.ChrgitmLv == "3" {
  20092. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20093. }
  20094. }
  20095. if item.MedChrgitmType == "03" { //检查费
  20096. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20097. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20098. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20099. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20100. if item.ChrgitmLv == "1" {
  20101. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20102. }
  20103. if item.ChrgitmLv == "2" {
  20104. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20105. }
  20106. if item.ChrgitmLv == "3" {
  20107. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20108. }
  20109. }
  20110. if item.MedChrgitmType == "04" { //化验费
  20111. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20112. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20113. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20114. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20115. if item.ChrgitmLv == "1" {
  20116. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20117. }
  20118. if item.ChrgitmLv == "2" {
  20119. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20120. }
  20121. if item.ChrgitmLv == "3" {
  20122. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20123. }
  20124. }
  20125. if item.MedChrgitmType == "05" { //治疗费
  20126. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20127. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20128. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20129. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20130. if item.ChrgitmLv == "1" {
  20131. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20132. }
  20133. if item.ChrgitmLv == "2" {
  20134. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20135. }
  20136. if item.ChrgitmLv == "3" {
  20137. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20138. }
  20139. }
  20140. if item.MedChrgitmType == "06" { //手术费
  20141. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20142. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20143. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20144. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20145. if item.ChrgitmLv == "1" {
  20146. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20147. }
  20148. if item.ChrgitmLv == "2" {
  20149. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20150. }
  20151. if item.ChrgitmLv == "3" {
  20152. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20153. }
  20154. }
  20155. if item.MedChrgitmType == "08" { //材料费
  20156. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20157. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20158. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20159. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20160. if item.ChrgitmLv == "1" {
  20161. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20162. }
  20163. if item.ChrgitmLv == "2" {
  20164. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20165. }
  20166. if item.ChrgitmLv == "3" {
  20167. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20168. }
  20169. }
  20170. if item.MedChrgitmType == "09" { //西药费
  20171. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20172. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20173. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20174. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20175. if item.ChrgitmLv == "1" {
  20176. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20177. }
  20178. if item.ChrgitmLv == "2" {
  20179. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20180. }
  20181. if item.ChrgitmLv == "3" {
  20182. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20183. }
  20184. }
  20185. if item.MedChrgitmType == "11" { //中成费
  20186. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20187. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20188. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20189. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20190. if item.ChrgitmLv == "1" {
  20191. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20192. }
  20193. if item.ChrgitmLv == "2" {
  20194. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20195. }
  20196. if item.ChrgitmLv == "3" {
  20197. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20198. }
  20199. }
  20200. if item.MedChrgitmType == "14" { //其他费
  20201. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20202. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20203. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20204. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20205. if item.ChrgitmLv == "1" {
  20206. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20207. }
  20208. if item.ChrgitmLv == "2" {
  20209. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20210. }
  20211. if item.ChrgitmLv == "3" {
  20212. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20213. }
  20214. }
  20215. }
  20216. var iteminfoStructs []service.IteminfoStruct
  20217. if bedCostTotal != 0 {
  20218. iteminfo.MedChrgitm = "01"
  20219. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20220. iteminfo.Amt = bedCostTotal
  20221. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20222. iteminfo.ClabAmt = bed_clab_amt
  20223. iteminfo.OthAmt = bed_other_amt
  20224. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20225. }
  20226. if checkCostTotal != 0 {
  20227. iteminfo.MedChrgitm = "03"
  20228. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20229. iteminfo.Amt = checkCostTotal
  20230. iteminfo.ClaaSumfee = check_claa_sunmfee
  20231. iteminfo.ClabAmt = check_clab_amt
  20232. iteminfo.OthAmt = check_other_amt
  20233. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20234. }
  20235. if laboratoryCostTotal != 0 {
  20236. iteminfo.MedChrgitm = "04"
  20237. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20238. iteminfo.Amt = laboratoryCostTotal
  20239. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20240. iteminfo.ClabAmt = laboratory_clab_amt
  20241. iteminfo.OthAmt = laboratory_other_amt
  20242. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20243. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20244. }
  20245. if treatCostTotal != 0 {
  20246. iteminfo.MedChrgitm = "05"
  20247. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20248. iteminfo.Amt = treatCostTotal
  20249. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20250. iteminfo.ClabAmt = treat_clab_amt
  20251. iteminfo.OthAmt = treat_other_amt
  20252. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20253. //(struct4101.IteminfoStruct, iteminfo)
  20254. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20255. }
  20256. if operationCostTotal != 0 {
  20257. iteminfo.MedChrgitm = "06"
  20258. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20259. iteminfo.Amt = operationCostTotal
  20260. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20261. iteminfo.ClabAmt = operation_clab_amt
  20262. iteminfo.OthAmt = operation_other_amt
  20263. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20264. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20265. }
  20266. if materialCostTotal != 0 {
  20267. iteminfo.MedChrgitm = "08"
  20268. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20269. iteminfo.Amt = materialCostTotal
  20270. iteminfo.ClaaSumfee = material_claa_sunmfee
  20271. iteminfo.ClabAmt = material_clab_amt
  20272. iteminfo.OthAmt = material_other_amt
  20273. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20274. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20275. }
  20276. if westernMedicineCostTotal != 0 {
  20277. iteminfo.MedChrgitm = "09"
  20278. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20279. iteminfo.Amt = westernMedicineCostTotal
  20280. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20281. iteminfo.ClabAmt = westernMedicine_clab_amt
  20282. iteminfo.OthAmt = westernMedicine_other_amt
  20283. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20284. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20285. }
  20286. if chineseTraditionalMedicineCostTotal != 0 {
  20287. iteminfo.MedChrgitm = "11"
  20288. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20289. iteminfo.Amt = westernMedicineCostTotal
  20290. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20291. iteminfo.ClabAmt = westernMedicine_clab_amt
  20292. iteminfo.OthAmt = westernMedicine_other_amt
  20293. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20294. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20295. }
  20296. if otherCostTotal != 0 {
  20297. iteminfo.MedChrgitm = "14"
  20298. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20299. iteminfo.Amt = otherCostTotal
  20300. iteminfo.ClaaSumfee = other_claa_sunmfee
  20301. iteminfo.ClabAmt = other_clab_amt
  20302. iteminfo.OthAmt = other_other_amt
  20303. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20304. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20305. }
  20306. struct4101.IteminfoStruct = iteminfoStructs
  20307. struct4101.Ntly = "中国"
  20308. struct4101.AdmCaty = "A03.06"
  20309. var resOther ResultSeventeenOther
  20310. var res ResultSeventeen
  20311. if miConfig.MdtrtareaAdmvs == "150499" {
  20312. var pp models.PublicParams
  20313. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20314. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20315. pp.FixmedinsName = miConfig.OrgName
  20316. pp.FixmedinsCode = miConfig.Code
  20317. pp.RequestUrl = miConfig.Url
  20318. pp.Cainfo = miConfig.Cainfo
  20319. pp.SecretKey = miConfig.SecretKey
  20320. pp.AccessKey = miConfig.AccessKey
  20321. pp.OpterName = curRoles.UserName
  20322. client := &http.Client{}
  20323. var req *http.Request
  20324. data := make(map[string]interface{})
  20325. data["struct4101"] = struct4101
  20326. data["pp"] = pp
  20327. bytesData, _ := json.Marshal(data)
  20328. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20329. resp, _ := client.Do(req)
  20330. defer resp.Body.Close()
  20331. body, ioErr := ioutil.ReadAll(resp.Body)
  20332. if ioErr != nil {
  20333. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20335. return
  20336. }
  20337. var respJSON map[string]interface{}
  20338. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20339. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20341. return
  20342. }
  20343. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20344. userJSONBytes, _ := json.Marshal(respJSON)
  20345. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20346. utils.ErrorLog("解析失败:%v", err)
  20347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20348. return
  20349. }
  20350. res.InfRefmsgid = resOther.InfRefmsgid
  20351. res.Output = resOther.Output
  20352. res.ErrMsg = resOther.ErrMsg
  20353. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20354. res.Infcode = infocode
  20355. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20356. var pp models.PublicParams
  20357. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20358. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20359. pp.FixmedinsName = miConfig.OrgName
  20360. pp.FixmedinsCode = miConfig.Code
  20361. pp.RequestUrl = miConfig.Url
  20362. pp.Cainfo = miConfig.Cainfo
  20363. pp.SecretKey = miConfig.SecretKey
  20364. pp.AccessKey = miConfig.AccessKey
  20365. pp.OpterName = curRoles.UserName
  20366. result, _ := service.Jxyb4101(struct4101, pp)
  20367. var dat map[string]interface{}
  20368. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20369. fmt.Println(dat)
  20370. } else {
  20371. fmt.Println(err)
  20372. }
  20373. userJSONBytes, _ := json.Marshal(dat)
  20374. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20375. utils.ErrorLog("解析失败:%v", err)
  20376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20377. return
  20378. }
  20379. } else if miConfig.MdtrtareaAdmvs == "361025" {
  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 {
  20404. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20405. var dat map[string]interface{}
  20406. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20407. fmt.Println(dat)
  20408. } else {
  20409. fmt.Println(err)
  20410. }
  20411. userJSONBytes, _ := json.Marshal(dat)
  20412. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20413. utils.ErrorLog("解析失败:%v", err)
  20414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20415. return
  20416. }
  20417. }
  20418. if res.Infcode != 0 {
  20419. c.ServeSuccessJSON(map[string]interface{}{
  20420. "failed_code": -10,
  20421. "msg": res.ErrMsg,
  20422. })
  20423. return
  20424. } else {
  20425. if miConfig.MdtrtareaAdmvs != "150499" {
  20426. order.FaPiaoNumber = zero
  20427. order.FaPiaoCode = last_order.FaPiaoCode
  20428. service.UpdateOrder(order)
  20429. }
  20430. hisFundSettleListResult := &models.HisFundSettleListResult{
  20431. Number: res.Output.SetlListId,
  20432. Status: 1,
  20433. Ctime: time.Now().Unix(),
  20434. Mtime: time.Now().Unix(),
  20435. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20436. IsUpload: 1,
  20437. OrderId: order_id,
  20438. }
  20439. service.CreateUploadRecord(hisFundSettleListResult)
  20440. c.ServeSuccessJSON(map[string]interface{}{
  20441. "msg": "上传成功",
  20442. "result": hisFundSettleListResult,
  20443. })
  20444. return
  20445. }
  20446. }
  20447. //func (c *HisApiController) GetBatchSettleList() {
  20448. // orders, _ := service.GetAllHisOrder(10106)
  20449. // for _, item := range orders {
  20450. // order_id := item.ID
  20451. // order, _ := service.GetHisOrderByIDTwo(order_id)
  20452. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20453. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20454. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20455. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  20456. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20457. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20458. //
  20459. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20460. //
  20461. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20462. //
  20463. // if order.ID == 0 {
  20464. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20465. // return
  20466. // }
  20467. // if his.BalanceAccountsType == 2 {
  20468. // continue
  20469. // }
  20470. // struct4101 := service.Struct4101{
  20471. // PsnNo: order.PsnNo,
  20472. // MdtrtId: order.MdtrtId,
  20473. // SetlId: order.SetlId,
  20474. // PsnName: order.PsnName,
  20475. // Gend: order.Gend,
  20476. // Brdy: his.Brdy,
  20477. // Age: his.Age,
  20478. // Naty: order.Naty,
  20479. // PatnCertType: "01",
  20480. // Certno: order.Certno,
  20481. // Prfs: "90",
  20482. // ConerName: roles[0].UserName,
  20483. // PatnRlts: "99",
  20484. // ConerAddr: miConfig.OrgName,
  20485. // ConerTel: admin.Mobile,
  20486. // HiType: order.Insutype,
  20487. // Insuplc: his.InsuplcAdmdvs,
  20488. // MaindiagFlag: "1",
  20489. // BillCode: order.SetlId,
  20490. // BillNo: order.SetlId,
  20491. // BizSn: order.Number,
  20492. // PsnSelfPay: order.PsnPartAmt,
  20493. // PsnOwnPay: order.PsnPartAmt,
  20494. // AcctPay: order.AcctPay,
  20495. // PsnCashpay: order.PsnCashPay,
  20496. // HiPaymtd: "1",
  20497. // Hsorg: his.InsuplcAdmdvs,
  20498. // HsorgOpter: his.InsuplcAdmdvs,
  20499. // MedinsFillPsn: curRoles.UserName,
  20500. // MedinsFillDept: depart.Name,
  20501. // IptMedType: "2",
  20502. // }
  20503. // struct4101.SetlBegnDate = order.SetlTime
  20504. // struct4101.SetlEndDate = order.SetlTime
  20505. // //if order.SettleType == 1 {
  20506. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  20507. // // dateStr := t.Format("2006-01-02")
  20508. // // struct4101.SetlBegnDate = dateStr
  20509. // // struct4101.SetlEndDate = dateStr
  20510. // //} else {
  20511. // // t := time.Unix(int64(order.SettleStartTime), 0)
  20512. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  20513. // // dateStartStr := t.Format("2006-01-02")
  20514. // // dateEndStr := t2.Format("2006-01-02")
  20515. // // struct4101.SetlBegnDate = dateStartStr
  20516. // // struct4101.SetlEndDate = dateEndStr
  20517. // //}
  20518. //
  20519. // var rf []CustomFundPay
  20520. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  20521. //
  20522. // var tempFunPays []service.CustomStruct
  20523. // var tempFunPay610100 service.CustomStruct
  20524. //
  20525. // for _, item := range rf {
  20526. // if item.FundPayType == "610100" {
  20527. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  20528. // tempFunPay610100.FundPayType = item.FundPayType
  20529. // } else {
  20530. // var tempFunPay service.CustomStruct
  20531. // tempFunPay.FundPayamt = item.FundPayamt
  20532. // tempFunPay.FundPayType = item.FundPayType
  20533. // tempFunPays = append(tempFunPays, tempFunPay)
  20534. // }
  20535. // }
  20536. // tempFunPays = append(tempFunPays, tempFunPay610100)
  20537. // struct4101.CustomStruct = tempFunPays
  20538. //
  20539. // var tempDiaginfos []service.DiaginfoStructTwo
  20540. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20541. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20542. //
  20543. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  20544. // var config []*models.HisXtDiagnoseConfig
  20545. // for _, item := range diagnosis_ids {
  20546. // id, _ := strconv.ParseInt(item, 10, 64)
  20547. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  20548. // config = append(config, &diagnosisConfig)
  20549. // }
  20550. //
  20551. // for index, item := range config {
  20552. // if index == 0 {
  20553. // var tempDiaginfo service.DiaginfoStructTwo
  20554. // tempDiaginfo.DiagCode = item.CountryCode
  20555. // tempDiaginfo.DiagName = item.CountryContentName
  20556. // tempDiaginfo.DiagType = "1"
  20557. // tempDiaginfo.MaindiagFlag = "1"
  20558. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20559. // } else {
  20560. //
  20561. // var tempDiaginfo service.DiaginfoStructTwo
  20562. // tempDiaginfo.DiagCode = item.CountryCode
  20563. // tempDiaginfo.DiagName = item.CountryContentName
  20564. // tempDiaginfo.DiagType = "2"
  20565. // tempDiaginfo.MaindiagFlag = "0"
  20566. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20567. // }
  20568. // }
  20569. // struct4101.Diseinfo = tempDiaginfos
  20570. //
  20571. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  20572. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20573. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20574. // tempOpspdiseinfo2.OprnOprtCode = ""
  20575. // tempOpspdiseinfo2.OprnOprtName = ""
  20576. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20577. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20578. //
  20579. // var iteminfo service.IteminfoStruct
  20580. //
  20581. // var bedCostTotal float64 = 0 //床位总费
  20582. // var bedCostSelfTotal float64 = 0 //床位自费
  20583. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20584. //
  20585. // var examineCostTotal float64 = 0 //诊查总费
  20586. // var examineCostSelfTotal float64 = 0 //诊查自费
  20587. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  20588. //
  20589. // var nursingCostTotal float64 = 0 //护理总费
  20590. // var nursingCostSelfTotal float64 = 0 //护理自费
  20591. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  20592. //
  20593. // var chineseMedicineCostTotal float64 = 0 //中成药
  20594. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  20595. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  20596. //
  20597. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  20598. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  20599. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  20600. //
  20601. // var registerCostTotal float64 = 0 //一般诊疗费
  20602. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  20603. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  20604. //
  20605. // var operationCostTotal float64 = 0 //手术费
  20606. // var operationCostSelfTotal float64 = 0 //手术费
  20607. // var operationCostPartSelfTotal float64 = 0 //手术费
  20608. //
  20609. // var otherCostTotal float64 = 0 //其他费用
  20610. // var otherCostSelfTotal float64 = 0 //其他费用
  20611. // var otherCostPartSelfTotal float64 = 0 //其他费用
  20612. //
  20613. // var materialCostTotal float64 = 0 //材料费
  20614. // var materialCostSelfTotal float64 = 0 //材料费
  20615. // var materialCostPartSelfTotal float64 = 0 //材料费
  20616. //
  20617. // var westernMedicineCostTotal float64 = 0 //西药费
  20618. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  20619. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20620. //
  20621. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20622. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20623. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20624. //
  20625. // var checkCostTotal float64 = 0 //检查费
  20626. // var checkCostSelfTotal float64 = 0 //检查费
  20627. // var checkCostPartSelfTotal float64 = 0 //检查费
  20628. //
  20629. // var laboratoryCostTotal float64 = 0 //化验费
  20630. // var laboratoryCostSelfTotal float64 = 0 //化验费
  20631. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20632. //
  20633. // var treatCostTotal float64 = 0 //治疗费用
  20634. // var treatCostSelfTotal float64 = 0 //治疗费用
  20635. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  20636. //
  20637. // decimal.DivisionPrecision = 2
  20638. //
  20639. // var bed_fulamt_ownpay_amt float64 = 0
  20640. //
  20641. // var examine_fulamt_ownpay_amt float64 = 0
  20642. //
  20643. // var nursing_fulamt_ownpay_amt float64 = 0
  20644. //
  20645. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  20646. //
  20647. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  20648. //
  20649. // var register_fulamt_ownpay_amt float64 = 0
  20650. //
  20651. // var operation_fulamt_ownpay_amt float64 = 0
  20652. // var other_fulamt_ownpay_amt float64 = 0
  20653. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  20654. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20655. // var check_fulamt_ownpay_amt float64 = 0
  20656. // var material_fulamt_ownpay_amt float64 = 0
  20657. // var laboratory_fulamt_ownpay_amt float64 = 0
  20658. // var treat_fulamt_ownpay_amt float64 = 0
  20659. //
  20660. // var bed_claa_sunmfee float64 = 0
  20661. // var bed_clab_amt float64 = 0
  20662. // var bed_other_amt float64 = 0
  20663. //
  20664. // var examine_claa_sunmfee float64 = 0
  20665. // var examine_clab_amt float64 = 0
  20666. // var examine_other_amt float64 = 0
  20667. //
  20668. // var nursing_claa_sunmfee float64 = 0
  20669. // var nursing_clab_amt float64 = 0
  20670. // var nursing_other_amt float64 = 0
  20671. //
  20672. // var chinese_medicine_claa_sunmfee float64 = 0
  20673. // var chinese_medicine_clab_amt float64 = 0
  20674. // var chinese_medicine_other_amt float64 = 0
  20675. //
  20676. // var commonly_treatment_claa_sunmfee float64 = 0
  20677. // var commonly_treatment_clab_amt float64 = 0
  20678. // var commonly_treatment_other_amt float64 = 0
  20679. //
  20680. // var operation_claa_sunmfee float64 = 0
  20681. // var operation_clab_amt float64 = 0
  20682. // var operation_other_amt float64 = 0
  20683. //
  20684. // var other_claa_sunmfee float64 = 0
  20685. // var other_clab_amt float64 = 0
  20686. // var other_other_amt float64 = 0
  20687. //
  20688. // var westernMedicine_claa_sunmfee float64 = 0
  20689. // var westernMedicine_clab_amt float64 = 0
  20690. // var westernMedicine_other_amt float64 = 0
  20691. //
  20692. // var chineseTraditional_claa_sunmfee float64 = 0
  20693. // var chineseTraditional_clab_amt float64 = 0
  20694. // var chineseTraditional_other_amt float64 = 0
  20695. //
  20696. // var check_claa_sunmfee float64 = 0
  20697. // var check_clab_amt float64 = 0
  20698. // var check_other_amt float64 = 0
  20699. //
  20700. // var material_claa_sunmfee float64 = 0
  20701. // var material_clab_amt float64 = 0
  20702. // var material_other_amt float64 = 0
  20703. //
  20704. // var laboratory_claa_sunmfee float64 = 0
  20705. // var laboratory_clab_amt float64 = 0
  20706. // var laboratory_other_amt float64 = 0
  20707. //
  20708. // var treat_claa_sunmfee float64 = 0
  20709. // var treat_clab_amt float64 = 0
  20710. // var treat_other_amt float64 = 0
  20711. //
  20712. // var register_claa_sunmfee float64 = 0
  20713. // var register_clab_amt float64 = 0
  20714. // var register_other_amt float64 = 0
  20715. //
  20716. // for _, item := range order.HisOrderInfo {
  20717. // if item.MedChrgitmType == "01" { //床位费
  20718. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20719. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20720. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20721. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20722. // if item.ChrgitmLv == "1" {
  20723. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20724. // }
  20725. // if item.ChrgitmLv == "2" {
  20726. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20727. //
  20728. // }
  20729. // if item.ChrgitmLv == "3" {
  20730. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20731. // }
  20732. //
  20733. // }
  20734. //
  20735. // if item.MedChrgitmType == "02" { //诊查
  20736. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20737. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20738. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20739. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20740. // if item.ChrgitmLv == "1" {
  20741. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20742. // }
  20743. // if item.ChrgitmLv == "2" {
  20744. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20745. //
  20746. // }
  20747. // if item.ChrgitmLv == "3" {
  20748. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20749. // }
  20750. //
  20751. // }
  20752. //
  20753. // if item.MedChrgitmType == "03" { //检查费
  20754. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20755. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20756. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20757. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20758. // if item.ChrgitmLv == "1" {
  20759. //
  20760. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20761. //
  20762. // }
  20763. // if item.ChrgitmLv == "2" {
  20764. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20765. //
  20766. // }
  20767. // if item.ChrgitmLv == "3" {
  20768. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20769. // }
  20770. // }
  20771. //
  20772. // if item.MedChrgitmType == "04" { //化验费
  20773. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20774. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20775. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20776. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20777. // if item.ChrgitmLv == "1" {
  20778. //
  20779. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20780. //
  20781. // }
  20782. // if item.ChrgitmLv == "2" {
  20783. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20784. //
  20785. // }
  20786. // if item.ChrgitmLv == "3" {
  20787. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20788. // }
  20789. // }
  20790. //
  20791. // if item.MedChrgitmType == "05" { //治疗费
  20792. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20793. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20794. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20795. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20796. // if item.ChrgitmLv == "1" {
  20797. //
  20798. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20799. //
  20800. // }
  20801. // if item.ChrgitmLv == "2" {
  20802. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20803. //
  20804. // }
  20805. // if item.ChrgitmLv == "3" {
  20806. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20807. // }
  20808. // }
  20809. //
  20810. // if item.MedChrgitmType == "06" { //手术费
  20811. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20812. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20813. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20814. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20815. //
  20816. // if item.ChrgitmLv == "1" {
  20817. //
  20818. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20819. //
  20820. // }
  20821. // if item.ChrgitmLv == "2" {
  20822. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20823. //
  20824. // }
  20825. // if item.ChrgitmLv == "3" {
  20826. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20827. // }
  20828. // }
  20829. //
  20830. // if item.MedChrgitmType == "07" { //手术费
  20831. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20832. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20833. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20834. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20835. //
  20836. // if item.ChrgitmLv == "1" {
  20837. //
  20838. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20839. //
  20840. // }
  20841. // if item.ChrgitmLv == "2" {
  20842. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20843. //
  20844. // }
  20845. // if item.ChrgitmLv == "3" {
  20846. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20847. // }
  20848. // }
  20849. //
  20850. // if item.MedChrgitmType == "08" { //材料费
  20851. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20852. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20853. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20854. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20855. // if item.ChrgitmLv == "1" {
  20856. //
  20857. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20858. //
  20859. // }
  20860. // if item.ChrgitmLv == "2" {
  20861. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20862. //
  20863. // }
  20864. // if item.ChrgitmLv == "3" {
  20865. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20866. // }
  20867. // }
  20868. // if item.MedChrgitmType == "09" { //西药费
  20869. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20870. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20871. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20872. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20873. // if item.ChrgitmLv == "1" {
  20874. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20875. // }
  20876. // if item.ChrgitmLv == "2" {
  20877. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20878. // }
  20879. // if item.ChrgitmLv == "3" {
  20880. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20881. // }
  20882. // }
  20883. // if item.MedChrgitmType == "10" { //中药饮片
  20884. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20885. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20886. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20887. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20888. // if item.ChrgitmLv == "1" {
  20889. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20890. // }
  20891. // if item.ChrgitmLv == "2" {
  20892. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20893. // }
  20894. // if item.ChrgitmLv == "3" {
  20895. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20896. // }
  20897. // }
  20898. //
  20899. // if item.MedChrgitmType == "11" { //中成费
  20900. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20901. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20902. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20903. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20904. // if item.ChrgitmLv == "1" {
  20905. //
  20906. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20907. //
  20908. // }
  20909. // if item.ChrgitmLv == "2" {
  20910. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20911. //
  20912. // }
  20913. // if item.ChrgitmLv == "3" {
  20914. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20915. // }
  20916. // }
  20917. //
  20918. // if item.MedChrgitmType == "12" { //中成费
  20919. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20920. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20921. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20922. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20923. // if item.ChrgitmLv == "1" {
  20924. //
  20925. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20926. //
  20927. // }
  20928. // if item.ChrgitmLv == "2" {
  20929. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20930. //
  20931. // }
  20932. // if item.ChrgitmLv == "3" {
  20933. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20934. // }
  20935. // }
  20936. //
  20937. // if item.MedChrgitmType == "13" { //中成费
  20938. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20939. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20940. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20941. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20942. // if item.ChrgitmLv == "1" {
  20943. //
  20944. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20945. //
  20946. // }
  20947. // if item.ChrgitmLv == "2" {
  20948. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20949. //
  20950. // }
  20951. // if item.ChrgitmLv == "3" {
  20952. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20953. // }
  20954. // }
  20955. //
  20956. // if item.MedChrgitmType == "14" { //其他费
  20957. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20958. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20959. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20960. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20961. // if item.ChrgitmLv == "1" {
  20962. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20963. //
  20964. // }
  20965. // if item.ChrgitmLv == "2" {
  20966. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20967. //
  20968. // }
  20969. // if item.ChrgitmLv == "3" {
  20970. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20971. // }
  20972. // }
  20973. //
  20974. // }
  20975. //
  20976. // var iteminfoStructs []service.IteminfoStruct
  20977. //
  20978. // if bedCostTotal != 0 {
  20979. // iteminfo.MedChrgitm = "01"
  20980. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20981. // iteminfo.Amt = bedCostTotal
  20982. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  20983. // iteminfo.ClabAmt = bed_clab_amt
  20984. // iteminfo.OthAmt = bed_other_amt
  20985. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20986. // }
  20987. //
  20988. // if examineCostTotal != 0 {
  20989. // iteminfo.MedChrgitm = "02"
  20990. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  20991. // iteminfo.Amt = examineCostTotal
  20992. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  20993. // iteminfo.ClabAmt = examine_clab_amt
  20994. // iteminfo.OthAmt = examine_other_amt
  20995. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20996. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  20997. // }
  20998. //
  20999. // if checkCostTotal != 0 {
  21000. // iteminfo.MedChrgitm = "03"
  21001. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  21002. // iteminfo.Amt = checkCostTotal
  21003. // iteminfo.ClaaSumfee = check_claa_sunmfee
  21004. // iteminfo.ClabAmt = check_clab_amt
  21005. // iteminfo.OthAmt = check_other_amt
  21006. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21007. //
  21008. // }
  21009. //
  21010. // if laboratoryCostTotal != 0 {
  21011. // iteminfo.MedChrgitm = "04"
  21012. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  21013. // iteminfo.Amt = laboratoryCostTotal
  21014. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  21015. // iteminfo.ClabAmt = laboratory_clab_amt
  21016. // iteminfo.OthAmt = laboratory_other_amt
  21017. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21018. //
  21019. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21020. //
  21021. // }
  21022. //
  21023. // if treatCostTotal != 0 {
  21024. // iteminfo.MedChrgitm = "05"
  21025. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  21026. // iteminfo.Amt = treatCostTotal
  21027. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  21028. // iteminfo.ClabAmt = treat_clab_amt
  21029. // iteminfo.OthAmt = treat_other_amt
  21030. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21031. // //(struct4101.IteminfoStruct, iteminfo)
  21032. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21033. // }
  21034. //
  21035. // if operationCostTotal != 0 {
  21036. // iteminfo.MedChrgitm = "06"
  21037. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21038. // iteminfo.Amt = operationCostTotal
  21039. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  21040. // iteminfo.ClabAmt = operation_clab_amt
  21041. // iteminfo.OthAmt = operation_other_amt
  21042. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21043. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21044. // }
  21045. //
  21046. // if nursingCostTotal != 0 {
  21047. // iteminfo.MedChrgitm = "07"
  21048. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  21049. // iteminfo.Amt = nursingCostTotal
  21050. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  21051. // iteminfo.ClabAmt = nursing_clab_amt
  21052. // iteminfo.OthAmt = nursing_other_amt
  21053. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21054. // }
  21055. //
  21056. // if materialCostTotal != 0 {
  21057. // iteminfo.MedChrgitm = "08"
  21058. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  21059. // iteminfo.Amt = materialCostTotal
  21060. // iteminfo.ClaaSumfee = material_claa_sunmfee
  21061. // iteminfo.ClabAmt = material_clab_amt
  21062. // iteminfo.OthAmt = material_other_amt
  21063. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21064. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21065. // }
  21066. //
  21067. // if westernMedicineCostTotal != 0 {
  21068. // iteminfo.MedChrgitm = "09"
  21069. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21070. // iteminfo.Amt = westernMedicineCostTotal
  21071. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21072. // iteminfo.ClabAmt = westernMedicine_clab_amt
  21073. // iteminfo.OthAmt = westernMedicine_other_amt
  21074. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21075. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21076. //
  21077. // }
  21078. //
  21079. // if chineseMedicineCostTotal != 0 {
  21080. // iteminfo.MedChrgitm = "10"
  21081. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  21082. // iteminfo.Amt = chineseMedicineCostTotal
  21083. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  21084. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  21085. // iteminfo.OthAmt = chinese_medicine_other_amt
  21086. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21087. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21088. //
  21089. // }
  21090. //
  21091. // if chineseTraditionalMedicineCostTotal != 0 {
  21092. // iteminfo.MedChrgitm = "11"
  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 commonlyTreatmentCostTotal != 0 {
  21104. // iteminfo.MedChrgitm = "12"
  21105. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  21106. // iteminfo.Amt = commonlyTreatmentCostTotal
  21107. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  21108. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  21109. // iteminfo.OthAmt = commonly_treatment_other_amt
  21110. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21111. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21112. //
  21113. // }
  21114. //
  21115. // if registerCostTotal != 0 {
  21116. // iteminfo.MedChrgitm = "13"
  21117. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  21118. // iteminfo.Amt = registerCostTotal
  21119. // iteminfo.ClaaSumfee = register_claa_sunmfee
  21120. // iteminfo.ClabAmt = register_clab_amt
  21121. // iteminfo.OthAmt = register_other_amt
  21122. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21123. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21124. //
  21125. // }
  21126. //
  21127. // if otherCostTotal != 0 {
  21128. // iteminfo.MedChrgitm = "14"
  21129. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  21130. // iteminfo.Amt = otherCostTotal
  21131. // iteminfo.ClaaSumfee = other_claa_sunmfee
  21132. // iteminfo.ClabAmt = other_clab_amt
  21133. // iteminfo.OthAmt = other_other_amt
  21134. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21135. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  21136. //
  21137. // }
  21138. // struct4101.IteminfoStruct = iteminfoStructs
  21139. // time_arr := strings.Split(order.SetlTime, " ")
  21140. // struct4101.AdmTime = time_arr[0]
  21141. // struct4101.AdmEndTime = time_arr[0]
  21142. //
  21143. // struct4101.DoctorName = doctor.UserName
  21144. // struct4101.DoctorCode = doctor.DoctorNumber
  21145. //
  21146. // struct4101.Ntly = "中国"
  21147. // struct4101.AdmCaty = "A03.06"
  21148. // var res ResultSeventeen
  21149. // if miConfig.MdtrtareaAdmvs == "421300" {
  21150. // data := make(map[string]interface{})
  21151. // data["struct4101"] = struct4101
  21152. // data["secret_key"] = miConfig.SecretKey
  21153. // data["org_name"] = miConfig.OrgName
  21154. // data["opera"] = curRoles.UserName
  21155. // data["code"] = miConfig.Code
  21156. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21157. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21158. //
  21159. // client := &http.Client{}
  21160. // bytesData, _ := json.Marshal(data)
  21161. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21162. // resp, _ := client.Do(req)
  21163. // defer resp.Body.Close()
  21164. // body, ioErr := ioutil.ReadAll(resp.Body)
  21165. // if ioErr != nil {
  21166. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21167. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21168. // return
  21169. // }
  21170. // var respJSON map[string]interface{}
  21171. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21172. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21173. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21174. // return
  21175. // }
  21176. //
  21177. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21178. // userJSONBytes, _ := json.Marshal(respJSON)
  21179. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21180. // utils.ErrorLog("解析失败:%v", err)
  21181. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21182. // adminUser := c.GetAdminUserInfo()
  21183. // errlog := &models.HisOrderError{
  21184. // UserOrgId: adminUser.CurrentOrgId,
  21185. // Ctime: time.Now().Unix(),
  21186. // Mtime: time.Now().Unix(),
  21187. // ErrMsg: res.ErrMsg + "解析失败",
  21188. // Status: 1,
  21189. // PatientId: order_id,
  21190. // Stage: 10088,
  21191. // }
  21192. // service.CreateErrMsgLog(errlog)
  21193. // continue
  21194. // }
  21195. //
  21196. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  21197. // data := make(map[string]interface{})
  21198. // data["struct4101"] = struct4101
  21199. // data["secret_key"] = miConfig.SecretKey
  21200. // data["org_name"] = miConfig.OrgName
  21201. // data["opera"] = curRoles.UserName
  21202. // data["code"] = miConfig.Code
  21203. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  21204. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21205. //
  21206. // client := &http.Client{}
  21207. // bytesData, _ := json.Marshal(data)
  21208. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  21209. // resp, _ := client.Do(req)
  21210. // defer resp.Body.Close()
  21211. // body, ioErr := ioutil.ReadAll(resp.Body)
  21212. // if ioErr != nil {
  21213. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21214. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21215. // return
  21216. // }
  21217. // var respJSON map[string]interface{}
  21218. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21219. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21220. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21221. // return
  21222. // }
  21223. //
  21224. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21225. // userJSONBytes, _ := json.Marshal(respJSON)
  21226. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21227. // utils.ErrorLog("解析失败:%v", err)
  21228. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21229. // adminUser := c.GetAdminUserInfo()
  21230. // errlog := &models.HisOrderError{
  21231. // UserOrgId: adminUser.CurrentOrgId,
  21232. // Ctime: time.Now().Unix(),
  21233. // Mtime: time.Now().Unix(),
  21234. // ErrMsg: res.ErrMsg + "解析失败",
  21235. // Status: 1,
  21236. // PatientId: order_id,
  21237. // Stage: 10088,
  21238. // }
  21239. // service.CreateErrMsgLog(errlog)
  21240. // continue
  21241. // }
  21242. //
  21243. // } else {
  21244. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  21245. // fmt.Println(result)
  21246. //
  21247. // var dat map[string]interface{}
  21248. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21249. // fmt.Println(dat)
  21250. // } else {
  21251. // fmt.Println(err)
  21252. // }
  21253. // userJSONBytes, _ := json.Marshal(dat)
  21254. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21255. // utils.ErrorLog("解析失败:%v", err)
  21256. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21257. // adminUser := c.GetAdminUserInfo()
  21258. // errlog := &models.HisOrderError{
  21259. // UserOrgId: adminUser.CurrentOrgId,
  21260. // Ctime: time.Now().Unix(),
  21261. // Mtime: time.Now().Unix(),
  21262. // ErrMsg: res.ErrMsg + "解析失败",
  21263. // Status: 1,
  21264. // PatientId: order_id,
  21265. // Stage: 10106,
  21266. // }
  21267. // service.CreateErrMsgLog(errlog)
  21268. // continue
  21269. // }
  21270. // }
  21271. //
  21272. // if res.Infcode != 0 {
  21273. // adminUser := c.GetAdminUserInfo()
  21274. // errlog := &models.HisOrderError{
  21275. // UserOrgId: adminUser.CurrentOrgId,
  21276. // Ctime: time.Now().Unix(),
  21277. // Mtime: time.Now().Unix(),
  21278. // ErrMsg: res.ErrMsg,
  21279. // Status: 1,
  21280. // PatientId: order_id,
  21281. // Stage: 10106,
  21282. // }
  21283. // service.CreateErrMsgLog(errlog)
  21284. // continue
  21285. // } else {
  21286. // hisFundSettleListResult := &models.HisFundSettleListResult{
  21287. // Number: res.Output.SetlListId,
  21288. // Status: 1,
  21289. // Ctime: time.Now().Unix(),
  21290. // Mtime: time.Now().Unix(),
  21291. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21292. // IsUpload: 1,
  21293. // OrderId: order_id,
  21294. // }
  21295. // service.CreateUploadRecord(hisFundSettleListResult)
  21296. // continue
  21297. // }
  21298. // }
  21299. //}
  21300. func (c *HisApiController) GetOrgInfo() {
  21301. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  21302. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  21303. }
  21304. func (c *HisApiController) GetHisPatientInfo() {
  21305. medical_insurance_card := c.GetString("medical_insurance_card")
  21306. id_card_type, _ := c.GetInt64("id_card_type")
  21307. id_card := c.GetString("id_card")
  21308. adminInfo := c.GetAdminUserInfo()
  21309. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  21310. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  21311. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  21312. IdCardNo := ""
  21313. if id_card_type == 1 {
  21314. IdCardNo = medical_insurance_card
  21315. } else if id_card_type == 2 {
  21316. IdCardNo = id_card
  21317. }
  21318. if config.IsOpen == 1 {
  21319. 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
  21320. resp, requestErr := http.Get(api)
  21321. if requestErr != nil {
  21322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21323. return
  21324. }
  21325. defer resp.Body.Close()
  21326. body, ioErr := ioutil.ReadAll(resp.Body)
  21327. if ioErr != nil {
  21328. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21330. return
  21331. }
  21332. var respJSON map[string]interface{}
  21333. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21334. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21336. return
  21337. }
  21338. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21339. userJSONBytes, _ := json.Marshal(userJSON)
  21340. var res ResultTwo
  21341. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21342. utils.ErrorLog("解析失败:%v", err)
  21343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21344. return
  21345. }
  21346. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21347. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21348. infoStr := string(Iinfos)
  21349. idetinfoStr := string(Idetinfos)
  21350. if res.Infcode == 0 {
  21351. his := models.VMHisPatient{
  21352. Status: 1,
  21353. Ctime: time.Now().Unix(),
  21354. Mtime: time.Now().Unix(),
  21355. PsnNo: res.Output.Baseinfo.PsnNo,
  21356. PsnCertType: res.Output.Baseinfo.PsnCertType,
  21357. Certno: res.Output.Baseinfo.Certno,
  21358. PsnName: res.Output.Baseinfo.PsnName,
  21359. Gend: res.Output.Baseinfo.Gend,
  21360. Naty: res.Output.Baseinfo.Naty,
  21361. Iinfo: infoStr,
  21362. Idetinfo: idetinfoStr,
  21363. UserOrgId: adminInfo.CurrentOrgId,
  21364. IsReturn: 1,
  21365. IdCardType: id_card_type,
  21366. }
  21367. c.ServeSuccessJSON(map[string]interface{}{
  21368. "info": his,
  21369. })
  21370. } else {
  21371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  21372. return
  21373. }
  21374. }
  21375. }
  21376. //func GetBasBaseInfo() (jsonStr string, err error) {
  21377. //
  21378. // handle := syscall.NewLazyDLL("SSCard.dll")
  21379. // add := handle.NewProc("ReadCardBas")
  21380. // str := make([]byte, 1024)
  21381. // str1 := make([]byte, 1024)
  21382. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21383. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  21384. //
  21385. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  21386. //
  21387. // fmt.Println("> Add(4,5)的结果为:", ret)
  21388. // handle.Release()
  21389. //
  21390. // return "", nil
  21391. //
  21392. //}
  21393. //func GetQRBaseInfo() (jsonStr string, err error) {
  21394. // handle := syscall.LoadDLL("SSCard.dll")
  21395. // ReadCardBas := handle.FindProc("GetQRBase")
  21396. //
  21397. // str := make([]byte, 256)
  21398. // str1 := make([]byte, 256)
  21399. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  21400. //
  21401. // fmt.Println(string(str))
  21402. // fmt.Println(r)
  21403. // return string(str), nil
  21404. //}
  21405. //func CardInit() int {
  21406. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  21407. // add := DllTestDef.MustFindProc("Init")
  21408. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21409. // if err != nil {
  21410. // fmt.Println("SSCard的运算结果为:", ret)
  21411. // }
  21412. // result := int(ret)
  21413. // return result
  21414. //}
  21415. //func CardInit() int {
  21416. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  21417. // if err != nil {
  21418. // fmt.Println("SSCard的运算结果为:", ret)
  21419. // }
  21420. // fmt.Println(err)
  21421. // result := int(ret)
  21422. // return result
  21423. //}
  21424. func IntPtr(n int) uintptr {
  21425. return uintptr(n)
  21426. }
  21427. func StrPtr(s string) uintptr {
  21428. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  21429. }
  21430. type Result2001 struct {
  21431. Cainfo interface{} `json:"cainfo"`
  21432. ErrMsg string `json:"err_msg"`
  21433. InfRefmsgid string `json:"inf_refmsgid"`
  21434. Infcode int64 `json:"infcode"`
  21435. Output struct {
  21436. Trtinfo struct {
  21437. PsnNo string `json:"psn_no"`
  21438. TrtChkType string `json:"trt_chk_type"`
  21439. FundPayType string `json:"fund_pay_type"`
  21440. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21441. Begndate string `json:"begndate"`
  21442. Enddate string `json:"enddate"`
  21443. TrtChkRslt string `json:"trt_chk_rslt"`
  21444. } `json:"trtinfo"`
  21445. } `json:"output"`
  21446. RefmsgTime string `json:"refmsg_time"`
  21447. RespondTime string `json:"respond_time"`
  21448. Signtype interface{} `json:"signtype"`
  21449. WarnMsg interface{} `json:"warn_msg"`
  21450. }
  21451. type Result2001Org10265 struct {
  21452. Cainfo interface{} `json:"cainfo"`
  21453. ErrMsg string `json:"err_msg"`
  21454. InfRefmsgid string `json:"inf_refmsgid"`
  21455. Infcode string `json:"infcode"`
  21456. Output struct {
  21457. Trtinfo struct {
  21458. PsnNo string `json:"psn_no"`
  21459. TrtChkType string `json:"trt_chk_type"`
  21460. FundPayType string `json:"fund_pay_type"`
  21461. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  21462. Begndate string `json:"begndate"`
  21463. Enddate string `json:"enddate"`
  21464. TrtChkRslt string `json:"trt_chk_rslt"`
  21465. } `json:"trtinfo"`
  21466. } `json:"output"`
  21467. RefmsgTime string `json:"refmsg_time"`
  21468. RespondTime string `json:"respond_time"`
  21469. Signtype interface{} `json:"signtype"`
  21470. WarnMsg interface{} `json:"warn_msg"`
  21471. }
  21472. type ResultTwo struct {
  21473. ErrMsg string `json:"err_msg"`
  21474. InfRefmsgid string `json:"inf_refmsgid"`
  21475. Infcode int64 `json:"infcode"`
  21476. Output struct {
  21477. Baseinfo struct {
  21478. //Brdy string `json:"brdy"`
  21479. Certno string `json:"certno"`
  21480. Gend string `json:"gend"`
  21481. Naty string `json:"naty"`
  21482. PsnCertType string `json:"psn_cert_type"`
  21483. PsnName string `json:"psn_name"`
  21484. PsnNo string `json:"psn_no"`
  21485. } `json:"baseinfo"`
  21486. Idetinfo []interface{} `json:"idetinfo"`
  21487. Iinfo []struct {
  21488. Balc float64 `json:"balc"`
  21489. CvlservFlag string `json:"cvlserv_flag"`
  21490. EmpName string `json:"emp_name"`
  21491. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21492. Insutype string `json:"insutype"`
  21493. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21494. //PausInsuDate string `json:"paus_insu_date"`
  21495. //PsnInsuDate string `json:"psn_insu_date"`
  21496. PsnInsuStas string `json:"psn_insu_stas"`
  21497. PsnType string `json:"psn_type"`
  21498. } `json:"insuinfo"`
  21499. } `json:"output"`
  21500. RefmsgTime string `json:"refmsg_time"`
  21501. RespondTime string `json:"respond_time"`
  21502. Signtype interface{} `json:"signtype"`
  21503. WarnInfo interface{} `json:"warn_info"`
  21504. }
  21505. type ResultTwo10265 struct {
  21506. ErrMsg string `json:"err_msg"`
  21507. InfRefmsgid string `json:"inf_refmsgid"`
  21508. Infcode string `json:"infcode"`
  21509. Output struct {
  21510. Baseinfo struct {
  21511. //Brdy string `json:"brdy"`
  21512. Certno string `json:"certno"`
  21513. Gend string `json:"gend"`
  21514. Naty string `json:"naty"`
  21515. PsnCertType string `json:"psn_cert_type"`
  21516. PsnName string `json:"psn_name"`
  21517. PsnNo string `json:"psn_no"`
  21518. } `json:"baseinfo"`
  21519. Idetinfo []interface{} `json:"idetinfo"`
  21520. Iinfo []struct {
  21521. Balc float64 `json:"balc"`
  21522. CvlservFlag string `json:"cvlserv_flag"`
  21523. EmpName string `json:"emp_name"`
  21524. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21525. Insutype string `json:"insutype"`
  21526. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21527. PsnInsuStas string `json:"psn_insu_stas"`
  21528. PsnType string `json:"psn_type"`
  21529. } `json:"insuinfo"`
  21530. } `json:"output"`
  21531. RefmsgTime string `json:"refmsg_time"`
  21532. RespondTime string `json:"respond_time"`
  21533. Signtype interface{} `json:"signtype"`
  21534. WarnInfo interface{} `json:"warn_info"`
  21535. }
  21536. type ResultThree struct {
  21537. Cainfo interface{} `json:"cainfo"`
  21538. ErrMsg string `json:"err_msg"`
  21539. InfRefmsgid string `json:"inf_refmsgid"`
  21540. Infcode int64 `json:"infcode"`
  21541. Output struct {
  21542. Data struct {
  21543. IptOtpNo string `json:"ipt_otp_no"`
  21544. MdtrtID string `json:"mdtrt_id"`
  21545. PsnNo string `json:"psn_no"`
  21546. } `json:"data"`
  21547. } `json:"output"`
  21548. RefmsgTime string `json:"refmsg_time"`
  21549. RespondTime string `json:"respond_time"`
  21550. Signtype interface{} `json:"signtype"`
  21551. WarnMsg interface{} `json:"warn_msg"`
  21552. }
  21553. type ResultThree10265 struct {
  21554. Cainfo interface{} `json:"cainfo"`
  21555. ErrMsg string `json:"err_msg"`
  21556. InfRefmsgid string `json:"inf_refmsgid"`
  21557. Infcode string `json:"infcode"`
  21558. Output struct {
  21559. Data struct {
  21560. IptOtpNo string `json:"ipt_otp_no"`
  21561. MdtrtID string `json:"mdtrt_id"`
  21562. PsnNo string `json:"psn_no"`
  21563. } `json:"data"`
  21564. } `json:"output"`
  21565. RefmsgTime string `json:"refmsg_time"`
  21566. RespondTime string `json:"respond_time"`
  21567. Signtype interface{} `json:"signtype"`
  21568. WarnMsg interface{} `json:"warn_msg"`
  21569. }
  21570. type ResultFour struct {
  21571. Cainfo string `json:"cainfo"`
  21572. ErrMsg string `json:"err_msg"`
  21573. InfRefmsgid string `json:"inf_refmsgid"`
  21574. Infcode int64 `json:"infcode"`
  21575. Output struct {
  21576. Result []struct {
  21577. BasMednFlag string `json:"bas_medn_flag"`
  21578. ChldMedcFlag string `json:"chld_medc_flag"`
  21579. ChrgitmLv string `json:"chrgitm_lv"`
  21580. Cnt float64 `json:"cnt"`
  21581. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21582. DrtReimFlag string `json:"drt_reim_flag"`
  21583. FeedetlSn string `json:"feedetl_sn"`
  21584. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21585. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21586. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21587. ListSpItemFlag string `json:"list_sp_item_flag"`
  21588. LmtUsedFlag string `json:"lmt_used_flag"`
  21589. MedChrgitmType string `json:"med_chrgitm_type"`
  21590. Memo string `json:"memo"`
  21591. OverlmtAmt float64 `json:"overlmt_amt"`
  21592. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21593. Pric float64 `json:"pric"`
  21594. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21595. SelfpayProp float64 `json:"selfpay_prop"`
  21596. } `json:"result"`
  21597. } `json:"output"`
  21598. RefmsgTime string `json:"refmsg_time"`
  21599. RespondTime string `json:"respond_time"`
  21600. Signtype string `json:"signtype"`
  21601. WarnMsg string `json:"warn_msg"`
  21602. }
  21603. type ResultFour10265 struct {
  21604. Cainfo string `json:"cainfo"`
  21605. ErrMsg string `json:"err_msg"`
  21606. InfRefmsgid string `json:"inf_refmsgid"`
  21607. Infcode string `json:"infcode"`
  21608. Output struct {
  21609. Result []struct {
  21610. BasMednFlag string `json:"bas_medn_flag"`
  21611. ChldMedcFlag string `json:"chld_medc_flag"`
  21612. ChrgitmLv string `json:"chrgitm_lv"`
  21613. Cnt float64 `json:"cnt"`
  21614. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  21615. DrtReimFlag string `json:"drt_reim_flag"`
  21616. FeedetlSn string `json:"feedetl_sn"`
  21617. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21618. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  21619. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21620. ListSpItemFlag string `json:"list_sp_item_flag"`
  21621. LmtUsedFlag string `json:"lmt_used_flag"`
  21622. MedChrgitmType string `json:"med_chrgitm_type"`
  21623. Memo string `json:"memo"`
  21624. OverlmtAmt float64 `json:"overlmt_amt"`
  21625. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21626. Pric float64 `json:"pric"`
  21627. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  21628. SelfpayProp float64 `json:"selfpay_prop"`
  21629. } `json:"result"`
  21630. } `json:"output"`
  21631. RefmsgTime string `json:"refmsg_time"`
  21632. RespondTime string `json:"respond_time"`
  21633. Signtype string `json:"signtype"`
  21634. WarnMsg string `json:"warn_msg"`
  21635. }
  21636. type ResultMemo struct {
  21637. InsuAdmdvs string `json:"insuAdmdvs"`
  21638. }
  21639. // [{"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}]
  21640. type ResultIDInfo struct {
  21641. Begntime string `json:"begntime"`
  21642. Endtime string `json:"endtime"`
  21643. Memo string `json:"memo"`
  21644. }
  21645. type ResultFive struct {
  21646. Balc float64 `json:"balc"`
  21647. CvlservFlag string `json:"cvlserv_flag"`
  21648. EmpName string `json:"emp_name"`
  21649. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  21650. Insutype string `json:"insutype"`
  21651. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  21652. PausInsuDate string `json:"paus_insu_date"`
  21653. PsnInsuDate string `json:"psn_insu_date"`
  21654. PsnInsuStas string `json:"psn_insu_stas"`
  21655. PsnType string `json:"psn_type"`
  21656. }
  21657. type ResultSix struct {
  21658. Cainfo interface{} `json:"cainfo"`
  21659. ErrMsg string `json:"err_msg"`
  21660. InfRefmsgid string `json:"inf_refmsgid"`
  21661. Infcode int64 `json:"infcode"`
  21662. Output struct {
  21663. } `json:"output"`
  21664. RefmsgTime string `json:"refmsg_time"`
  21665. RespondTime string `json:"respond_time"`
  21666. Signtype interface{} `json:"signtype"`
  21667. WarnMsg interface{} `json:"warn_msg"`
  21668. }
  21669. type FJ3507Result struct {
  21670. Cainfo interface{} `json:"cainfo"`
  21671. ErrMsg string `json:"err_msg"`
  21672. InfRefmsgid string `json:"inf_refmsgid"`
  21673. Infcode int64 `json:"infcode"`
  21674. Output struct {
  21675. retRslt string `json:"retRslt"`
  21676. msgRslt string `json:"msgRslt"`
  21677. } `json:"output"`
  21678. RefmsgTime string `json:"refmsg_time"`
  21679. RespondTime string `json:"respond_time"`
  21680. Signtype interface{} `json:"signtype"`
  21681. WarnMsg interface{} `json:"warn_msg"`
  21682. }
  21683. type FJ3507ResultFor10188 struct {
  21684. Cainfo interface{} `json:"cainfo"`
  21685. ErrMsg string `json:"err_msg"`
  21686. InfRefmsgid string `json:"inf_refmsgid"`
  21687. Infcode string `json:"infcode"`
  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 Result2406 struct {
  21694. Cainfo interface{} `json:"cainfo"`
  21695. ErrMsg string `json:"err_msg"`
  21696. InfRefmsgid string `json:"inf_refmsgid"`
  21697. Infcode int64 `json:"infcode"`
  21698. Output struct {
  21699. Result struct {
  21700. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  21701. } `json:"result"`
  21702. } `json:"output"`
  21703. RefmsgTime string `json:"refmsg_time"`
  21704. RespondTime string `json:"respond_time"`
  21705. Signtype interface{} `json:"signtype"`
  21706. WarnMsg interface{} `json:"warn_msg"`
  21707. }
  21708. type GZResultSix struct {
  21709. Cainfo interface{} `json:"cainfo"`
  21710. ErrMsg string `json:"err_msg"`
  21711. InfRefmsgid string `json:"inf_refmsgid"`
  21712. Infcode int64 `json:"infcode"`
  21713. Output string `json:"output"`
  21714. RefmsgTime string `json:"refmsg_time"`
  21715. RespondTime string `json:"respond_time"`
  21716. Signtype interface{} `json:"signtype"`
  21717. WarnMsg interface{} `json:"warn_msg"`
  21718. }
  21719. type ResultSix10265 struct {
  21720. Cainfo interface{} `json:"cainfo"`
  21721. ErrMsg string `json:"err_msg"`
  21722. InfRefmsgid string `json:"inf_refmsgid"`
  21723. Infcode string `json:"infcode"`
  21724. Output struct {
  21725. } `json:"output"`
  21726. RefmsgTime string `json:"refmsg_time"`
  21727. RespondTime string `json:"respond_time"`
  21728. Signtype interface{} `json:"signtype"`
  21729. WarnMsg interface{} `json:"warn_msg"`
  21730. }
  21731. type ResultSeven struct {
  21732. Cainfo string `json:"cainfo"`
  21733. ErrMsg string `json:"err_msg"`
  21734. InfRefmsgid string `json:"inf_refmsgid"`
  21735. Infcode int64 `json:"infcode"`
  21736. Output struct {
  21737. Setlinfo struct {
  21738. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21739. AcctPay float64 `json:"acct_pay"`
  21740. ActPayDedc float64 `json:"act_pay_dedc"`
  21741. Age float64 `json:"age"`
  21742. Balc float64 `json:"balc"`
  21743. Certno string `json:"certno"`
  21744. ClrOptins string `json:"clr_optins"`
  21745. ClrType string `json:"clr_type"`
  21746. ClrWay string `json:"clr_way"`
  21747. CvlservFlag string `json:"cvlserv_flag"`
  21748. CvlservPay float64 `json:"cvlserv_pay"`
  21749. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21750. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21751. Gend string `json:"gend"`
  21752. HifesPay float64 `json:"hifes_pay"`
  21753. HifmiPay float64 `json:"hifmi_pay"`
  21754. HifpPay float64 `json:"hifp_pay"`
  21755. HospPartAmt float64 `json:"hosp_part_amt"`
  21756. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21757. Insutype string `json:"insutype"`
  21758. MafPay float64 `json:"maf_pay"`
  21759. MdtrtCertType string `json:"mdtrt_cert_type"`
  21760. HifobPay float64 `json:"hifob_pay"`
  21761. MdtrtID string `json:"mdtrt_id"`
  21762. MedType string `json:"med_type"`
  21763. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21764. MedinsSetlID string `json:"medins_setl_id"`
  21765. Naty string `json:"naty"`
  21766. OthPay float64 `json:"oth_pay"`
  21767. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21768. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21769. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21770. PsnCashPay float64 `json:"psn_cash_pay"`
  21771. PsnCertType string `json:"psn_cert_type"`
  21772. PsnName string `json:"psn_name"`
  21773. PsnNo string `json:"psn_no"`
  21774. PsnPartAmt float64 `json:"psn_part_amt"`
  21775. PsnType string `json:"psn_type"`
  21776. SetlID string `json:"setl_id"`
  21777. SetlTime string `json:"setl_time"`
  21778. } `json:"setlinfo"`
  21779. Setldetail interface{} `json:"setldetail"`
  21780. } `json:"output"`
  21781. RefmsgTime string `json:"refmsg_time"`
  21782. RespondTime string `json:"respond_time"`
  21783. Signtype interface{} `json:"signtype"`
  21784. WarnMsg interface{} `json:"warn_msg"`
  21785. }
  21786. type ResultSevenAH struct {
  21787. Cainfo string `json:"cainfo"`
  21788. ErrMsg string `json:"err_msg"`
  21789. InfRefmsgid string `json:"inf_refmsgid"`
  21790. Infcode int64 `json:"infcode"`
  21791. Output struct {
  21792. Setlinfo struct {
  21793. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21794. AcctPay float64 `json:"acct_pay"`
  21795. ActPayDedc float64 `json:"act_pay_dedc"`
  21796. Age float64 `json:"age"`
  21797. Balc float64 `json:"balc"`
  21798. Certno string `json:"certno"`
  21799. ClrOptins string `json:"clr_optins"`
  21800. ClrType string `json:"clr_type"`
  21801. ClrWay string `json:"clr_way"`
  21802. CvlservFlag string `json:"cvlserv_flag"`
  21803. CvlservPay float64 `json:"cvlserv_pay"`
  21804. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21805. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21806. Gend string `json:"gend"`
  21807. HifesPay float64 `json:"hifes_pay"`
  21808. HifmiPay float64 `json:"hifmi_pay"`
  21809. HifpPay float64 `json:"hifp_pay"`
  21810. HospPartAmt float64 `json:"hosp_part_amt"`
  21811. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21812. Insutype string `json:"insutype"`
  21813. MafPay float64 `json:"maf_pay"`
  21814. MdtrtCertType string `json:"mdtrt_cert_type"`
  21815. HifobPay float64 `json:"hifob_pay"`
  21816. MdtrtID string `json:"mdtrt_id"`
  21817. MedType string `json:"med_type"`
  21818. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21819. MedinsSetlID string `json:"medins_setl_id"`
  21820. Naty string `json:"naty"`
  21821. OthPay float64 `json:"oth_pay"`
  21822. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21823. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21824. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21825. PsnCashPay float64 `json:"psn_cash_pay"`
  21826. PsnCertType string `json:"psn_cert_type"`
  21827. PsnName string `json:"psn_name"`
  21828. PsnNo string `json:"psn_no"`
  21829. PsnPartAmt float64 `json:"psn_part_amt"`
  21830. PsnType string `json:"psn_type"`
  21831. SetlID string `json:"setl_id"`
  21832. SetlTime int64 `json:"setl_time"`
  21833. } `json:"setlinfo"`
  21834. Setldetail interface{} `json:"setldetail"`
  21835. } `json:"output"`
  21836. RefmsgTime string `json:"refmsg_time"`
  21837. RespondTime string `json:"respond_time"`
  21838. Signtype interface{} `json:"signtype"`
  21839. WarnMsg interface{} `json:"warn_msg"`
  21840. }
  21841. type ResultSeven10265 struct {
  21842. Cainfo string `json:"cainfo"`
  21843. ErrMsg string `json:"err_msg"`
  21844. InfRefmsgid string `json:"inf_refmsgid"`
  21845. Infcode string `json:"infcode"`
  21846. Output struct {
  21847. Setlinfo struct {
  21848. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21849. AcctPay float64 `json:"acct_pay"`
  21850. ActPayDedc float64 `json:"act_pay_dedc"`
  21851. Age float64 `json:"age"`
  21852. Balc float64 `json:"balc"`
  21853. Certno string `json:"certno"`
  21854. ClrOptins string `json:"clr_optins"`
  21855. ClrType string `json:"clr_type"`
  21856. ClrWay string `json:"clr_way"`
  21857. CvlservFlag string `json:"cvlserv_flag"`
  21858. CvlservPay float64 `json:"cvlserv_pay"`
  21859. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21860. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21861. Gend string `json:"gend"`
  21862. HifesPay float64 `json:"hifes_pay"`
  21863. HifmiPay float64 `json:"hifmi_pay"`
  21864. HifpPay float64 `json:"hifp_pay"`
  21865. HospPartAmt float64 `json:"hosp_part_amt"`
  21866. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21867. Insutype string `json:"insutype"`
  21868. MafPay float64 `json:"maf_pay"`
  21869. MdtrtCertType string `json:"mdtrt_cert_type"`
  21870. HifobPay float64 `json:"hifob_pay"`
  21871. MdtrtID string `json:"mdtrt_id"`
  21872. MedType string `json:"med_type"`
  21873. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21874. MedinsSetlID string `json:"medins_setl_id"`
  21875. Naty string `json:"naty"`
  21876. OthPay float64 `json:"oth_pay"`
  21877. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21878. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  21879. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21880. PsnCashPay float64 `json:"psn_cash_pay"`
  21881. PsnCertType string `json:"psn_cert_type"`
  21882. PsnName string `json:"psn_name"`
  21883. PsnNo string `json:"psn_no"`
  21884. PsnPartAmt float64 `json:"psn_part_amt"`
  21885. PsnType string `json:"psn_type"`
  21886. SetlID string `json:"setl_id"`
  21887. SetlTime string `json:"setl_time"`
  21888. } `json:"setlinfo"`
  21889. Setldetail interface{} `json:"setldetail"`
  21890. } `json:"output"`
  21891. RefmsgTime string `json:"refmsg_time"`
  21892. RespondTime string `json:"respond_time"`
  21893. Signtype interface{} `json:"signtype"`
  21894. WarnMsg interface{} `json:"warn_msg"`
  21895. }
  21896. type ResultSeven10265Two struct {
  21897. Cainfo string `json:"cainfo"`
  21898. ErrMsg string `json:"err_msg"`
  21899. InfRefmsgid string `json:"inf_refmsgid"`
  21900. Infcode string `json:"infcode"`
  21901. Output struct {
  21902. Setlinfo struct {
  21903. AcctMulaidPay string `json:"acct_mulaid_pay"`
  21904. AcctPay float64 `json:"acct_pay"`
  21905. ActPayDedc float64 `json:"act_pay_dedc"`
  21906. Age float64 `json:"age"`
  21907. Balc float64 `json:"balc"`
  21908. Certno string `json:"certno"`
  21909. ClrOptins string `json:"clr_optins"`
  21910. ClrType string `json:"clr_type"`
  21911. ClrWay string `json:"clr_way"`
  21912. CvlservFlag string `json:"cvlserv_flag"`
  21913. CvlservPay float64 `json:"cvlserv_pay"`
  21914. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21915. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21916. Gend string `json:"gend"`
  21917. HifesPay float64 `json:"hifes_pay"`
  21918. HifmiPay float64 `json:"hifmi_pay"`
  21919. HifpPay float64 `json:"hifp_pay"`
  21920. HospPartAmt string `json:"hosp_part_amt"`
  21921. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21922. Insutype string `json:"insutype"`
  21923. MafPay float64 `json:"maf_pay"`
  21924. MdtrtCertType string `json:"mdtrt_cert_type"`
  21925. HifobPay float64 `json:"hifob_pay"`
  21926. MdtrtID string `json:"mdtrt_id"`
  21927. MedType string `json:"med_type"`
  21928. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21929. MedinsSetlID string `json:"medins_setl_id"`
  21930. Naty string `json:"naty"`
  21931. OthPay float64 `json:"oth_pay"`
  21932. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21933. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21934. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21935. PsnCashPay float64 `json:"psn_cash_pay"`
  21936. PsnCertType string `json:"psn_cert_type"`
  21937. PsnName string `json:"psn_name"`
  21938. PsnNo string `json:"psn_no"`
  21939. PsnPartAmt float64 `json:"psn_part_amt"`
  21940. PsnType string `json:"psn_type"`
  21941. SetlID string `json:"setl_id"`
  21942. SetlTime string `json:"setl_time"`
  21943. } `json:"setlinfo"`
  21944. Setldetail interface{} `json:"setldetail"`
  21945. } `json:"output"`
  21946. RefmsgTime string `json:"refmsg_time"`
  21947. RespondTime string `json:"respond_time"`
  21948. Signtype interface{} `json:"signtype"`
  21949. WarnMsg interface{} `json:"warn_msg"`
  21950. }
  21951. type GZResultSeven10265Two struct {
  21952. Cainfo string `json:"cainfo"`
  21953. ErrMsg string `json:"err_msg"`
  21954. InfRefmsgid string `json:"inf_refmsgid"`
  21955. Infcode int64 `json:"infcode"`
  21956. Output struct {
  21957. Setlinfo struct {
  21958. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21959. AcctPay float64 `json:"acct_pay"`
  21960. ActPayDedc float64 `json:"act_pay_dedc"`
  21961. Age float64 `json:"age"`
  21962. Balc float64 `json:"balc"`
  21963. Certno string `json:"certno"`
  21964. ClrOptins string `json:"clr_optins"`
  21965. ClrType string `json:"clr_type"`
  21966. ClrWay string `json:"clr_way"`
  21967. CvlservFlag string `json:"cvlserv_flag"`
  21968. CvlservPay float64 `json:"cvlserv_pay"`
  21969. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21970. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21971. Gend string `json:"gend"`
  21972. HifesPay float64 `json:"hifes_pay"`
  21973. HifmiPay float64 `json:"hifmi_pay"`
  21974. HifpPay float64 `json:"hifp_pay"`
  21975. HospPartAmt float64 `json:"hosp_part_amt"`
  21976. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21977. Insutype string `json:"insutype"`
  21978. MafPay float64 `json:"maf_pay"`
  21979. MdtrtCertType string `json:"mdtrt_cert_type"`
  21980. HifobPay float64 `json:"hifob_pay"`
  21981. MdtrtID string `json:"mdtrt_id"`
  21982. MedType string `json:"med_type"`
  21983. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21984. MedinsSetlID string `json:"medins_setl_id"`
  21985. Naty string `json:"naty"`
  21986. OthPay float64 `json:"oth_pay"`
  21987. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21988. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  21989. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21990. PsnCashPay float64 `json:"psn_cash_pay"`
  21991. PsnCertType string `json:"psn_cert_type"`
  21992. PsnName string `json:"psn_name"`
  21993. PsnNo string `json:"psn_no"`
  21994. PsnPartAmt float64 `json:"psn_part_amt"`
  21995. PsnType string `json:"psn_type"`
  21996. SetlID string `json:"setl_id"`
  21997. SetlTime string `json:"setl_time"`
  21998. } `json:"setlinfo"`
  21999. Setldetail interface{} `json:"setldetail"`
  22000. } `json:"output"`
  22001. RefmsgTime string `json:"refmsg_time"`
  22002. RespondTime string `json:"respond_time"`
  22003. Signtype interface{} `json:"signtype"`
  22004. WarnMsg interface{} `json:"warn_msg"`
  22005. }
  22006. type ResultEight struct {
  22007. Cainfo string `json:"cainfo"`
  22008. ErrMsg string `json:"err_msg"`
  22009. InfRefmsgid string `json:"inf_refmsgid"`
  22010. Infcode int64 `json:"infcode"`
  22011. Output struct {
  22012. Stmtinfo struct {
  22013. SetlOptins string `json:"setl_optins"`
  22014. StmtRslt string `json:"stmt_rslt"`
  22015. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  22016. } `json:"stmtinfo"`
  22017. } `json:"output"`
  22018. RefmsgTime string `json:"refmsg_time"`
  22019. RespondTime string `json:"respond_time"`
  22020. Signtype interface{} `json:"signtype"`
  22021. WarnMsg interface{} `json:"warn_msg"`
  22022. }
  22023. type ResultEightFor10188 struct {
  22024. Cainfo string `json:"cainfo"`
  22025. ErrMsg string `json:"err_msg"`
  22026. InfRefmsgid string `json:"inf_refmsgid"`
  22027. Infcode string `json:"infcode"`
  22028. Output struct {
  22029. Stmtinfo struct {
  22030. SetlOptins string `json:"setl_optins"`
  22031. StmtRslt string `json:"stmt_rslt"`
  22032. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  22033. } `json:"stmtinfo"`
  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 ResultNine 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. FileQuryNo string `json:"file_qury_no"`
  22047. } `json:"output"`
  22048. RefmsgTime string `json:"refmsg_time"`
  22049. RespondTime string `json:"respond_time"`
  22050. Signtype interface{} `json:"signtype"`
  22051. WarnMsg interface{} `json:"warn_msg"`
  22052. }
  22053. type ResultTen struct {
  22054. Cainfo string `json:"cainfo"`
  22055. ErrMsg string `json:"err_msg"`
  22056. InfRefmsgid string `json:"inf_refmsgid"`
  22057. Infcode int64 `json:"infcode"`
  22058. Output struct {
  22059. Fileinfo struct {
  22060. DldEndtime string `json:"dld_endtime"`
  22061. FileQuryNo string `json:"file_qury_no"`
  22062. Filename string `json:"filename"`
  22063. } `json:"fileinfo"`
  22064. } `json:"output"`
  22065. RefmsgTime string `json:"refmsg_time"`
  22066. RespondTime string `json:"respond_time"`
  22067. Signtype interface{} `json:"signtype"`
  22068. WarnMsg interface{} `json:"warn_msg"`
  22069. }
  22070. type Result5262 struct {
  22071. ErrMsg string `json:"err_msg"`
  22072. InfRefmsgid string `json:"inf_refmsgid"`
  22073. Infcode int64 `json:"infcode"`
  22074. Output struct {
  22075. PageInfo struct {
  22076. Size int `json:"size"`
  22077. RecordCounts int `json:"record_counts"`
  22078. } `json:"page_info"`
  22079. Idetinfo []interface{} `json:"idetinfo"`
  22080. Result []struct {
  22081. SetlID string `json:"setl_id"`
  22082. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22083. MdtrtID string `json:"mdtrt_id"`
  22084. InitSetlID string `json:"init_setl_id,omitempty"`
  22085. PsnNo string `json:"psn_no"`
  22086. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22087. PsnName string `json:"psn_name"`
  22088. PsnCertType string `json:"psn_cert_type"`
  22089. Certno string `json:"certno"`
  22090. Gend string `json:"gend,omitempty"`
  22091. Naty string `json:"naty,omitempty"`
  22092. Brdy string `json:"brdy,omitempty"`
  22093. Age float64 `json:"age,omitempty"`
  22094. Insutype string `json:"insutype,omitempty"`
  22095. PsnType string `json:"psn_type"`
  22096. CvlservFlag string `json:"cvlserv_flag"`
  22097. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22098. SpPsnType string `json:"sp_psn_type,omitempty"`
  22099. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22100. ClctGrde string `json:"clct_grde,omitempty"`
  22101. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22102. NwbFlag string `json:"nwb_flag,omitempty"`
  22103. InsuAdmdvs string `json:"insu_admdvs"`
  22104. EmpNo string `json:"emp_no,omitempty"`
  22105. EmpName string `json:"emp_name,omitempty"`
  22106. EmpType string `json:"emp_type,omitempty"`
  22107. EconType string `json:"econ_type,omitempty"`
  22108. AfilIndu string `json:"afil_indu,omitempty"`
  22109. AfilRlts string `json:"afil_rlts,omitempty"`
  22110. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22111. PayLoc string `json:"pay_loc,omitempty"`
  22112. FixmedinsCode string `json:"fixmedins_code"`
  22113. FixmedinsName string `json:"fixmedins_name"`
  22114. HospLv string `json:"hosp_lv,omitempty"`
  22115. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22116. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22117. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22118. Begndate string `json:"begndate"`
  22119. Enddate string `json:"enddate"`
  22120. SetlTime string `json:"setl_time"`
  22121. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22122. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22123. MedType string `json:"med_type"`
  22124. SetlType string `json:"setl_type,omitempty"`
  22125. ClrType string `json:"clr_type,omitempty"`
  22126. ClrWay string `json:"clr_way,omitempty"`
  22127. PsnSetlway string `json:"psn_setlway,omitempty"`
  22128. ClrOptins string `json:"clr_optins,omitempty"`
  22129. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22130. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22131. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22132. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22133. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22134. DedcStd float64 `json:"dedc_std,omitempty"`
  22135. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22136. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22137. HifpPay float64 `json:"hifp_pay,omitempty"`
  22138. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22139. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22140. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22141. HifesPay float64 `json:"hifes_pay,omitempty"`
  22142. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22143. HifobPay float64 `json:"hifob_pay,omitempty"`
  22144. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22145. MafPay float64 `json:"maf_pay,omitempty"`
  22146. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22147. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22148. PsnPay float64 `json:"psn_pay,omitempty"`
  22149. AcctPay float64 `json:"acct_pay,omitempty"`
  22150. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22151. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22152. Balc float64 `json:"balc,omitempty"`
  22153. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22154. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22155. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22156. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22157. Year string `json:"year,omitempty"`
  22158. DiseNo string `json:"dise_no,omitempty"`
  22159. DiseName string `json:"dise_name,omitempty"`
  22160. Invono string `json:"invono,omitempty"`
  22161. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22162. ValiFlag string `json:"vali_flag,omitempty"`
  22163. Memo string `json:"memo,omitempty"`
  22164. Rid string `json:"rid"`
  22165. UpdtTime string `json:"updt_time,omitempty"`
  22166. CrterID string `json:"crter_id,omitempty"`
  22167. CrterName string `json:"crter_name,omitempty"`
  22168. CrteTime string `json:"crte_time,omitempty"`
  22169. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  22170. OpterID string `json:"opter_id,omitempty"`
  22171. OpterName string `json:"opter_name,omitempty"`
  22172. OptTime string `json:"opt_time,omitempty"`
  22173. OptinsNo string `json:"optins_no,omitempty"`
  22174. PoolareaNo string `json:"poolarea_no,omitempty"`
  22175. } `json:"result"`
  22176. } `json:"output"`
  22177. RefmsgTime string `json:"refmsg_time"`
  22178. RespondTime string `json:"respond_time"`
  22179. Signtype interface{} `json:"signtype"`
  22180. WarnInfo interface{} `json:"warn_info"`
  22181. }
  22182. type Result5267 struct {
  22183. ErrMsg string `json:"err_msg"`
  22184. InfRefmsgid string `json:"inf_refmsgid"`
  22185. Infcode int64 `json:"infcode"`
  22186. Output struct {
  22187. PageInfo struct {
  22188. Size int `json:"size"`
  22189. RecordCounts int `json:"record_counts"`
  22190. } `json:"pageinfo"`
  22191. Result []struct {
  22192. SetlID string `json:"setl_id"`
  22193. ClrOptins string `json:"clr_optins"`
  22194. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  22195. MdtrtID string `json:"mdtrt_id"`
  22196. InitSetlID string `json:"init_setl_id,omitempty"`
  22197. PsnNo string `json:"psn_no"`
  22198. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  22199. PsnName string `json:"psn_name"`
  22200. PsnCertType string `json:"psn_cert_type"`
  22201. Certno string `json:"certno"`
  22202. Gend string `json:"gend,omitempty"`
  22203. Naty string `json:"naty,omitempty"`
  22204. Brdy string `json:"brdy,omitempty"`
  22205. Age float64 `json:"age,omitempty"`
  22206. Insutype string `json:"insutype,omitempty"`
  22207. PsnType string `json:"psn_type"`
  22208. CvlservFlag string `json:"cvlserv_flag"`
  22209. CvlservLv string `json:"cvlserv_lv,omitempty"`
  22210. SpPsnType string `json:"sp_psn_type,omitempty"`
  22211. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  22212. ClctGrde string `json:"clct_grde,omitempty"`
  22213. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  22214. NwbFlag string `json:"nwb_flag,omitempty"`
  22215. InsuAdmdvs string `json:"insu_admdvs"`
  22216. EmpNo string `json:"emp_no,omitempty"`
  22217. EmpName string `json:"emp_name,omitempty"`
  22218. EmpType string `json:"emp_type,omitempty"`
  22219. EconType string `json:"econ_type,omitempty"`
  22220. AfilIndu string `json:"afil_indu,omitempty"`
  22221. AfilRlts string `json:"afil_rlts,omitempty"`
  22222. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  22223. PayLoc string `json:"pay_loc,omitempty"`
  22224. FixmedinsCode string `json:"fixmedins_code"`
  22225. FixmedinsName string `json:"fixmedins_name"`
  22226. HospLv string `json:"hosp_lv,omitempty"`
  22227. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  22228. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  22229. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  22230. Begndate string `json:"begndate,omitempty"`
  22231. Enddate string `json:"enddate,omitempty"`
  22232. SetlTime string `json:"setl_time,omitempty"`
  22233. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  22234. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  22235. MedType string `json:"med_type"`
  22236. SetlType string `json:"setl_type,omitempty"`
  22237. ClrType string `json:"clr_type,omitempty"`
  22238. ClrWay string `json:"clr_way,omitempty"`
  22239. PsnSetlway string `json:"psn_setlway,omitempty"`
  22240. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  22241. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  22242. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  22243. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  22244. InscpAmt float64 `json:"inscp_amt,omitempty"`
  22245. DedcStd float64 `json:"dedc_std,omitempty"`
  22246. CrtDedc float64 `json:"crt_dedc,omitempty"`
  22247. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  22248. HifpPay float64 `json:"hifp_pay,omitempty"`
  22249. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  22250. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  22251. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  22252. HifesPay float64 `json:"hifes_pay,omitempty"`
  22253. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  22254. HifobPay float64 `json:"hifob_pay,omitempty"`
  22255. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  22256. MafPay float64 `json:"maf_pay,omitempty"`
  22257. OthfundPay float64 `json:"othfund_pay,omitempty"`
  22258. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  22259. PsnPay float64 `json:"psn_pay,omitempty"`
  22260. AcctPay float64 `json:"acct_pay,omitempty"`
  22261. CashPayamt float64 `json:"cash_payamt,omitempty"`
  22262. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  22263. Balc float64 `json:"balc,omitempty"`
  22264. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  22265. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  22266. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  22267. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  22268. Year string `json:"year,omitempty"`
  22269. DiseNo string `json:"dise_no,omitempty"`
  22270. DiseName string `json:"dise_name,omitempty"`
  22271. Invono string `json:"invono,omitempty"`
  22272. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  22273. Memo string `json:"memo,omitempty"`
  22274. UpdtTime string `json:"updt_time,omitempty"`
  22275. OpterID string `json:"opter_id,omitempty"`
  22276. OpterName string `json:"opter_name,omitempty"`
  22277. OptTime string `json:"opt_time,omitempty"`
  22278. OptinsNo string `json:"optins_no,omitempty"`
  22279. PoolareaNo string `json:"poolarea_no,omitempty"`
  22280. } `json:"result"`
  22281. } `json:"output"`
  22282. RefmsgTime string `json:"refmsg_time"`
  22283. RespondTime string `json:"respond_time"`
  22284. Signtype interface{} `json:"signtype"`
  22285. WarnInfo interface{} `json:"warn_info"`
  22286. }
  22287. // type Autogenerated struct {
  22288. // Output struct {
  22289. // Setlinfo struct {
  22290. // SetlTime string `json:"setl_time"`
  22291. // CvlservPay float64 `json:"cvlserv_pay"`
  22292. // Year string `json:"year"`
  22293. // MedType string `json:"med_type"`
  22294. // PsnPay float64 `json:"psn_pay"`
  22295. // OpterID string `json:"opter_id"`
  22296. // Begndate string `json:"begndate"`
  22297. // FlxempeFlag string `json:"flxempe_flag"`
  22298. // HifmiPay float64 `json:"hifmi_pay"`
  22299. // PsnNo string `json:"psn_no"`
  22300. // ActPayDedc float64 `json:"act_pay_dedc"`
  22301. // MedinsSetlID interface{} `json:"medins_setl_id"`
  22302. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22303. // ClrWay string `json:"clr_way"`
  22304. // OthPay float64 `json:"oth_pay"`
  22305. // Gend string `json:"gend"`
  22306. // MdtrtID string `json:"mdtrt_id"`
  22307. // AcctPay float64 `json:"acct_pay"`
  22308. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  22309. // Insutype string `json:"insutype"`
  22310. // Invono interface{} `json:"invono"`
  22311. // Enddate string `json:"enddate"`
  22312. // CashPayamt float64 `json:"cash_payamt"`
  22313. // PsnType string `json:"psn_type"`
  22314. // FixmedinsName string `json:"fixmedins_name"`
  22315. // HifpPay float64 `json:"hifp_pay"`
  22316. // NewFlag interface{} `json:"new_flag"`
  22317. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22318. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  22319. // PayLoc string `json:"pay_loc"`
  22320. // ClrType string `json:"clr_type"`
  22321. // RefdSetlFlag string `json:"refd_setl_flag"`
  22322. // CvlservFlag string `json:"cvlserv_flag"`
  22323. // EmpName string `json:"emp_name"`
  22324. // Brdy string `json:"brdy"`
  22325. // Naty string `json:"naty"`
  22326. // Certno string `json:"certno"`
  22327. // DiseCode string `json:"dise_code"`
  22328. // FixmedinsCode string `json:"fixmedins_code"`
  22329. // DedcHospLv string `json:"dedc_hosp_lv"`
  22330. // OpterName string `json:"opter_name"`
  22331. // Balc float64 `json:"balc"`
  22332. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22333. // PsnCertType string `json:"psn_cert_type"`
  22334. // HifobPay float64 `json:"hifob_pay"`
  22335. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  22336. // HifesPay float64 `json:"hifes_pay"`
  22337. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22338. // OptTime string `json:"opt_time"`
  22339. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22340. // SetlID string `json:"setl_id"`
  22341. // MafPay float64 `json:"maf_pay"`
  22342. // PsnName string `json:"psn_name"`
  22343. // InsuOptins interface{} `json:"insu_optins"`
  22344. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22345. // ClrOptins string `json:"clr_optins"`
  22346. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22347. // DiseName string `json:"dise_name"`
  22348. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22349. // Age float64 `json:"age"`
  22350. // DtrtCertType string `json:"dtrt_cert_type"`
  22351. // HospLv string `json:"hosp_lv"`
  22352. // } `json:"setlinfo"`
  22353. // Setldetail []struct {
  22354. // FundPayType string `json:"fund_pay_type"`
  22355. // FundPayamt float64 `json:"fund_payamt"`
  22356. // SetlProcInfo interface{} `json:"setl_proc_info"`
  22357. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  22358. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  22359. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  22360. // PrefFundPay interface{} `json:"pref_fund_pay"`
  22361. // } `json:"setldetail"`
  22362. // } `json:"output"`
  22363. // Infcode int `json:"infcode"`
  22364. // WarnMsg interface{} `json:"warn_msg"`
  22365. // Cainfo interface{} `json:"cainfo"`
  22366. // ErrMsg interface{} `json:"err_msg"`
  22367. // RefmsgTime string `json:"refmsg_time"`
  22368. // Signtype interface{} `json:"signtype"`
  22369. // RespondTime string `json:"respond_time"`
  22370. // InfRefmsgid string `json:"inf_refmsgid"`
  22371. // }
  22372. type Result002 struct {
  22373. Cainfo interface{} `json:"cainfo"`
  22374. ErrMsg string `json:"err_msg"`
  22375. InfRefmsgid string `json:"inf_refmsgid"`
  22376. Infcode int64 `json:"infcode"`
  22377. Output struct {
  22378. RxFile string `json:"rx_file"`
  22379. SignDigest string `json:"sign_digest"`
  22380. SignCertSn string `json:"sign_cert_sn"`
  22381. SignCertDn string `json:"sign_cert_dn"`
  22382. } `json:"output"`
  22383. RefmsgTime string `json:"refmsg_time"`
  22384. RespondTime string `json:"respond_time"`
  22385. Signtype interface{} `json:"signtype"`
  22386. WarnMsg interface{} `json:"warn_msg"`
  22387. }
  22388. type Result003 struct {
  22389. Cainfo interface{} `json:"cainfo"`
  22390. ErrMsg string `json:"err_msg"`
  22391. InfRefmsgid string `json:"inf_refmsgid"`
  22392. Infcode int64 `json:"infcode"`
  22393. Output struct {
  22394. HiRxno string `json:"hi_rxno"`
  22395. RxStasCodg string `json:"rx_stas_codg"`
  22396. RxStasName string `json:"rx_stas_name"`
  22397. } `json:"output"`
  22398. RefmsgTime string `json:"refmsg_time"`
  22399. RespondTime string `json:"respond_time"`
  22400. Signtype interface{} `json:"signtype"`
  22401. WarnMsg interface{} `json:"warn_msg"`
  22402. }
  22403. type ResultEleven struct {
  22404. Cainfo string `json:"cainfo"`
  22405. ErrMsg string `json:"err_msg"`
  22406. InfRefmsgid string `json:"inf_refmsgid"`
  22407. Infcode int64 `json:"infcode"`
  22408. Output struct {
  22409. Setlinfo struct {
  22410. SetlTime string `json:"setl_time"`
  22411. CvlservPay float64 `json:"cvlserv_pay"`
  22412. Year string `json:"year"`
  22413. MedType string `json:"med_type"`
  22414. PsnPay float64 `json:"psn_pay"`
  22415. OpterID string `json:"opter_id"`
  22416. Begndate string `json:"begndate"`
  22417. FlxempeFlag string `json:"flxempe_flag"`
  22418. HifmiPay float64 `json:"hifmi_pay"`
  22419. PsnNo string `json:"psn_no"`
  22420. ActPayDedc float64 `json:"act_pay_dedc"`
  22421. MedinsSetlID interface{} `json:"medins_setl_id"`
  22422. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22423. ClrWay string `json:"clr_way"`
  22424. OthPay float64 `json:"oth_pay"`
  22425. Gend string `json:"gend"`
  22426. MdtrtID string `json:"mdtrt_id"`
  22427. AcctPay float64 `json:"acct_pay"`
  22428. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22429. Insutype string `json:"insutype"`
  22430. Invono interface{} `json:"invono"`
  22431. Enddate string `json:"enddate"`
  22432. CashPayamt float64 `json:"cash_payamt"`
  22433. PsnType string `json:"psn_type"`
  22434. FixmedinsName string `json:"fixmedins_name"`
  22435. HifpPay float64 `json:"hifp_pay"`
  22436. NewFlag interface{} `json:"new_flag"`
  22437. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22438. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22439. PayLoc string `json:"pay_loc"`
  22440. ClrType string `json:"clr_type"`
  22441. RefdSetlFlag string `json:"refd_setl_flag"`
  22442. CvlservFlag string `json:"cvlserv_flag"`
  22443. EmpName string `json:"emp_name"`
  22444. Brdy string `json:"brdy"`
  22445. Naty string `json:"naty"`
  22446. Certno string `json:"certno"`
  22447. DiseCode string `json:"dise_code"`
  22448. FixmedinsCode string `json:"fixmedins_code"`
  22449. DedcHospLv string `json:"dedc_hosp_lv"`
  22450. OpterName string `json:"opter_name"`
  22451. Balc float64 `json:"balc"`
  22452. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22453. PsnCertType string `json:"psn_cert_type"`
  22454. HifobPay float64 `json:"hifob_pay"`
  22455. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22456. HifesPay float64 `json:"hifes_pay"`
  22457. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22458. OptTime string `json:"opt_time"`
  22459. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22460. SetlID string `json:"setl_id"`
  22461. MafPay float64 `json:"maf_pay"`
  22462. PsnName string `json:"psn_name"`
  22463. InsuOptins interface{} `json:"insu_optins"`
  22464. PrefFundPay interface{} `json:"pref_fund_pay"`
  22465. ClrOptins string `json:"clr_optins"`
  22466. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22467. DiseName string `json:"dise_name"`
  22468. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22469. Age float64 `json:"age"`
  22470. DtrtCertType string `json:"dtrt_cert_type"`
  22471. HospLv string `json:"hosp_lv"`
  22472. PsnCashPay float64 `json:"psn_cash_pay"`
  22473. } `json:"setlinfo"`
  22474. } `json:"output"`
  22475. RefmsgTime string `json:"refmsg_time"`
  22476. RespondTime string `json:"respond_time"`
  22477. Signtype interface{} `json:"signtype"`
  22478. WarnMsg interface{} `json:"warn_msg"`
  22479. }
  22480. type ResultElevenah struct {
  22481. Cainfo string `json:"cainfo"`
  22482. ErrMsg string `json:"err_msg"`
  22483. InfRefmsgid string `json:"inf_refmsgid"`
  22484. Infcode int64 `json:"infcode"`
  22485. Output struct {
  22486. Setlinfo struct {
  22487. SetlTime int64 `json:"setl_time"`
  22488. CvlservPay float64 `json:"cvlserv_pay"`
  22489. Year string `json:"year"`
  22490. MedType string `json:"med_type"`
  22491. PsnPay float64 `json:"psn_pay"`
  22492. OpterID string `json:"opter_id"`
  22493. Begndate int64 `json:"begndate"`
  22494. FlxempeFlag string `json:"flxempe_flag"`
  22495. HifmiPay float64 `json:"hifmi_pay"`
  22496. PsnNo string `json:"psn_no"`
  22497. ActPayDedc float64 `json:"act_pay_dedc"`
  22498. MedinsSetlID interface{} `json:"medins_setl_id"`
  22499. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22500. ClrWay string `json:"clr_way"`
  22501. OthPay float64 `json:"oth_pay"`
  22502. Gend string `json:"gend"`
  22503. MdtrtID string `json:"mdtrt_id"`
  22504. AcctPay float64 `json:"acct_pay"`
  22505. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22506. Insutype string `json:"insutype"`
  22507. Invono interface{} `json:"invono"`
  22508. Enddate int64 `json:"enddate"`
  22509. CashPayamt float64 `json:"cash_payamt"`
  22510. PsnType string `json:"psn_type"`
  22511. FixmedinsName string `json:"fixmedins_name"`
  22512. HifpPay float64 `json:"hifp_pay"`
  22513. NewFlag interface{} `json:"new_flag"`
  22514. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22515. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22516. PayLoc string `json:"pay_loc"`
  22517. ClrType string `json:"clr_type"`
  22518. RefdSetlFlag string `json:"refd_setl_flag"`
  22519. CvlservFlag string `json:"cvlserv_flag"`
  22520. EmpName string `json:"emp_name"`
  22521. Brdy int64 `json:"brdy"`
  22522. Naty string `json:"naty"`
  22523. Certno string `json:"certno"`
  22524. DiseCode string `json:"dise_code"`
  22525. FixmedinsCode string `json:"fixmedins_code"`
  22526. DedcHospLv string `json:"dedc_hosp_lv"`
  22527. OpterName string `json:"opter_name"`
  22528. Balc float64 `json:"balc"`
  22529. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22530. PsnCertType string `json:"psn_cert_type"`
  22531. HifobPay float64 `json:"hifob_pay"`
  22532. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22533. HifesPay float64 `json:"hifes_pay"`
  22534. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22535. OptTime int64 `json:"opt_time"`
  22536. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22537. SetlID string `json:"setl_id"`
  22538. MafPay float64 `json:"maf_pay"`
  22539. PsnName string `json:"psn_name"`
  22540. InsuOptins interface{} `json:"insu_optins"`
  22541. PrefFundPay interface{} `json:"pref_fund_pay"`
  22542. ClrOptins string `json:"clr_optins"`
  22543. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22544. DiseName string `json:"dise_name"`
  22545. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22546. Age float64 `json:"age"`
  22547. DtrtCertType string `json:"dtrt_cert_type"`
  22548. HospLv string `json:"hosp_lv"`
  22549. PsnCashPay float64 `json:"psn_cash_pay"`
  22550. } `json:"setlinfo"`
  22551. } `json:"output"`
  22552. RefmsgTime string `json:"refmsg_time"`
  22553. RespondTime string `json:"respond_time"`
  22554. Signtype interface{} `json:"signtype"`
  22555. WarnMsg interface{} `json:"warn_msg"`
  22556. }
  22557. type ResultEleven10265 struct {
  22558. Cainfo string `json:"cainfo"`
  22559. ErrMsg string `json:"err_msg"`
  22560. InfRefmsgid string `json:"inf_refmsgid"`
  22561. Infcode string `json:"infcode"`
  22562. Output struct {
  22563. Setlinfo struct {
  22564. SetlTime string `json:"setl_time"`
  22565. CvlservPay float64 `json:"cvlserv_pay"`
  22566. Year string `json:"year"`
  22567. MedType string `json:"med_type"`
  22568. PsnPay float64 `json:"psn_pay"`
  22569. OpterID string `json:"opter_id"`
  22570. Begndate string `json:"begndate"`
  22571. FlxempeFlag string `json:"flxempe_flag"`
  22572. HifmiPay float64 `json:"hifmi_pay"`
  22573. PsnNo string `json:"psn_no"`
  22574. ActPayDedc float64 `json:"act_pay_dedc"`
  22575. MedinsSetlID interface{} `json:"medins_setl_id"`
  22576. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  22577. ClrWay string `json:"clr_way"`
  22578. OthPay float64 `json:"oth_pay"`
  22579. Gend string `json:"gend"`
  22580. MdtrtID string `json:"mdtrt_id"`
  22581. AcctPay float64 `json:"acct_pay"`
  22582. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22583. Insutype string `json:"insutype"`
  22584. Invono interface{} `json:"invono"`
  22585. Enddate string `json:"enddate"`
  22586. CashPayamt float64 `json:"cash_payamt"`
  22587. PsnType string `json:"psn_type"`
  22588. FixmedinsName string `json:"fixmedins_name"`
  22589. HifpPay float64 `json:"hifp_pay"`
  22590. NewFlag interface{} `json:"new_flag"`
  22591. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22592. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22593. PayLoc string `json:"pay_loc"`
  22594. ClrType string `json:"clr_type"`
  22595. RefdSetlFlag string `json:"refd_setl_flag"`
  22596. CvlservFlag string `json:"cvlserv_flag"`
  22597. EmpName string `json:"emp_name"`
  22598. Brdy string `json:"brdy"`
  22599. Naty string `json:"naty"`
  22600. Certno string `json:"certno"`
  22601. DiseCode string `json:"dise_code"`
  22602. FixmedinsCode string `json:"fixmedins_code"`
  22603. DedcHospLv string `json:"dedc_hosp_lv"`
  22604. OpterName string `json:"opter_name"`
  22605. Balc float64 `json:"balc"`
  22606. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  22607. PsnCertType string `json:"psn_cert_type"`
  22608. HifobPay float64 `json:"hifob_pay"`
  22609. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22610. HifesPay float64 `json:"hifes_pay"`
  22611. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22612. OptTime string `json:"opt_time"`
  22613. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22614. SetlID string `json:"setl_id"`
  22615. MafPay float64 `json:"maf_pay"`
  22616. PsnName string `json:"psn_name"`
  22617. InsuOptins interface{} `json:"insu_optins"`
  22618. PrefFundPay interface{} `json:"pref_fund_pay"`
  22619. ClrOptins string `json:"clr_optins"`
  22620. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22621. DiseName string `json:"dise_name"`
  22622. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  22623. Age float64 `json:"age"`
  22624. DtrtCertType string `json:"dtrt_cert_type"`
  22625. HospLv string `json:"hosp_lv"`
  22626. PsnCashPay float64 `json:"psn_cash_pay"`
  22627. } `json:"setlinfo"`
  22628. } `json:"output"`
  22629. RefmsgTime string `json:"refmsg_time"`
  22630. RespondTime string `json:"respond_time"`
  22631. Signtype interface{} `json:"signtype"`
  22632. WarnMsg interface{} `json:"warn_msg"`
  22633. }
  22634. type ResultTwelve struct {
  22635. Cainfo string `json:"cainfo"`
  22636. ErrMsg string `json:"err_msg"`
  22637. InfRefmsgid string `json:"inf_refmsgid"`
  22638. Infcode int64 `json:"infcode"`
  22639. Output struct {
  22640. MdtrtId string `json:"mdtrt_id"`
  22641. ChrgBchno string `json:"chrg_bchno"`
  22642. PsnNo string `json:"psn_no"`
  22643. } `json:"output"`
  22644. RefmsgTime string `json:"refmsg_time"`
  22645. RespondTime string `json:"respond_time"`
  22646. Signtype interface{} `json:"signtype"`
  22647. WarnMsg interface{} `json:"warn_msg"`
  22648. }
  22649. type ResultThirteen struct {
  22650. ErrMsg string `json:"err_msg"`
  22651. InfRefmsgid string `json:"inf_refmsgid"`
  22652. Infcode int64 `json:"infcode"`
  22653. Output struct {
  22654. Result struct {
  22655. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22656. } `json:"result"`
  22657. } `json:"output"`
  22658. RefmsgTime string `json:"refmsg_time"`
  22659. RespondTime string `json:"respond_time"`
  22660. Signtype interface{} `json:"signtype"`
  22661. WarnInfo interface{} `json:"warn_info"`
  22662. }
  22663. type ResultThirteen10265 struct {
  22664. ErrMsg string `json:"err_msg"`
  22665. InfRefmsgid string `json:"inf_refmsgid"`
  22666. Infcode string `json:"infcode"`
  22667. Output struct {
  22668. Result struct {
  22669. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  22670. } `json:"result"`
  22671. } `json:"output"`
  22672. RefmsgTime string `json:"refmsg_time"`
  22673. RespondTime string `json:"respond_time"`
  22674. Signtype interface{} `json:"signtype"`
  22675. WarnInfo interface{} `json:"warn_info"`
  22676. }
  22677. type ResultFourteen struct {
  22678. ErrMsg string `json:"err_msg"`
  22679. InfRefmsgid string `json:"inf_refmsgid"`
  22680. Infcode int64 `json:"infcode"`
  22681. Output struct {
  22682. } `json:"output"`
  22683. RefmsgTime string `json:"refmsg_time"`
  22684. RespondTime string `json:"respond_time"`
  22685. Signtype interface{} `json:"signtype"`
  22686. WarnInfo interface{} `json:"warn_info"`
  22687. }
  22688. type ResultCFYLJG001 struct {
  22689. ErrMsg string `json:"err_msg"`
  22690. InfRefmsgid string `json:"inf_refmsgid"`
  22691. Infcode int64 `json:"infcode"`
  22692. Output struct {
  22693. RxTraceCode string `json:"rx_trace_code"`
  22694. HiRxno string `json:"hi_rxno"`
  22695. } `json:"output"`
  22696. RefmsgTime string `json:"refmsg_time"`
  22697. RespondTime string `json:"respond_time"`
  22698. Signtype interface{} `json:"signtype"`
  22699. WarnInfo interface{} `json:"warn_info"`
  22700. }
  22701. type ResultCFYLJG007 struct {
  22702. ErrMsg string `json:"err_msg"`
  22703. InfRefmsgid string `json:"inf_refmsgid"`
  22704. Infcode int64 `json:"infcode"`
  22705. Output struct {
  22706. HiRxno string `json:"hi_rxno"`
  22707. RxStasName string `json:"rx_stas_name"`
  22708. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  22709. Seltdelts []interface{} `json:"seltdelts"`
  22710. RxUsedStasName string `json:"rx_used_stas_name"`
  22711. RxStasCodg string `json:"rx_stas_codg"`
  22712. } `json:"output"`
  22713. RefmsgTime string `json:"refmsg_time"`
  22714. RespondTime string `json:"respond_time"`
  22715. Signtype interface{} `json:"signtype"`
  22716. WarnInfo interface{} `json:"warn_info"`
  22717. }
  22718. type ResultCFYLJG002 struct {
  22719. ErrMsg string `json:"err_msg"`
  22720. InfRefmsgid string `json:"inf_refmsgid"`
  22721. Infcode int64 `json:"infcode"`
  22722. Output struct {
  22723. RxFile string `json:"rx_file"`
  22724. SignDigest string `json:"sign_digest"`
  22725. SignCertSn string `json:"sign_cert_sn"`
  22726. SignCertDn string `json:"sign_cert_dn"`
  22727. } `json:"output"`
  22728. RefmsgTime string `json:"refmsg_time"`
  22729. RespondTime string `json:"respond_time"`
  22730. Signtype interface{} `json:"signtype"`
  22731. WarnInfo interface{} `json:"warn_info"`
  22732. }
  22733. type ResultCFYLJG003 struct {
  22734. ErrMsg string `json:"err_msg"`
  22735. InfRefmsgid string `json:"inf_refmsgid"`
  22736. Infcode int64 `json:"infcode"`
  22737. Output struct {
  22738. HiRxno string `json:"hi_rxno"`
  22739. RxStasCodg string `json:"rx_stas_codg"`
  22740. RxStasName string `json:"rx_stas_name"`
  22741. } `json:"output"`
  22742. RefmsgTime string `json:"refmsg_time"`
  22743. RespondTime string `json:"respond_time"`
  22744. Signtype interface{} `json:"signtype"`
  22745. WarnInfo interface{} `json:"warn_info"`
  22746. }
  22747. type ResultCFYLJG004 struct {
  22748. ErrMsg string `json:"err_msg"`
  22749. InfRefmsgid string `json:"inf_refmsgid"`
  22750. Infcode int64 `json:"infcode"`
  22751. Output struct {
  22752. HiRxno string `json:"hi_rxno"`
  22753. RxStasCodg string `json:"rx_stas_codg"`
  22754. RxStasName string `json:"rx_stas_name"`
  22755. } `json:"output"`
  22756. RefmsgTime string `json:"refmsg_time"`
  22757. RespondTime string `json:"respond_time"`
  22758. Signtype interface{} `json:"signtype"`
  22759. WarnInfo interface{} `json:"warn_info"`
  22760. }
  22761. type ResultCFYLJG008 struct {
  22762. ErrMsg string `json:"err_msg"`
  22763. InfRefmsgid string `json:"inf_refmsgid"`
  22764. Infcode int64 `json:"infcode"`
  22765. Output struct {
  22766. PoolareaNo string `json:"poolareaNo"`
  22767. AdmdvsName string `json:"admdvsName"`
  22768. Count string `json:"count"`
  22769. } `json:"output"`
  22770. RefmsgTime string `json:"refmsg_time"`
  22771. RespondTime string `json:"respond_time"`
  22772. Signtype interface{} `json:"signtype"`
  22773. WarnInfo interface{} `json:"warn_info"`
  22774. }
  22775. type ResultCFYLJG005 struct {
  22776. ErrMsg string `json:"err_msg"`
  22777. InfRefmsgid string `json:"inf_refmsgid"`
  22778. Infcode int64 `json:"infcode"`
  22779. Output struct {
  22780. HiRxNo string `json:"hi_rxno"`
  22781. FixMedinsCode string `json:"fixmedins_code"`
  22782. FixMedinsName string `json:"fixmedins_name"`
  22783. RxStasCodg string `json:"rx_stas_codg"`
  22784. RxStasName string `json:"rx_stas_name"`
  22785. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  22786. RxUserdStasName string `json:"rx_userd_stas_name"`
  22787. PrscTime string `json:"prsc_time"`
  22788. RxDrugCnt float64 `json:"rx_drug_cnt"`
  22789. RxUsedWayCodg string `json:"rx_used_way_codg"`
  22790. RxUsedWayName string `json:"rx_used_way_name"`
  22791. RxFrquCodg string `json:"rx_frqu_codg"`
  22792. RxFrquName string `json:"rx_frqu_name"`
  22793. RxDosunt string `json:"rx_dosunt"`
  22794. RxDoscnt float64 `json:"rx_doscnt"`
  22795. RxDrordDscr string `json:"rx_drord_dscr"`
  22796. ValiDays int64 `json:"vali_days"`
  22797. ValiEndTime string `json:"vali_end_time"`
  22798. ReptFlag string `json:"rept_flag"`
  22799. MaxReptCnt int64 `json:"max_rept_cnt"`
  22800. ReptdCnt int64 `json:"reptd_cnt"`
  22801. MinInrvDays int64 `json:"min_inrv_days"`
  22802. RxTypeCode string `json:"rx_type_code"`
  22803. RxTypeName string `json:"rx_type_name"`
  22804. LongRxFlag string `json:"long_rx_flag"`
  22805. RxDetlList []struct {
  22806. MedListCodg string `json:"med_list_codg"`
  22807. MedinsListCodg string `json:"medins_list_codg"`
  22808. HospPrepFlag string `json:"hosp_prep_flag"`
  22809. RxItemTypeCode string `json:"rx_item_type_code"`
  22810. RxItemTypeName string `json:"rx_item_type_name"`
  22811. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  22812. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  22813. TcmHerbFoote string `json:"tcmherb_foote"`
  22814. MednTypeCode string `json:"medn_type_code"`
  22815. MednTypeName string `json:"medn_type_name"`
  22816. MainMedcFlag string `json:"main_medc_flag"`
  22817. UrgtFlag string `json:"urgt_flag"`
  22818. BasMednFlag string `json:"bas_medn_flag"`
  22819. ImpDrugFlag string `json:"imp_drug_flag"`
  22820. ProdBarc string `json:"prod_barc"`
  22821. DrugProdname string `json:"drug_prodname"`
  22822. GennameCodg string `json:"genname_codg"`
  22823. DrugGenname string `json:"drug_genname"`
  22824. DrugDosform string `json:"drug_dosform"`
  22825. DrugSpec string `json:"drug_spec"`
  22826. PrdrName string `json:"prdr_name"`
  22827. MedcWayCodg string `json:"medc_way_codg"`
  22828. MedcWayDscr string `json:"medc_way_dscr"`
  22829. MedcBegntime string `json:"medc_begntime"`
  22830. MedcEndtime string `json:"medc_endtime"`
  22831. MedcDays float64 `json:"medc_days"`
  22832. DrugPric float64 `json:"drug_pric"`
  22833. DrugSumamt float64 `json:"drug_sumamt"`
  22834. DrugCnt float64 `json:"drug_cnt"`
  22835. DrugDosunt string `json:"drug_dosunt"`
  22836. SinDoscnt float64 `json:"sin_doscnt"`
  22837. SinDosunt string `json:"sin_dosunt"`
  22838. UsedFrquCodg string `json:"used_frqu_codg"`
  22839. UsedFrquName string `json:"used_frqu_name"`
  22840. DrugTotlcnt string `json:"drug_totlcnt"`
  22841. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  22842. DiseCodg string `json:"dise_codg"`
  22843. HospApprFlag string `json:"hosp_appr_flag"`
  22844. } `json:"rx_detl_list"`
  22845. RxOtpinfo struct {
  22846. MedType string `json:"med_type"`
  22847. IptOtpNo string `json:"ipt_otp_no"`
  22848. OtpIptFlag string `json:"otp_ipt_flag"`
  22849. PatnName string `json:"patn_name"`
  22850. PatnAge float64 `json:"patn_age"`
  22851. PatnHgt float64 `json:"patn_hgt"`
  22852. PatnWt float64 `json:"patn_wt"`
  22853. Gend string `json:"gend"`
  22854. GesoVal float64 `json:"geso_val"`
  22855. NwbFlag string `json:"nwb_flag"`
  22856. NwbAge string `json:"nwb_age"`
  22857. SuckPrdFlag string `json:"suck_prd_flag"`
  22858. AlgsHis string `json:"algs_his"`
  22859. Insutype string `json:"insutype"`
  22860. PrscDeptName string `json:"prsc_dept_name"`
  22861. PrscDrName string `json:"prsc_dr_name"`
  22862. PharName string `json:"phar_name"`
  22863. PharChkTime string `json:"phar_chk_time"`
  22864. MdtrtTime string `json:"mdtrt_time"`
  22865. DiseCodg string `json:"dise_codg"`
  22866. DiseName string `json:"dise_name"`
  22867. SpDiseFlag string `json:"sp_dise_flag"`
  22868. MaindiagCode string `json:"maindiag_code"`
  22869. MaindiagName string `json:"maindiag_name"`
  22870. DiseCondDscr string `json:"dise_cond_dscr"`
  22871. FstdiagFlag string `json:"fstdiag_flag"`
  22872. } `json:"rx_otpinfo"`
  22873. RxDiseList []struct {
  22874. DiagType string `json:"diag_type"`
  22875. MaindiagFlag string `json:"maindiag_flag"`
  22876. DiagSrtNo string `json:"diag_srt_no"`
  22877. DiagCode string `json:"diag_code"`
  22878. DiagName string `json:"diag_name"`
  22879. DiagDept string `json:"diag_dept"`
  22880. DiagDrNo string `json:"diag_dr_no"`
  22881. DiagDrName string `json:"diag_dr_name"`
  22882. DiagTime string `json:"diag_time"`
  22883. TcmDiseCode string `json:"tcm_dise_code"`
  22884. TcmDiseName string `json:"tcm_dise_name"`
  22885. TcmSympCode string `json:"tcmsymp_code"`
  22886. TcmSymp string `json:"tcmsymp"`
  22887. } `json:"rx_dise_list"`
  22888. } `json:"output"`
  22889. RefmsgTime string `json:"refmsg_time"`
  22890. RespondTime string `json:"respond_time"`
  22891. Signtype interface{} `json:"signtype"`
  22892. WarnInfo interface{} `json:"warn_info"`
  22893. }
  22894. type ResultCFYLJG006 struct {
  22895. ErrMsg string `json:"err_msg"`
  22896. InfRefmsgid string `json:"inf_refmsgid"`
  22897. Infcode int64 `json:"infcode"`
  22898. Output struct {
  22899. HiRxNo string `json:"hi_rxno"`
  22900. PharCode string `json:"phar_code"`
  22901. PharName string `json:"phar_name"`
  22902. RxChkOpnn string `json:"rx_chk_opnn"`
  22903. RxChkTime string `json:"rx_chk_time"`
  22904. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  22905. RxChkStasName string `json:"rx_chk_stas_name"`
  22906. RxStasCodg string `json:"rx_stas_codg"`
  22907. RxStasName string `json:"rx_stas_name"`
  22908. } `json:"output"`
  22909. RefmsgTime string `json:"refmsg_time"`
  22910. RespondTime string `json:"respond_time"`
  22911. Signtype interface{} `json:"signtype"`
  22912. WarnInfo interface{} `json:"warn_info"`
  22913. }
  22914. type ResultFourteen10265 struct {
  22915. ErrMsg string `json:"err_msg"`
  22916. InfRefmsgid string `json:"inf_refmsgid"`
  22917. Infcode string `json:"infcode"`
  22918. Output struct {
  22919. } `json:"output"`
  22920. RefmsgTime string `json:"refmsg_time"`
  22921. RespondTime string `json:"respond_time"`
  22922. Signtype interface{} `json:"signtype"`
  22923. WarnInfo interface{} `json:"warn_info"`
  22924. }
  22925. type ResultSixteen struct {
  22926. Cainfo string `json:"cainfo"`
  22927. ErrMsg string `json:"err_msg"`
  22928. InfRefmsgid string `json:"inf_refmsgid"`
  22929. Infcode int64 `json:"infcode"`
  22930. Output struct {
  22931. Setlinfo struct {
  22932. MdtrtID string `json:"mdtrt_id"`
  22933. SetlID string `json:"setl_id"`
  22934. ClrOptins string `json:"clr_optins"`
  22935. SetlTime string `json:"setl_time"`
  22936. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22937. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22938. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22939. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22940. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22941. ActPayDedc float64 `json:"act_pay_dedc"`
  22942. HifpPay float64 `json:"hifp_pay"`
  22943. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22944. Lfpay float64 `json:"selfpay"`
  22945. CvlservPay float64 `json:"cvlserv_pay"`
  22946. HifesPay float64 `json:"hifes_pay"`
  22947. HifmiPay float64 `json:"hifmi_pay"`
  22948. HifobPay float64 `json:"hifob_pay"`
  22949. MafPay float64 `json:"maf_pay"`
  22950. OthPay float64 `json:"oth_pay"`
  22951. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22952. PsnPartAmt float64 `json:"psn_part_amt"`
  22953. AcctPay float64 `json:"acct_pay"`
  22954. Balc float64 `json:"balc"`
  22955. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22956. HospPartAmt float64 `json:"hosp_part_amt"`
  22957. MedinsSetlID string `json:"medins_setl_id"`
  22958. PdnCashPay string `json:"pdn_cash_pay"`
  22959. } `json:"setlinfo"`
  22960. } `json:"output"`
  22961. RefmsgTime string `json:"refmsg_time"`
  22962. RespondTime string `json:"respond_time"`
  22963. Signtype interface{} `json:"signtype"`
  22964. WarnMsg interface{} `json:"warn_msg"`
  22965. }
  22966. type ResultSixteen10265 struct {
  22967. Cainfo string `json:"cainfo"`
  22968. ErrMsg string `json:"err_msg"`
  22969. InfRefmsgid string `json:"inf_refmsgid"`
  22970. Infcode string `json:"infcode"`
  22971. Output struct {
  22972. Setlinfo struct {
  22973. MdtrtID string `json:"mdtrt_id"`
  22974. SetlID string `json:"setl_id"`
  22975. ClrOptins string `json:"clr_optins"`
  22976. SetlTime string `json:"setl_time"`
  22977. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22978. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22979. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22980. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22981. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22982. ActPayDedc float64 `json:"act_pay_dedc"`
  22983. HifpPay float64 `json:"hifp_pay"`
  22984. PoolPropSe float64 `json:"pool_prop_selfpay"`
  22985. Lfpay float64 `json:"selfpay"`
  22986. CvlservPay float64 `json:"cvlserv_pay"`
  22987. HifesPay float64 `json:"hifes_pay"`
  22988. HifmiPay float64 `json:"hifmi_pay"`
  22989. HifobPay float64 `json:"hifob_pay"`
  22990. MafPay float64 `json:"maf_pay"`
  22991. OthPay float64 `json:"oth_pay"`
  22992. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22993. PsnPartAmt float64 `json:"psn_part_amt"`
  22994. AcctPay float64 `json:"acct_pay"`
  22995. Balc float64 `json:"balc"`
  22996. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22997. HospPartAmt float64 `json:"hosp_part_amt"`
  22998. MedinsSetlID string `json:"medins_setl_id"`
  22999. PdnCashPay string `json:"pdn_cash_pay"`
  23000. } `json:"setlinfo"`
  23001. } `json:"output"`
  23002. RefmsgTime string `json:"refmsg_time"`
  23003. RespondTime string `json:"respond_time"`
  23004. Signtype interface{} `json:"signtype"`
  23005. WarnMsg interface{} `json:"warn_msg"`
  23006. }
  23007. type ResultSixteen10265Two struct {
  23008. Cainfo string `json:"cainfo"`
  23009. ErrMsg string `json:"err_msg"`
  23010. InfRefmsgid string `json:"inf_refmsgid"`
  23011. Infcode string `json:"infcode"`
  23012. Output struct {
  23013. Setlinfo interface{} `json:"setlinfo"`
  23014. } `json:"output"`
  23015. RefmsgTime string `json:"refmsg_time"`
  23016. RespondTime string `json:"respond_time"`
  23017. Signtype interface{} `json:"signtype"`
  23018. WarnMsg interface{} `json:"warn_msg"`
  23019. }
  23020. type ResultgzSixteen10265Two struct {
  23021. Cainfo string `json:"cainfo"`
  23022. ErrMsg string `json:"err_msg"`
  23023. InfRefmsgid string `json:"inf_refmsgid"`
  23024. Infcode int64 `json:"infcode"`
  23025. Output struct {
  23026. Setlinfo interface{} `json:"setlinfo"`
  23027. } `json:"output"`
  23028. RefmsgTime string `json:"refmsg_time"`
  23029. RespondTime string `json:"respond_time"`
  23030. Signtype interface{} `json:"signtype"`
  23031. WarnMsg interface{} `json:"warn_msg"`
  23032. }
  23033. type ResultSeventeen struct {
  23034. ErrMsg string `json:"err_msg"`
  23035. InfRefmsgid string `json:"inf_refmsgid"`
  23036. Infcode int64 `json:"infcode"`
  23037. Output struct {
  23038. SetlListId string `json:"setl_list_id"`
  23039. } `json:"output"`
  23040. RefmsgTime string `json:"refmsg_time"`
  23041. RespondTime string `json:"respond_time"`
  23042. Signtype string `json:"signtype"`
  23043. WarnInfo string `json:"warn_info"`
  23044. }
  23045. type ResultSeventeenOther struct {
  23046. ErrMsg string `json:"err_msg"`
  23047. InfRefmsgid string `json:"inf_refmsgid"`
  23048. Infcode string `json:"infcode"`
  23049. Output struct {
  23050. SetlListId string `json:"setl_list_id"`
  23051. } `json:"output"`
  23052. RefmsgTime string `json:"refmsg_time"`
  23053. RespondTime string `json:"respond_time"`
  23054. Signtype string `json:"signtype"`
  23055. WarnInfo string `json:"warn_info"`
  23056. }
  23057. type Result90991 struct {
  23058. ErrMsg string `json:"err_msg"`
  23059. InfRefmsgid string `json:"inf_refmsgid"`
  23060. Infcode int64 `json:"infcode"`
  23061. Output struct {
  23062. Result struct {
  23063. PsnNo string `json:"psn_no"`
  23064. CardStat string `json:"card_stat"`
  23065. Certno string `json:"certno"`
  23066. PsnName string `json:"psn_name"`
  23067. CheckStat string `json:"check_stat"`
  23068. SscnoCheckStat string `json:"sscno_check_stat"`
  23069. } `json:"result"`
  23070. } `json:"output"`
  23071. RefmsgTime string `json:"refmsg_time"`
  23072. RespondTime string `json:"respond_time"`
  23073. Signtype interface{} `json:"signtype"`
  23074. WarnInfo interface{} `json:"warn_info"`
  23075. }
  23076. type Result90100 struct {
  23077. ErrMsg string `json:"err_msg"`
  23078. InfRefmsgid string `json:"inf_refmsgid"`
  23079. Infcode int64 `json:"infcode"`
  23080. Output struct {
  23081. PoolareaNo string `json:"poolarea_no"`
  23082. PoolareaNoName string `json:"poolarea_no_name"`
  23083. Insutype string `json:"insutype"`
  23084. InsutypeName string `json:"insutype_name"`
  23085. ClctType string `json:"clct_type"`
  23086. ClctTypeName string `json:"clct_type_name"`
  23087. ClctFlag string `json:"clct_flag"`
  23088. ClctFlagName string `json:"clct_flag_name"`
  23089. AccrymBegn string `json:"accrym_begn"`
  23090. AccrymEnd string `json:"accrym_end"`
  23091. ClctTime string `json:"clct_time"`
  23092. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  23093. } `json:"output"`
  23094. RefmsgTime string `json:"refmsg_time"`
  23095. RespondTime string `json:"respond_time"`
  23096. Signtype interface{} `json:"signtype"`
  23097. WarnInfo interface{} `json:"warn_info"`
  23098. }
  23099. type Custom struct {
  23100. DetItemFeeSumamt string
  23101. Cut string
  23102. FeedetlSn string
  23103. Price string
  23104. MedListCodg string
  23105. Type int64
  23106. AdviceId int64
  23107. ProjectId int64
  23108. ItemId int64
  23109. }
  23110. type Result5301 struct {
  23111. ErrMsg string `json:"err_msg"`
  23112. InfRefmsgid string `json:"inf_refmsgid"`
  23113. Infcode int64 `json:"infcode"`
  23114. Output struct {
  23115. Result []struct {
  23116. OpspDiseCode string `json:"opsp_dise_code"`
  23117. OpspDiseName string `json:"opsp_dise_name"`
  23118. Begndate string `json:"begndate"`
  23119. Enddate string `json:"enddate"`
  23120. } `json:"feedetail"`
  23121. } `json:"output"`
  23122. RefmsgTime string `json:"refmsg_time"`
  23123. RespondTime string `json:"respond_time"`
  23124. Signtype interface{} `json:"signtype"`
  23125. WarnInfo interface{} `json:"warn_info"`
  23126. }
  23127. type Result5301For10265 struct {
  23128. ErrMsg string `json:"err_msg"`
  23129. InfRefmsgid string `json:"inf_refmsgid"`
  23130. Infcode string `json:"infcode"`
  23131. Output struct {
  23132. Result []struct {
  23133. OpspDiseCode string `json:"opsp_dise_code"`
  23134. OpspDiseName string `json:"opsp_dise_name"`
  23135. Begndate string `json:"begndate"`
  23136. Enddate string `json:"enddate"`
  23137. } `json:"feedetail"`
  23138. } `json:"output"`
  23139. RefmsgTime string `json:"refmsg_time"`
  23140. RespondTime string `json:"respond_time"`
  23141. Signtype interface{} `json:"signtype"`
  23142. WarnInfo interface{} `json:"warn_info"`
  23143. }
  23144. //获取个人信息----挂号-----上传就诊信息
  23145. func (c *HisApiController) GetRegisterInfo() {
  23146. id, _ := c.GetInt64("id")
  23147. record_time := c.GetString("record_time")
  23148. settlementValue, _ := c.GetInt64("settlement_value")
  23149. medical_insurance_card := c.GetString("medical_insurance_card")
  23150. name := c.GetString("name")
  23151. id_card_type, _ := c.GetInt64("id_card_type")
  23152. certificates, _ := c.GetInt64("certificates")
  23153. medical_care, _ := c.GetInt64("medical_care")
  23154. birthday := c.GetString("birthday")
  23155. id_card := c.GetString("id_card")
  23156. register_type, _ := c.GetInt64("register")
  23157. doctor, _ := c.GetInt64("doctor")
  23158. department, _ := c.GetInt64("department")
  23159. gender, _ := c.GetInt64("sex")
  23160. registration_fee, _ := c.GetFloat("registration_fee")
  23161. medical_expenses, _ := c.GetFloat("medical_expenses")
  23162. social_type, _ := c.GetInt64("social_type")
  23163. admin_user_id, _ := c.GetInt64("admin_user_id")
  23164. insuplc_admdvs := c.GetString("insuplc_admdvs")
  23165. mdtrt_type := c.GetString("mdtrt_type")
  23166. if id_card_type == 5 {
  23167. id_card_type = 4
  23168. }
  23169. timeLayout := "2006-01-02"
  23170. loc, _ := time.LoadLocation("Local")
  23171. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  23172. birthUnix := birthdays.Unix()
  23173. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  23174. if err != nil {
  23175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23176. return
  23177. }
  23178. recordDateTime := theTime.Unix()
  23179. adminInfo := c.GetAdminUserInfo()
  23180. var patient service.Patients
  23181. if id == 0 {
  23182. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  23183. } else {
  23184. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  23185. }
  23186. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23187. if patientPrescription.ID == 0 {
  23188. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  23189. }
  23190. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  23191. if patient.ID == 0 {
  23192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  23193. return
  23194. }
  23195. if len(patient.IdCardNo) == 0 {
  23196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  23197. return
  23198. }
  23199. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  23200. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  23201. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  23202. //就诊结算未完成,不能进行二次挂号
  23203. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  23204. if len(his) >= 1 {
  23205. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  23206. if len(his) >= 1 && order.ID == 0 {
  23207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  23208. return
  23209. }
  23210. }
  23211. //var register_log string
  23212. if config.IsOpen == 1 {
  23213. var res ResultTwo
  23214. var res10265 ResultTwo10265
  23215. var PsnNo string
  23216. var PsnCertType string
  23217. var Certno string
  23218. var PsnName string
  23219. var Gend string
  23220. var Naty string
  23221. var Brdy string
  23222. var Age float64
  23223. var infoStr string
  23224. var idetinfoStr string
  23225. var infocode int64
  23226. var verify_number string
  23227. fmt.Println(verify_number)
  23228. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  23229. psn_info, _ := service.GetPsnByPatientId(id)
  23230. PsnNo = psn_info.PsnNo
  23231. PsnCertType = psn_info.PsnCertType
  23232. Certno = psn_info.Certno
  23233. PsnName = psn_info.PsnName
  23234. Gend = psn_info.Gend
  23235. Naty = psn_info.Naty
  23236. Brdy = psn_info.Brdy
  23237. Age = psn_info.Age
  23238. infoStr = psn_info.Insuinfo
  23239. idetinfoStr = psn_info.Idetinfo
  23240. infocode = 0
  23241. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23242. psn_info, _ := service.GetPsnByPatientId(id)
  23243. PsnNo = psn_info.PsnNo
  23244. PsnCertType = psn_info.PsnCertType
  23245. Certno = psn_info.Certno
  23246. PsnName = psn_info.PsnName
  23247. Gend = psn_info.Gend
  23248. Naty = psn_info.Naty
  23249. Brdy = psn_info.Brdy
  23250. Age = psn_info.Age
  23251. infoStr = psn_info.Insuinfo
  23252. idetinfoStr = psn_info.Idetinfo
  23253. infocode = 0
  23254. verify_number = psn_info.VerifyNumber
  23255. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23256. if id_card_type == 2 {
  23257. //请求内网数据
  23258. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  23259. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23260. "&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
  23261. resp, requestErr := http.Get(api)
  23262. if requestErr != nil {
  23263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23264. return
  23265. }
  23266. body, ioErr := ioutil.ReadAll(resp.Body)
  23267. if ioErr != nil {
  23268. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23270. return
  23271. }
  23272. var respJSON map[string]interface{}
  23273. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23274. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23276. return
  23277. }
  23278. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23279. result_byte, _ := json.Marshal(respJSON)
  23280. result := string(result_byte)
  23281. var dat map[string]interface{}
  23282. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23283. fmt.Println(dat)
  23284. } else {
  23285. fmt.Println(err)
  23286. }
  23287. userJSONBytes, _ := json.Marshal(dat)
  23288. var res ResultTwo
  23289. var resTwo10265 ResultTwo10265
  23290. if miConfig.Code == "H15049901371" {
  23291. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  23292. utils.ErrorLog("解析失败:%v", err)
  23293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23294. return
  23295. }
  23296. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  23297. res.Infcode = Infcode
  23298. res.ErrMsg = resTwo10265.ErrMsg
  23299. res.Output = resTwo10265.Output
  23300. res.InfRefmsgid = resTwo10265.InfRefmsgid
  23301. res.RespondTime = resTwo10265.RespondTime
  23302. res.WarnInfo = resTwo10265.WarnInfo
  23303. } else {
  23304. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23305. utils.ErrorLog("解析失败:%v", err)
  23306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23307. return
  23308. }
  23309. }
  23310. //var insutypes []string
  23311. //var insutype string
  23312. //var is390 int = 0
  23313. //var is310 int = 0
  23314. //for _, item := range res.Output.Iinfo {
  23315. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23316. // insutypes = append(insutypes, item.Insutype)
  23317. // }
  23318. //}
  23319. //if len(insutypes) == 1 {
  23320. // insutype = insutypes[0]
  23321. //} else {
  23322. // for _, i := range insutypes {
  23323. // if i == "390" {
  23324. // is390 = 1
  23325. // }
  23326. //
  23327. // if i == "310" {
  23328. // is310 = 1
  23329. // }
  23330. // }
  23331. //}
  23332. //if is390 == 1 {
  23333. // insutype = "390"
  23334. //}
  23335. //if is310 == 1 {
  23336. // insutype = "310"
  23337. //}
  23338. //if len(insutypes) == 0 {
  23339. // insutype = "310"
  23340. //}
  23341. PsnNo = res.Output.Baseinfo.PsnNo
  23342. PsnCertType = res.Output.Baseinfo.PsnCertType
  23343. Certno = res.Output.Baseinfo.Certno
  23344. PsnName = res.Output.Baseinfo.PsnName
  23345. Gend = res.Output.Baseinfo.Gend
  23346. Naty = res.Output.Baseinfo.Naty
  23347. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23348. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23349. infoStr = string(Iinfos)
  23350. idetinfoStr = string(Idetinfos)
  23351. infocode = res.Infcode
  23352. //infocode = 0
  23353. //verify_number = psn_info.VerifyNumber
  23354. } else {
  23355. psn_info, _ := service.GetPsnByPatientId(id)
  23356. PsnNo = psn_info.PsnNo
  23357. PsnCertType = psn_info.PsnCertType
  23358. Certno = psn_info.Certno
  23359. PsnName = psn_info.PsnName
  23360. Gend = psn_info.Gend
  23361. Naty = psn_info.Naty
  23362. Brdy = psn_info.Brdy
  23363. Age = psn_info.Age
  23364. infoStr = psn_info.Insuinfo
  23365. idetinfoStr = psn_info.Idetinfo
  23366. infocode = 0
  23367. verify_number = psn_info.VerifyNumber
  23368. }
  23369. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23370. if id_card_type == 1 {
  23371. psn_info, _ := service.GetPsnByPatientId(id)
  23372. PsnNo = psn_info.PsnNo
  23373. PsnCertType = psn_info.PsnCertType
  23374. Certno = psn_info.Certno
  23375. PsnName = psn_info.PsnName
  23376. Gend = psn_info.Gend
  23377. Naty = psn_info.Naty
  23378. Brdy = psn_info.Brdy
  23379. Age = psn_info.Age
  23380. infoStr = psn_info.Insuinfo
  23381. idetinfoStr = psn_info.Idetinfo
  23382. infocode = 0
  23383. verify_number = psn_info.VerifyNumber
  23384. } else if id_card_type == 2 {
  23385. 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)
  23386. fmt.Println(errMsgLog)
  23387. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23388. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23389. utils.ErrorLog("解析失败:%v", err)
  23390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23391. return
  23392. }
  23393. PsnNo = res.Output.Baseinfo.PsnNo
  23394. PsnCertType = res.Output.Baseinfo.PsnCertType
  23395. Certno = res.Output.Baseinfo.Certno
  23396. PsnName = res.Output.Baseinfo.PsnName
  23397. Gend = res.Output.Baseinfo.Gend
  23398. Naty = res.Output.Baseinfo.Naty
  23399. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23400. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23401. infoStr = string(Iinfos)
  23402. idetinfoStr = string(Idetinfos)
  23403. infocode = res.Infcode
  23404. }
  23405. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23406. if id_card_type == 1 {
  23407. psn_info, _ := service.GetPsnByPatientId(id)
  23408. PsnNo = psn_info.PsnNo
  23409. PsnCertType = psn_info.PsnCertType
  23410. Certno = psn_info.Certno
  23411. PsnName = psn_info.PsnName
  23412. Gend = psn_info.Gend
  23413. Naty = psn_info.Naty
  23414. Brdy = psn_info.Brdy
  23415. Age = psn_info.Age
  23416. infoStr = psn_info.Insuinfo
  23417. idetinfoStr = psn_info.Idetinfo
  23418. infocode = 0
  23419. verify_number = psn_info.VerifyNumber
  23420. } else if id_card_type == 2 {
  23421. 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, "")
  23422. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23423. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23424. utils.ErrorLog("解析失败:%v", err)
  23425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23426. return
  23427. }
  23428. PsnNo = res.Output.Baseinfo.PsnNo
  23429. PsnCertType = res.Output.Baseinfo.PsnCertType
  23430. Certno = res.Output.Baseinfo.Certno
  23431. PsnName = res.Output.Baseinfo.PsnName
  23432. Gend = res.Output.Baseinfo.Gend
  23433. Naty = res.Output.Baseinfo.Naty
  23434. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23435. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23436. infoStr = string(Iinfos)
  23437. idetinfoStr = string(Idetinfos)
  23438. infocode = res.Infcode
  23439. } else {
  23440. psn_info, _ := service.GetPsnByPatientId(id)
  23441. PsnNo = psn_info.PsnNo
  23442. PsnCertType = psn_info.PsnCertType
  23443. Certno = psn_info.Certno
  23444. PsnName = psn_info.PsnName
  23445. Gend = psn_info.Gend
  23446. Naty = psn_info.Naty
  23447. Brdy = psn_info.Brdy
  23448. Age = psn_info.Age
  23449. infoStr = psn_info.Insuinfo
  23450. idetinfoStr = psn_info.Idetinfo
  23451. infocode = 0
  23452. verify_number = psn_info.VerifyNumber
  23453. }
  23454. } else if miConfig.MdtrtareaAdmvs == "361025" {
  23455. if id_card_type == 1 {
  23456. psn_info, _ := service.GetPsnByPatientId(id)
  23457. PsnNo = psn_info.PsnNo
  23458. PsnCertType = psn_info.PsnCertType
  23459. Certno = psn_info.Certno
  23460. PsnName = psn_info.PsnName
  23461. Gend = psn_info.Gend
  23462. Naty = psn_info.Naty
  23463. Brdy = psn_info.Brdy
  23464. Age = psn_info.Age
  23465. infoStr = psn_info.Insuinfo
  23466. idetinfoStr = psn_info.Idetinfo
  23467. infocode = 0
  23468. verify_number = psn_info.VerifyNumber
  23469. } else if id_card_type == 2 {
  23470. psn_info, _ := service.GetPsnByPatientId(id)
  23471. PsnNo = psn_info.PsnNo
  23472. PsnCertType = psn_info.PsnCertType
  23473. Certno = psn_info.Certno
  23474. PsnName = psn_info.PsnName
  23475. Gend = psn_info.Gend
  23476. Naty = psn_info.Naty
  23477. Brdy = psn_info.Brdy
  23478. Age = psn_info.Age
  23479. infoStr = psn_info.Insuinfo
  23480. idetinfoStr = psn_info.Idetinfo
  23481. infocode = 0
  23482. verify_number = psn_info.VerifyNumber
  23483. } else {
  23484. psn_info, _ := service.GetPsnByPatientId(id)
  23485. PsnNo = psn_info.PsnNo
  23486. PsnCertType = psn_info.PsnCertType
  23487. Certno = psn_info.Certno
  23488. PsnName = psn_info.PsnName
  23489. Gend = psn_info.Gend
  23490. Naty = psn_info.Naty
  23491. Brdy = psn_info.Brdy
  23492. Age = psn_info.Age
  23493. infoStr = psn_info.Insuinfo
  23494. idetinfoStr = psn_info.Idetinfo
  23495. infocode = 0
  23496. verify_number = psn_info.VerifyNumber
  23497. }
  23498. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  23499. psn_info, _ := service.GetPsnByPatientId(id)
  23500. PsnNo = psn_info.PsnNo
  23501. PsnCertType = psn_info.PsnCertType
  23502. Certno = psn_info.Certno
  23503. PsnName = psn_info.PsnName
  23504. Gend = psn_info.Gend
  23505. Naty = psn_info.Naty
  23506. Brdy = psn_info.Brdy
  23507. Age = psn_info.Age
  23508. infoStr = psn_info.Insuinfo
  23509. idetinfoStr = psn_info.Idetinfo
  23510. infocode = 0
  23511. verify_number = psn_info.VerifyNumber
  23512. idetinfoStr = psn_info.Idetinfo
  23513. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23514. if id_card_type == 1 {
  23515. psn_info, _ := service.GetPsnByPatientId(id)
  23516. PsnNo = psn_info.PsnNo
  23517. PsnCertType = psn_info.PsnCertType
  23518. Certno = psn_info.Certno
  23519. PsnName = psn_info.PsnName
  23520. Gend = psn_info.Gend
  23521. Naty = psn_info.Naty
  23522. Brdy = psn_info.Brdy
  23523. Age = psn_info.Age
  23524. infoStr = psn_info.Insuinfo
  23525. idetinfoStr = psn_info.Idetinfo
  23526. infocode = 0
  23527. verify_number = psn_info.VerifyNumber
  23528. } else if id_card_type == 2 {
  23529. 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)
  23530. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23531. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23532. utils.ErrorLog("解析失败:%v", err)
  23533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23534. return
  23535. }
  23536. PsnNo = res.Output.Baseinfo.PsnNo
  23537. PsnCertType = res.Output.Baseinfo.PsnCertType
  23538. Certno = res.Output.Baseinfo.Certno
  23539. PsnName = res.Output.Baseinfo.PsnName
  23540. Gend = res.Output.Baseinfo.Gend
  23541. Naty = res.Output.Baseinfo.Naty
  23542. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23543. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23544. infoStr = string(Iinfos)
  23545. idetinfoStr = string(Idetinfos)
  23546. infocode = res.Infcode
  23547. } else if id_card_type == 4 {
  23548. psn_info, _ := service.GetPsnByPatientId(id)
  23549. PsnNo = psn_info.PsnNo
  23550. PsnCertType = psn_info.PsnCertType
  23551. Certno = psn_info.Certno
  23552. PsnName = psn_info.PsnName
  23553. Gend = psn_info.Gend
  23554. Naty = psn_info.Naty
  23555. Brdy = psn_info.Brdy
  23556. Age = psn_info.Age
  23557. infoStr = psn_info.Insuinfo
  23558. idetinfoStr = psn_info.Idetinfo
  23559. infocode = 0
  23560. verify_number = psn_info.VerifyNumber
  23561. }
  23562. } else if miConfig.MdtrtareaAdmvs == "131023" {
  23563. var result string
  23564. var requestLog string
  23565. 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), "")
  23566. if id_card_type == 4 {
  23567. psn_info, _ := service.GetPsnByPatientId(id)
  23568. PsnNo = psn_info.PsnNo
  23569. PsnCertType = psn_info.PsnCertType
  23570. Certno = psn_info.Certno
  23571. PsnName = psn_info.PsnName
  23572. Gend = psn_info.Gend
  23573. Naty = psn_info.Naty
  23574. Brdy = psn_info.Brdy
  23575. Age = psn_info.Age
  23576. infoStr = psn_info.Insuinfo
  23577. idetinfoStr = psn_info.Idetinfo
  23578. infocode = 0
  23579. verify_number = psn_info.VerifyNumber
  23580. } else {
  23581. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23582. if miConfig.Code == "H15049901371" {
  23583. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23584. utils.ErrorLog("解析失败:%v", err)
  23585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23586. return
  23587. }
  23588. res.ErrMsg = res10265.ErrMsg
  23589. res.Output = res10265.Output
  23590. res.InfRefmsgid = res10265.InfRefmsgid
  23591. } else {
  23592. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23593. utils.ErrorLog("解析失败:%v", err)
  23594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23595. return
  23596. }
  23597. }
  23598. PsnNo = res.Output.Baseinfo.PsnNo
  23599. PsnCertType = res.Output.Baseinfo.PsnCertType
  23600. Certno = res.Output.Baseinfo.Certno
  23601. PsnName = res.Output.Baseinfo.PsnName
  23602. Gend = res.Output.Baseinfo.Gend
  23603. Naty = res.Output.Baseinfo.Naty
  23604. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23605. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23606. infoStr = string(Iinfos)
  23607. idetinfoStr = string(Idetinfos)
  23608. if miConfig.Code == "H15049901371" {
  23609. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23610. } else {
  23611. infocode = res.Infcode
  23612. }
  23613. }
  23614. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23615. psn_info, _ := service.GetPsnByPatientId(id)
  23616. PsnNo = psn_info.PsnNo
  23617. PsnCertType = psn_info.PsnCertType
  23618. Certno = psn_info.Certno
  23619. PsnName = psn_info.PsnName
  23620. Gend = psn_info.Gend
  23621. Naty = psn_info.Naty
  23622. Brdy = psn_info.Brdy
  23623. Age = psn_info.Age
  23624. infoStr = psn_info.Insuinfo
  23625. idetinfoStr = psn_info.Idetinfo
  23626. infocode = 0
  23627. verify_number = psn_info.VerifyNumber
  23628. } else if miConfig.MdtrtareaAdmvs == "450721" {
  23629. psn_info, _ := service.GetPsnByPatientId(id)
  23630. PsnNo = psn_info.PsnNo
  23631. PsnCertType = psn_info.PsnCertType
  23632. Certno = psn_info.Certno
  23633. PsnName = psn_info.PsnName
  23634. Gend = psn_info.Gend
  23635. Naty = psn_info.Naty
  23636. Brdy = psn_info.Brdy
  23637. Age = psn_info.Age
  23638. infoStr = psn_info.Insuinfo
  23639. idetinfoStr = psn_info.Idetinfo
  23640. infocode = 0
  23641. verify_number = psn_info.VerifyNumber
  23642. } else {
  23643. var result string
  23644. var requestLog string
  23645. //if miConfig.UserOrgId == 10138 {
  23646. if id_card_type != 4 || id_card_type != 1 {
  23647. var insa string
  23648. if len(patient.InsuplcAdmdvs) > 0 {
  23649. insa = patient.InsuplcAdmdvs
  23650. } else {
  23651. insa = miConfig.InsuplcAdmdvs
  23652. }
  23653. //psn_info, _ := service.GetPsnByPatientId(id)
  23654. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  23655. 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)
  23656. }
  23657. //}
  23658. //else {
  23659. // var insa string
  23660. // if len(patient.InsuplcAdmdvs) > 0 {
  23661. // insa = patient.InsuplcAdmdvs
  23662. // } else {
  23663. // insa = miConfig.InsuplcAdmdvs
  23664. // }
  23665. // 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)
  23666. //}
  23667. if id_card_type == 4 || id_card_type == 1 {
  23668. psn_info, _ := service.GetPsnByPatientId(id)
  23669. PsnNo = psn_info.PsnNo
  23670. PsnCertType = psn_info.PsnCertType
  23671. Certno = psn_info.Certno
  23672. PsnName = psn_info.PsnName
  23673. Gend = psn_info.Gend
  23674. Naty = psn_info.Naty
  23675. Brdy = psn_info.Brdy
  23676. Age = psn_info.Age
  23677. infoStr = psn_info.Insuinfo
  23678. idetinfoStr = psn_info.Idetinfo
  23679. infocode = 0
  23680. verify_number = psn_info.VerifyNumber
  23681. } else {
  23682. saveLog(result, requestLog, "1101", "人员基本信息获取")
  23683. if miConfig.Code == "H15049901371" {
  23684. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  23685. utils.ErrorLog("解析失败:%v", err)
  23686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23687. return
  23688. }
  23689. res.ErrMsg = res10265.ErrMsg
  23690. res.Output = res10265.Output
  23691. res.InfRefmsgid = res10265.InfRefmsgid
  23692. } else {
  23693. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23694. utils.ErrorLog("解析失败:%v", err)
  23695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23696. return
  23697. }
  23698. }
  23699. PsnNo = res.Output.Baseinfo.PsnNo
  23700. PsnCertType = res.Output.Baseinfo.PsnCertType
  23701. Certno = res.Output.Baseinfo.Certno
  23702. PsnName = res.Output.Baseinfo.PsnName
  23703. Gend = res.Output.Baseinfo.Gend
  23704. Naty = res.Output.Baseinfo.Naty
  23705. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  23706. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  23707. infoStr = string(Iinfos)
  23708. idetinfoStr = string(Idetinfos)
  23709. if miConfig.Code == "H15049901371" {
  23710. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  23711. } else {
  23712. infocode = res.Infcode
  23713. }
  23714. }
  23715. }
  23716. if infocode == 0 {
  23717. his := models.VMHisPatient{
  23718. Name: name,
  23719. Gender: gender,
  23720. Birthday: birthUnix,
  23721. MedicalTreatmentType: medical_care,
  23722. IdType: certificates,
  23723. IdCardNo: id_card,
  23724. BalanceAccountsType: settlementValue,
  23725. SocialType: social_type,
  23726. MedicalInsuranceNumber: medical_insurance_card,
  23727. RegisterType: register_type,
  23728. RegisterCost: registration_fee,
  23729. TreatmentCost: medical_expenses,
  23730. Status: 1,
  23731. Ctime: time.Now().Unix(),
  23732. Mtime: time.Now().Unix(),
  23733. PsnNo: PsnNo,
  23734. PsnCertType: PsnCertType,
  23735. Certno: Certno,
  23736. PsnName: PsnName,
  23737. Gend: Gend,
  23738. Naty: Naty,
  23739. Brdy: Brdy,
  23740. Age: Age,
  23741. Iinfo: infoStr,
  23742. Idetinfo: idetinfoStr,
  23743. PatientId: patient.ID,
  23744. RecordDate: theTime.Unix(),
  23745. UserOrgId: adminInfo.CurrentOrgId,
  23746. AdminUserId: admin_user_id,
  23747. IsReturn: 1,
  23748. IdCardType: id_card_type,
  23749. Doctor: doctor,
  23750. Departments: department,
  23751. MdtrtGrpType: mdtrt_type,
  23752. }
  23753. timestamp := time.Now().Unix()
  23754. tempTime := time.Unix(timestamp, 0)
  23755. timeFormat := tempTime.Format("20060102150405")
  23756. chrgBchno := rand.Intn(100000) + 10000
  23757. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  23758. his.Number = ipt_otp_no
  23759. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  23760. department, _ := service.GetDepartMentDetail(department)
  23761. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  23762. IdCardNo := ""
  23763. if id_card_type == 1 {
  23764. // IdCardNo = medical_insurance_card
  23765. IdCardNo = patient.IdCardNo
  23766. } else {
  23767. IdCardNo = patient.IdCardNo
  23768. }
  23769. var rf []*ResultFive
  23770. json.Unmarshal([]byte(his.Iinfo), &rf)
  23771. var insutypes []*ResultFive
  23772. var insutype string
  23773. var insuplc_admdvs_temp string
  23774. var is390 int = 0
  23775. var is310 int = 0
  23776. for _, item := range rf {
  23777. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23778. insutypes = append(insutypes, item)
  23779. }
  23780. }
  23781. if len(insutypes) == 1 {
  23782. insutype = insutypes[0].Insutype
  23783. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  23784. if insutype == "390" {
  23785. is390 = 1
  23786. }
  23787. if insutype == "310" {
  23788. is310 = 1
  23789. }
  23790. } else {
  23791. for _, i := range insutypes {
  23792. if i.Insutype == "390" {
  23793. is390 = 1
  23794. }
  23795. if i.Insutype == "310" {
  23796. is310 = 1
  23797. }
  23798. }
  23799. }
  23800. if is390 == 1 {
  23801. insutype = "390"
  23802. }
  23803. if is310 == 1 {
  23804. insutype = "310"
  23805. }
  23806. fmt.Println(social_type)
  23807. if social_type > 0 {
  23808. insutype = strconv.FormatInt(social_type, 10)
  23809. }
  23810. var infocode int64
  23811. var resThree ResultThree
  23812. var resThree10265 ResultThree10265
  23813. if len(insuplc_admdvs) == 0 {
  23814. psn_info, _ := service.GetPsnByPatientId(id)
  23815. //if len(psn_info.InsuplcAdmdvs) > 0 {
  23816. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  23817. //}
  23818. } else {
  23819. insuplc_admdvs_temp = insuplc_admdvs
  23820. }
  23821. if miConfig.MdtrtareaAdmvs == "421300" {
  23822. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23823. psn_info, _ := service.GetPsnByPatientId(id)
  23824. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23825. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23826. "&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
  23827. resp, requestErr := http.Get(api)
  23828. if requestErr != nil {
  23829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23830. return
  23831. }
  23832. body, ioErr := ioutil.ReadAll(resp.Body)
  23833. if ioErr != nil {
  23834. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23836. return
  23837. }
  23838. var respJSON map[string]interface{}
  23839. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23840. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23842. return
  23843. }
  23844. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23845. result, _ := json.Marshal(respJSON)
  23846. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23847. utils.ErrorLog("解析失败:%v", err)
  23848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23849. return
  23850. }
  23851. infocode = resThree.Infcode
  23852. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23853. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23854. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23855. // insuplc_admdvs_temp =
  23856. //}
  23857. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23858. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23859. //}
  23860. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23861. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23862. "&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
  23863. resp, requestErr := http.Get(api)
  23864. if requestErr != nil {
  23865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23866. return
  23867. }
  23868. body, ioErr := ioutil.ReadAll(resp.Body)
  23869. if ioErr != nil {
  23870. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23872. return
  23873. }
  23874. var respJSON map[string]interface{}
  23875. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23876. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23878. return
  23879. }
  23880. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23881. result, _ := json.Marshal(respJSON)
  23882. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23883. utils.ErrorLog("解析失败:%v", err)
  23884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23885. return
  23886. }
  23887. infocode = resThree.Infcode
  23888. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23889. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23890. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23891. // insuplc_admdvs_temp =
  23892. //}
  23893. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23894. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23895. //}
  23896. utils.ErrorLog("解析失败:%v", insutype)
  23897. utils.ErrorLog("解析失败:%v", PsnNo)
  23898. utils.ErrorLog("解析失败:%v", Certno)
  23899. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  23900. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  23901. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  23902. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  23903. utils.ErrorLog("解析失败:%v", PsnNo)
  23904. utils.ErrorLog("解析失败:%v", department.Number)
  23905. utils.ErrorLog("解析失败:%v", department.Name)
  23906. utils.ErrorLog("解析失败:%v", roles.UserName)
  23907. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23908. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23909. "&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
  23910. resp, requestErr := http.Get(api)
  23911. if requestErr != nil {
  23912. utils.ErrorLog("解析失败:%v", requestErr)
  23913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23914. return
  23915. }
  23916. body, ioErr := ioutil.ReadAll(resp.Body)
  23917. if ioErr != nil {
  23918. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23920. return
  23921. }
  23922. var respJSON map[string]interface{}
  23923. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23924. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23926. return
  23927. }
  23928. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23929. result, _ := json.Marshal(respJSON)
  23930. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23931. utils.ErrorLog("解析失败:%v", err)
  23932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23933. return
  23934. }
  23935. infocode = resThree.Infcode
  23936. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23937. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23938. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  23939. // insuplc_admdvs_temp =
  23940. //}
  23941. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  23942. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  23943. //}
  23944. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23945. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23946. "&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
  23947. resp, requestErr := http.Get(api)
  23948. if requestErr != nil {
  23949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23950. return
  23951. }
  23952. body, ioErr := ioutil.ReadAll(resp.Body)
  23953. if ioErr != nil {
  23954. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23956. return
  23957. }
  23958. var respJSON map[string]interface{}
  23959. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23960. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23962. return
  23963. }
  23964. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23965. result, _ := json.Marshal(respJSON)
  23966. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  23967. utils.ErrorLog("解析失败:%v", err)
  23968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23969. return
  23970. }
  23971. infocode = resThree.Infcode
  23972. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23973. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  23974. psn_info, _ := service.GetPsnByPatientId(id)
  23975. var verify_number string
  23976. if id_card_type == 4 {
  23977. verify_number = psn_info.VerifyNumber
  23978. } else if id_card_type == 1 {
  23979. bas := strings.Split(psn_info.CardInfo, "|")
  23980. cardNumber := bas[2]
  23981. verify_number = cardNumber
  23982. }
  23983. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  23984. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  23985. "&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
  23986. resp, requestErr := http.Get(api)
  23987. if requestErr != nil {
  23988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23989. return
  23990. }
  23991. body, ioErr := ioutil.ReadAll(resp.Body)
  23992. if ioErr != nil {
  23993. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23995. return
  23996. }
  23997. var respJSON map[string]interface{}
  23998. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23999. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24001. return
  24002. }
  24003. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24004. result, _ := json.Marshal(respJSON)
  24005. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24006. // utils.ErrorLog("解析失败:%v", err)
  24007. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24008. // return
  24009. //}
  24010. //infocode = resThree.Infcode
  24011. //result, _ := json.Marshal(respJSON)
  24012. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24013. utils.ErrorLog("解析失败:%v", err)
  24014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24015. return
  24016. }
  24017. resThree.ErrMsg = resThree10265.ErrMsg
  24018. resThree.Output = resThree10265.Output
  24019. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24020. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24021. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24022. psn_info, _ := service.GetPsnByPatientId(id)
  24023. his.PsnNo = psn_info.PsnNo
  24024. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24025. var cert_no string
  24026. if id_card_type == 3 {
  24027. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  24028. cert_no = IdCardNo
  24029. } else if id_card_type == 4 {
  24030. cert_no = IdCardNo
  24031. psn_info.VerifyNumber = psn_info.VerifyNumber
  24032. } else {
  24033. bas := strings.Split(psn_info.CardInfo, "|")
  24034. cert_no = bas[2]
  24035. }
  24036. var hisPrescription []*models.HisPrescription
  24037. for _, item := range rf {
  24038. if item.Insutype == insutype {
  24039. //insuplc_admdvs = item.InsuplcAdmdvs
  24040. his.InsuplcAdmdvs = insuplc_admdvs
  24041. }
  24042. }
  24043. his.Insutype = insutype
  24044. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24045. fmt.Println(res3101)
  24046. fmt.Println(res3101.Infcode)
  24047. if res3101.Infcode == "0" {
  24048. fmt.Println("33333333")
  24049. if len(res3101.Output.Result) > 0 {
  24050. fmt.Println("222222")
  24051. for _, item := range res3101.Output.Result {
  24052. if len(res3101.ErrMsg) == 0 {
  24053. res3101.ErrMsg = item.VolaCont
  24054. } else {
  24055. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24056. }
  24057. }
  24058. c.ServeSuccessJSON(map[string]interface{}{
  24059. "failed_code": -10,
  24060. "msg": res3101.ErrMsg,
  24061. })
  24062. return
  24063. } else {
  24064. fmt.Println("11111")
  24065. var api string
  24066. if miConfig.MdtrtareaAdmvs == "320921" {
  24067. ipt_otp_no = timeFormat
  24068. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24069. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24070. "&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
  24071. } else {
  24072. ipt_otp_no = timeFormat
  24073. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  24074. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24075. "&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
  24076. }
  24077. resp, requestErr := http.Get(api)
  24078. if requestErr != nil {
  24079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24080. return
  24081. }
  24082. body, ioErr := ioutil.ReadAll(resp.Body)
  24083. if ioErr != nil {
  24084. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24086. return
  24087. }
  24088. var respJSON map[string]interface{}
  24089. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24090. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24092. return
  24093. }
  24094. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24095. result, _ := json.Marshal(respJSON)
  24096. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24097. utils.ErrorLog("解析失败:%v", err)
  24098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24099. return
  24100. }
  24101. resThree.ErrMsg = resThree10265.ErrMsg
  24102. resThree.Output = resThree10265.Output
  24103. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24104. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24105. }
  24106. } else if res3101.Infcode != "0" {
  24107. c.ServeSuccessJSON(map[string]interface{}{
  24108. "failed_code": -10,
  24109. "msg": res3101.ErrMsg,
  24110. })
  24111. return
  24112. }
  24113. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24114. psn_info, _ := service.GetPsnByPatientId(id)
  24115. var cert_no string
  24116. if id_card_type == 1 {
  24117. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  24118. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24119. } else if id_card_type == 4 {
  24120. cert_no = psn_info.VerifyNumber
  24121. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24122. } else {
  24123. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24124. cert_no = psn_info.VerifyNumber
  24125. }
  24126. 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)
  24127. saveLog(result, requestLog, "2201", "挂号")
  24128. if miConfig.Code == "H15049901371" {
  24129. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24130. utils.ErrorLog("解析失败:%v", err)
  24131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24132. return
  24133. }
  24134. resThree.ErrMsg = resThree10265.ErrMsg
  24135. resThree.Output = resThree10265.Output
  24136. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24137. } else {
  24138. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24139. utils.ErrorLog("解析失败:%v", err)
  24140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24141. return
  24142. }
  24143. }
  24144. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24145. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  24146. psn_info, _ := service.GetPsnByPatientId(id)
  24147. var result string
  24148. var requestLog string
  24149. if id_card_type == 1 {
  24150. bas := strings.Split(psn_info.CardInfo, "|")
  24151. basNumber := bas[2]
  24152. card_sn := bas[3]
  24153. 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)
  24154. saveLog(result, requestLog, "2201A", "挂号")
  24155. } else if id_card_type == 2 {
  24156. 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, "", "", "", "", "", "")
  24157. saveLog(result, requestLog, "2201A", "挂号")
  24158. } else {
  24159. 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)
  24160. saveLog(result, requestLog, "2201A", "挂号")
  24161. }
  24162. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24163. utils.ErrorLog("解析失败:%v", err)
  24164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24165. return
  24166. }
  24167. infocode = resThree.Infcode
  24168. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  24169. psn_info, _ := service.GetPsnByPatientId(id)
  24170. var result string
  24171. var requestLog string
  24172. if id_card_type == 1 {
  24173. bas := strings.Split(psn_info.CardInfo, "|")
  24174. basNumber := bas[2]
  24175. card_sn := ""
  24176. 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)
  24177. saveLog(result, requestLog, "2201A", "挂号")
  24178. } else if id_card_type == 2 {
  24179. 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, "", "", "", "", "", "")
  24180. saveLog(result, requestLog, "2201A", "挂号")
  24181. } else {
  24182. 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)
  24183. saveLog(result, requestLog, "2201A", "挂号")
  24184. }
  24185. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24186. utils.ErrorLog("解析失败:%v", err)
  24187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24188. return
  24189. }
  24190. infocode = resThree.Infcode
  24191. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24192. psn_info, _ := service.GetPsnByPatientId(id)
  24193. his.PsnNo = psn_info.PsnNo
  24194. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24195. var cert_no string
  24196. if id_card_type == 1 {
  24197. bas := strings.Split(psn_info.CardInfo, "|")
  24198. cert_no = bas[2]
  24199. } else if id_card_type == 4 {
  24200. cert_no = psn_info.VerifyNumber
  24201. psn_info.VerifyNumber = psn_info.VerifyNumber
  24202. IdCardNo = psn_info.VerifyNumber
  24203. } else {
  24204. cert_no = IdCardNo
  24205. psn_info.VerifyNumber = cert_no
  24206. }
  24207. for _, item := range rf {
  24208. if item.Insutype == insutype {
  24209. his.InsuplcAdmdvs = insuplc_admdvs
  24210. }
  24211. }
  24212. his.Insutype = insutype
  24213. var api string
  24214. ipt_otp_no = timeFormat
  24215. 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 +
  24216. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24217. "&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
  24218. resp, requestErr := http.Get(api)
  24219. if requestErr != nil {
  24220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24221. return
  24222. }
  24223. body, ioErr := ioutil.ReadAll(resp.Body)
  24224. if ioErr != nil {
  24225. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24227. return
  24228. }
  24229. var respJSON map[string]interface{}
  24230. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24231. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24233. return
  24234. }
  24235. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24236. if status == "0" {
  24237. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24238. c.ServeSuccessJSON(map[string]interface{}{
  24239. "failed_code": -10,
  24240. "msg": err_msg,
  24241. })
  24242. return
  24243. }
  24244. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24245. result, _ := json.Marshal(respJSON)
  24246. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24247. utils.ErrorLog("解析失败:%v", err)
  24248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24249. return
  24250. }
  24251. infocode = resThree.Infcode
  24252. } else if miConfig.MdtrtareaAdmvs == "340699" {
  24253. psn_info, _ := service.GetPsnByPatientId(id)
  24254. his.PsnNo = psn_info.PsnNo
  24255. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24256. var cert_no string
  24257. if id_card_type == 1 {
  24258. bas := strings.Split(psn_info.CardInfo, "|")
  24259. cert_no = bas[2]
  24260. } else if id_card_type == 4 {
  24261. cert_no = psn_info.VerifyNumber
  24262. psn_info.VerifyNumber = psn_info.VerifyNumber
  24263. IdCardNo = psn_info.VerifyNumber
  24264. } else {
  24265. cert_no = IdCardNo
  24266. psn_info.VerifyNumber = cert_no
  24267. }
  24268. for _, item := range rf {
  24269. if item.Insutype == insutype {
  24270. his.InsuplcAdmdvs = insuplc_admdvs
  24271. patient.InsuplcAdmdvs = insuplc_admdvs
  24272. }
  24273. }
  24274. his.Insutype = insutype
  24275. var api string
  24276. ipt_otp_no = timeFormat
  24277. 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 +
  24278. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24279. "&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
  24280. resp, requestErr := http.Get(api)
  24281. if requestErr != nil {
  24282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24283. return
  24284. }
  24285. body, ioErr := ioutil.ReadAll(resp.Body)
  24286. if ioErr != nil {
  24287. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24289. return
  24290. }
  24291. var respJSON map[string]interface{}
  24292. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24293. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24295. return
  24296. }
  24297. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24298. if status == "0" {
  24299. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24300. c.ServeSuccessJSON(map[string]interface{}{
  24301. "failed_code": -10,
  24302. "msg": err_msg,
  24303. })
  24304. return
  24305. }
  24306. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24307. result, _ := json.Marshal(respJSON)
  24308. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24309. utils.ErrorLog("解析失败:%v", err)
  24310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24311. return
  24312. }
  24313. infocode = resThree.Infcode
  24314. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24315. psn_info, _ := service.GetPsnByPatientId(id)
  24316. var result string
  24317. var requestLog string
  24318. if id_card_type == 1 {
  24319. bas := strings.Split(psn_info.CardInfo, "|")
  24320. basNumber := bas[2]
  24321. card_sn := bas[3]
  24322. 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)
  24323. saveLog(result, requestLog, "2201A", "挂号")
  24324. } else if id_card_type == 2 {
  24325. 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, "", "")
  24326. saveLog(result, requestLog, "2201A", "挂号")
  24327. } else {
  24328. 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, "", "")
  24329. saveLog(result, requestLog, "2201A", "挂号")
  24330. }
  24331. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24332. utils.ErrorLog("解析失败:%v", err)
  24333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24334. return
  24335. }
  24336. infocode = resThree.Infcode
  24337. } else if miConfig.MdtrtareaAdmvs == "131023" {
  24338. psn_info, _ := service.GetPsnByPatientId(id)
  24339. 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)
  24340. saveLog(result, requestLog, "2201A", "挂号")
  24341. if miConfig.Code == "H15049901371" {
  24342. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24343. utils.ErrorLog("解析失败:%v", err)
  24344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24345. return
  24346. }
  24347. resThree.ErrMsg = resThree10265.ErrMsg
  24348. resThree.Output = resThree10265.Output
  24349. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24350. } else {
  24351. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24352. utils.ErrorLog("解析失败:%v", err)
  24353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24354. return
  24355. }
  24356. }
  24357. if miConfig.Code == "H15049901371" {
  24358. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24359. } else {
  24360. infocode = resThree.Infcode
  24361. }
  24362. } else {
  24363. psn_info, _ := service.GetPsnByPatientId(id)
  24364. if id_card_type == 4 || id_card_type == 1 {
  24365. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  24366. }
  24367. var rf []*ResultFive
  24368. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24369. var insutypes []*ResultFive
  24370. var insutype string
  24371. var is390 int = 0
  24372. var is310 int = 0
  24373. for _, item := range rf {
  24374. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24375. insutypes = append(insutypes, item)
  24376. }
  24377. }
  24378. if len(insutypes) == 1 {
  24379. insutype = insutypes[0].Insutype
  24380. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24381. } else {
  24382. for _, i := range insutypes {
  24383. if i.Insutype == "390" {
  24384. is390 = 1
  24385. }
  24386. if i.Insutype == "310" {
  24387. is310 = 1
  24388. }
  24389. }
  24390. }
  24391. if is390 == 1 {
  24392. insutype = "390"
  24393. }
  24394. if is310 == 1 {
  24395. insutype = "310"
  24396. }
  24397. fmt.Println(len(insutypes))
  24398. if len(insutypes) == 0 {
  24399. for index, item := range rf {
  24400. if index == 0 {
  24401. insutype = item.Insutype
  24402. insuplc_admdvs = item.InsuplcAdmdvs
  24403. }
  24404. }
  24405. fmt.Println(insutype)
  24406. fmt.Println(insuplc_admdvs)
  24407. }
  24408. if social_type > 0 {
  24409. insutype = strconv.FormatInt(social_type, 10)
  24410. }
  24411. fmt.Println("--------")
  24412. fmt.Println(psn_info)
  24413. fmt.Println(psn_info.PsnNo)
  24414. if miConfig.MdtrtareaAdmvs == "441202" {
  24415. var hisPrescription []*models.HisPrescription
  24416. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24417. if res3101.Infcode == 0 {
  24418. fmt.Println("33333333")
  24419. if len(res3101.Output.Result) > 0 {
  24420. fmt.Println("222222")
  24421. for _, item := range res3101.Output.Result {
  24422. if len(res3101.ErrMsg) == 0 {
  24423. res3101.ErrMsg = item.VolaCont
  24424. } else {
  24425. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24426. }
  24427. }
  24428. c.ServeSuccessJSON(map[string]interface{}{
  24429. "failed_code": -10,
  24430. "msg": res3101.ErrMsg,
  24431. })
  24432. return
  24433. } else {
  24434. hour := time.Now().Format("15")
  24435. min := time.Now().Format("04")
  24436. sec := time.Now().Format("05")
  24437. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24438. fmt.Println(record_time_two)
  24439. 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)
  24440. saveLog(result, requestLog, "2201A", "挂号")
  24441. if miConfig.Code == "H15049901371" {
  24442. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24443. utils.ErrorLog("解析失败:%v", err)
  24444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24445. return
  24446. }
  24447. resThree.ErrMsg = resThree10265.ErrMsg
  24448. resThree.Output = resThree10265.Output
  24449. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24450. } else {
  24451. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24452. utils.ErrorLog("解析失败:%v", err)
  24453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24454. return
  24455. }
  24456. }
  24457. if miConfig.Code == "H15049901371" {
  24458. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24459. } else {
  24460. infocode = resThree.Infcode
  24461. }
  24462. }
  24463. } else if res3101.Infcode != 0 {
  24464. c.ServeSuccessJSON(map[string]interface{}{
  24465. "failed_code": -10,
  24466. "msg": res3101.ErrMsg,
  24467. })
  24468. return
  24469. }
  24470. } else if miConfig.MdtrtareaAdmvs == "440205" {
  24471. var hisPrescription []*models.HisPrescription
  24472. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24473. if res3101.Infcode == 0 {
  24474. fmt.Println("33333333")
  24475. if len(res3101.Output.Result) > 0 {
  24476. fmt.Println("222222")
  24477. for _, item := range res3101.Output.Result {
  24478. if len(res3101.ErrMsg) == 0 {
  24479. res3101.ErrMsg = item.VolaCont
  24480. } else {
  24481. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24482. }
  24483. }
  24484. c.ServeSuccessJSON(map[string]interface{}{
  24485. "failed_code": -10,
  24486. "msg": res3101.ErrMsg,
  24487. })
  24488. return
  24489. } else {
  24490. hour := time.Now().Format("15")
  24491. min := time.Now().Format("04")
  24492. sec := time.Now().Format("05")
  24493. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24494. fmt.Println(record_time_two)
  24495. 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)
  24496. saveLog(result, requestLog, "2201A", "挂号")
  24497. if miConfig.Code == "H15049901371" {
  24498. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24499. utils.ErrorLog("解析失败:%v", err)
  24500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24501. return
  24502. }
  24503. resThree.ErrMsg = resThree10265.ErrMsg
  24504. resThree.Output = resThree10265.Output
  24505. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24506. } else {
  24507. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24508. utils.ErrorLog("解析失败:%v", err)
  24509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24510. return
  24511. }
  24512. }
  24513. if miConfig.Code == "H15049901371" {
  24514. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24515. } else {
  24516. infocode = resThree.Infcode
  24517. }
  24518. }
  24519. } else if res3101.Infcode != 0 {
  24520. c.ServeSuccessJSON(map[string]interface{}{
  24521. "failed_code": -10,
  24522. "msg": res3101.ErrMsg,
  24523. })
  24524. return
  24525. }
  24526. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24527. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  24528. psn_info, _ := service.GetPsnByPatientId(id)
  24529. var verify_number string
  24530. if id_card_type == 4 {
  24531. verify_number = psn_info.VerifyNumber
  24532. } else if id_card_type == 1 {
  24533. bas := strings.Split(psn_info.CardInfo, "|")
  24534. cardNumber := bas[2]
  24535. verify_number = cardNumber
  24536. } else {
  24537. verify_number = psn_info.Certno
  24538. }
  24539. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  24540. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  24541. "&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
  24542. resp, requestErr := http.Get(api)
  24543. if requestErr != nil {
  24544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24545. return
  24546. }
  24547. body, ioErr := ioutil.ReadAll(resp.Body)
  24548. if ioErr != nil {
  24549. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24551. return
  24552. }
  24553. var respJSON map[string]interface{}
  24554. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24555. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24557. return
  24558. }
  24559. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24560. result, _ := json.Marshal(respJSON)
  24561. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24562. utils.ErrorLog("解析失败:%v", err)
  24563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24564. return
  24565. }
  24566. infocode = resThree.Infcode
  24567. } else {
  24568. hour := time.Now().Format("15")
  24569. min := time.Now().Format("04")
  24570. sec := time.Now().Format("05")
  24571. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24572. if id_card_type == 1 {
  24573. for _, item := range rf {
  24574. if item.Insutype == strconv.FormatInt(social_type, 10) {
  24575. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  24576. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24577. } else if strconv.FormatInt(social_type, 10) == "390" {
  24578. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24579. } else {
  24580. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24581. }
  24582. }
  24583. }
  24584. }
  24585. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  24586. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24587. }
  24588. if id_card_type == 1 {
  24589. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  24590. bas := strings.Split(psn_info.CardInfo, "|")
  24591. basNumber := bas[1]
  24592. IdCardNo = basNumber
  24593. }
  24594. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  24595. IdCardNo = psn_info.VerifyNumber
  24596. }
  24597. if len(insuplc_admdvs_temp) == 0 {
  24598. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  24599. }
  24600. var result string
  24601. var requestLog string
  24602. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" {
  24603. var hisPrescription []*models.HisPrescription
  24604. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  24605. if res3101.Infcode == 0 {
  24606. if len(res3101.Output.Result) > 0 {
  24607. for _, item := range res3101.Output.Result {
  24608. if len(res3101.ErrMsg) == 0 {
  24609. res3101.ErrMsg = item.VolaCont
  24610. } else {
  24611. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  24612. }
  24613. }
  24614. c.ServeSuccessJSON(map[string]interface{}{
  24615. "failed_code": -10,
  24616. "msg": res3101.ErrMsg,
  24617. })
  24618. return
  24619. } else {
  24620. hour := time.Now().Format("15")
  24621. min := time.Now().Format("04")
  24622. sec := time.Now().Format("05")
  24623. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  24624. fmt.Println(record_time_two)
  24625. if his.IdCardType == 2 {
  24626. IdCardNo = psn_info.Certno
  24627. psn_info.VerifyNumber = psn_info.Certno
  24628. } else if his.IdCardType == 4 {
  24629. IdCardNo = psn_info.Certno
  24630. } else {
  24631. bas := strings.Split(psn_info.CardInfo, "|")
  24632. IdCardNo = bas[2]
  24633. }
  24634. 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)
  24635. saveLog(result, requestLog, "2201A", "挂号")
  24636. if miConfig.Code == "H15049901371" {
  24637. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24638. utils.ErrorLog("解析失败:%v", err)
  24639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24640. return
  24641. }
  24642. resThree.ErrMsg = resThree10265.ErrMsg
  24643. resThree.Output = resThree10265.Output
  24644. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24645. } else {
  24646. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24647. utils.ErrorLog("解析失败:%v", err)
  24648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24649. return
  24650. }
  24651. }
  24652. if miConfig.Code == "H15049901371" {
  24653. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24654. } else {
  24655. infocode = resThree.Infcode
  24656. }
  24657. }
  24658. } else if res3101.Infcode != 0 {
  24659. c.ServeSuccessJSON(map[string]interface{}{
  24660. "failed_code": -10,
  24661. "msg": res3101.ErrMsg,
  24662. })
  24663. return
  24664. }
  24665. } else {
  24666. psn_info, _ := service.GetPsnByPatientId(id)
  24667. var rf []*ResultFive
  24668. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  24669. //var insutypes []*ResultFive
  24670. var insutype string
  24671. var insutypes []*ResultFive
  24672. var is390 int = 0
  24673. var is310 int = 0
  24674. for _, item := range rf {
  24675. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24676. insutypes = append(insutypes, item)
  24677. }
  24678. }
  24679. if len(insutypes) == 1 {
  24680. insutype = insutypes[0].Insutype
  24681. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  24682. } else {
  24683. for _, i := range insutypes {
  24684. if i.Insutype == "390" {
  24685. is390 = 1
  24686. }
  24687. if i.Insutype == "310" {
  24688. is310 = 1
  24689. }
  24690. }
  24691. }
  24692. if is390 == 1 {
  24693. insutype = "390"
  24694. }
  24695. if is310 == 1 {
  24696. insutype = "310"
  24697. }
  24698. if len(insutypes) == 0 {
  24699. insutype = "310"
  24700. }
  24701. if social_type > 0 {
  24702. insutype = strconv.FormatInt(social_type, 10)
  24703. }
  24704. for _, item := range rf {
  24705. utils.ErrorLog("解析失败:%v", item.Insutype)
  24706. utils.ErrorLog("解析失败:%v", insutype)
  24707. if item.Insutype == insutype {
  24708. insuplc_admdvs_temp = item.InsuplcAdmdvs
  24709. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  24710. }
  24711. }
  24712. 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)
  24713. saveLog(result, requestLog, "2201A", "挂号")
  24714. }
  24715. if miConfig.Code == "H15049901371" {
  24716. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  24717. utils.ErrorLog("解析失败:%v", err)
  24718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24719. return
  24720. }
  24721. resThree.ErrMsg = resThree10265.ErrMsg
  24722. resThree.Output = resThree10265.Output
  24723. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  24724. } else {
  24725. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  24726. utils.ErrorLog("解析失败:%v", err)
  24727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24728. return
  24729. }
  24730. }
  24731. if miConfig.Code == "H15049901371" {
  24732. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  24733. } else {
  24734. infocode = resThree.Infcode
  24735. }
  24736. }
  24737. }
  24738. if infocode == -1 {
  24739. adminUser := c.GetAdminUserInfo()
  24740. errlog := &models.HisOrderError{
  24741. UserOrgId: adminUser.CurrentOrgId,
  24742. Ctime: time.Now().Unix(),
  24743. Mtime: time.Now().Unix(),
  24744. ErrMsg: resThree.ErrMsg,
  24745. Status: 1,
  24746. PatientId: id,
  24747. RecordTime: recordDateTime,
  24748. Stage: 2,
  24749. }
  24750. service.CreateErrMsgLog(errlog)
  24751. c.ServeSuccessJSON(map[string]interface{}{
  24752. "failed_code": -10,
  24753. "msg": resThree.ErrMsg,
  24754. })
  24755. return
  24756. }
  24757. his.Number = resThree.Output.Data.MdtrtID
  24758. his.PsnNo = resThree.Output.Data.PsnNo
  24759. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  24760. his.IdCardNo = patient.IdCardNo
  24761. his.PhoneNumber = patient.Phone
  24762. his.UserOrgId = adminInfo.CurrentOrgId
  24763. his.Insutype = insutype
  24764. his.Ctime = time.Now().Unix()
  24765. his.Mtime = time.Now().Unix()
  24766. his.InsuplcAdmdvs = insuplc_admdvs_temp
  24767. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  24768. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24769. }
  24770. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  24771. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24772. }
  24773. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  24774. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  24775. }
  24776. his.Status = 1
  24777. his.MdtrtGrpType = mdtrt_type
  24778. service.UpdateHisPatientStatus(&his)
  24779. service.UpdateHisPatient123(&patient)
  24780. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  24781. c.ServeSuccessJSON(map[string]interface{}{
  24782. "his_info": his,
  24783. })
  24784. } else {
  24785. adminUser := c.GetAdminUserInfo()
  24786. errlog := &models.HisOrderError{
  24787. UserOrgId: adminUser.CurrentOrgId,
  24788. Ctime: time.Now().Unix(),
  24789. Mtime: time.Now().Unix(),
  24790. ErrMsg: res.ErrMsg,
  24791. Status: 1,
  24792. PatientId: id,
  24793. RecordTime: recordDateTime,
  24794. Stage: 1,
  24795. }
  24796. service.CreateErrMsgLog(errlog)
  24797. c.ServeSuccessJSON(map[string]interface{}{
  24798. "failed_code": -10,
  24799. "msg": res.ErrMsg,
  24800. })
  24801. return
  24802. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  24803. }
  24804. }
  24805. }
  24806. func (c *HisApiController) GetUploadInfo() {
  24807. id, _ := c.GetInt64("id")
  24808. record_time := c.GetString("record_time")
  24809. his_patient_id, _ := c.GetInt64("his_patient_id")
  24810. order_id, _ := c.GetInt64("order_id")
  24811. pay_way, _ := c.GetInt64("pay_way")
  24812. pay_ways := c.GetString("pay_ways")
  24813. oth_desc := c.GetString("oth_desc")
  24814. pay_price, _ := c.GetFloat("pay_price")
  24815. pay_card_no := c.GetString("pay_card_no")
  24816. discount_price, _ := c.GetFloat("discount_price")
  24817. preferential_price, _ := c.GetFloat("preferential_price")
  24818. reality_price, _ := c.GetFloat("reality_price")
  24819. found_price, _ := c.GetFloat("found_price")
  24820. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  24821. private_price, _ := c.GetFloat("private_price")
  24822. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  24823. admin_user_id, _ := c.GetInt64("admin_user_id")
  24824. fapiao_code := c.GetString("fapiao_code")
  24825. fapiao_number := c.GetString("fapiao_number")
  24826. diagnosis_id := c.GetString("diagnosis")
  24827. sick_type, _ := c.GetInt64("sick_type")
  24828. reg_type, _ := c.GetInt64("p_type")
  24829. begin_time := c.GetString("begin_time")
  24830. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  24831. cash_pay := c.GetString("cash_pay")
  24832. band_card_pay := c.GetString("band_card_pay")
  24833. wechat_pay := c.GetString("wechat_pay")
  24834. ali_pay := c.GetString("ali_pay")
  24835. jifen_pay := c.GetString("jifen_pay")
  24836. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  24837. fmt.Println(acct_used_flag)
  24838. id_str := c.GetString("ids")
  24839. ids_arr := strings.Split(id_str, ",")
  24840. timeLayout := "2006-01-02"
  24841. loc, _ := time.LoadLocation("Local")
  24842. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24843. if err != nil {
  24844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24845. return
  24846. }
  24847. recordDateTime := theTime.Unix()
  24848. adminUser := c.GetAdminUserInfo()
  24849. var tempOrder models.HisOrder
  24850. tempOrder, _ = service.GetHisOrderByID(order_id)
  24851. var prescriptions []*models.HisPrescription
  24852. var start_time int64
  24853. var end_time int64
  24854. //押金模块
  24855. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  24856. tmp_decimal := c.GetString("tmp_decimal")
  24857. var decimal float64 //本次使用的押金
  24858. var errmsg error
  24859. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  24860. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  24861. return
  24862. }
  24863. if len(tmp_decimal) > 0 {
  24864. if tmp_decimal[0] == 45 {
  24865. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  24866. return
  24867. }
  24868. }
  24869. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  24870. fmt.Println(errs)
  24871. decimal = tt
  24872. //if adminUser.CurrentOrgId == 10106{
  24873. // if len(fapiao_code) == 0{
  24874. // fapiao_code = "144072080589"
  24875. // }
  24876. // if len(fapiao_number) == 0{
  24877. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  24878. // if order.ID == 0{
  24879. // fapiao_number = "00001520"
  24880. // }else{
  24881. // //fapiao_code = "00001520"
  24882. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  24883. // var zero string
  24884. // if fpNumber >= 1000{
  24885. // zero = "0000" + strconv.Itoa(fpNumber)
  24886. // }else if fpNumber >= 10000{
  24887. // zero = "000" + strconv.Itoa(fpNumber)
  24888. // } else if fpNumber >= 100000{
  24889. // zero = "00" + strconv.Itoa(fpNumber)
  24890. // } else if fpNumber >= 1000000{
  24891. // zero = "0" + strconv.Itoa(fpNumber)
  24892. // }else {
  24893. // zero = strconv.Itoa(fpNumber)
  24894. // }
  24895. // fapiao_number = zero
  24896. // }
  24897. // }
  24898. //}
  24899. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24900. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24901. var patientPrescription models.HisPrescriptionInfo
  24902. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24903. if patientPrescription.ID == 0 {
  24904. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  24905. }
  24906. //if patientPrescription.Do
  24907. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24908. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  24909. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  24910. diagnosis_ids := strings.Split(diagnosis_id, ",")
  24911. var config []*models.HisXtDiagnoseConfig
  24912. for _, item := range diagnosis_ids {
  24913. id, _ := strconv.ParseInt(item, 10, 64)
  24914. diagnosisConfig, _ := service.FindDiagnoseById(id)
  24915. config = append(config, &diagnosisConfig)
  24916. }
  24917. sickConfig, _ := service.FindSickById(sick_type)
  24918. //if tempOrder.ID == 0 {
  24919. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  24920. //}
  24921. if tempOrder.ID == 0 {
  24922. var result string
  24923. var requestLog string
  24924. var res2 ResultSix
  24925. var res3 GZResultSix
  24926. var ressix10265 ResultSix10265
  24927. if miConfig.MdtrtareaAdmvs == "421300" {
  24928. data := make(map[string]interface{})
  24929. client := &http.Client{}
  24930. data["psn_no"] = his.PsnNo
  24931. data["mdtrt_id"] = his.Number
  24932. data["opter"] = roles.UserName
  24933. data["org_name"] = miConfig.OrgName
  24934. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24935. data["doctor_id"] = doctor_info.DoctorNumber
  24936. data["doctor_name"] = doctor_info.UserName
  24937. data["department"] = department.Name
  24938. data["fixmedins_code"] = miConfig.Code
  24939. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24940. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24941. data["secret_key"] = miConfig.SecretKey
  24942. data["sick_code"] = sickConfig.CountryCode
  24943. data["sick_name"] = sickConfig.ClassName
  24944. data["dept"] = strconv.FormatInt(department.ID, 10)
  24945. data["config"] = config
  24946. data["begin_time"] = begin_time
  24947. bytesData, _ := json.Marshal(data)
  24948. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24949. resp, _ := client.Do(req)
  24950. defer resp.Body.Close()
  24951. body, ioErr := ioutil.ReadAll(resp.Body)
  24952. if ioErr != nil {
  24953. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24955. return
  24956. }
  24957. var respJSON map[string]interface{}
  24958. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  24959. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24961. return
  24962. }
  24963. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24964. userJSONBytes, _ := json.Marshal(respJSON)
  24965. fmt.Println("log")
  24966. fmt.Println(string(userJSONBytes))
  24967. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24968. utils.ErrorLog("解析失败:%v", err)
  24969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24970. return
  24971. }
  24972. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24973. data := make(map[string]interface{})
  24974. client := &http.Client{}
  24975. data["psn_no"] = his.PsnNo
  24976. data["mdtrt_id"] = his.Number
  24977. data["opter"] = roles.UserName
  24978. data["org_name"] = miConfig.OrgName
  24979. if reg_type == 11 && his.Insutype == "390" {
  24980. data["med_type"] = "110104"
  24981. } else {
  24982. data["med_type"] = strconv.FormatInt(reg_type, 10)
  24983. }
  24984. data["doctor_id"] = doctor_info.DoctorNumber
  24985. data["doctor_name"] = doctor_info.UserName
  24986. data["department"] = department.Name
  24987. data["fixmedins_code"] = miConfig.Code
  24988. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  24989. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  24990. data["secret_key"] = miConfig.SecretKey
  24991. data["sick_code"] = sickConfig.CountryCode
  24992. data["sick_name"] = sickConfig.ClassName
  24993. data["dept"] = strconv.FormatInt(department.ID, 10)
  24994. data["config"] = config
  24995. data["begin_time"] = begin_time
  24996. bytesData, _ := json.Marshal(data)
  24997. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  24998. resp, _ := client.Do(req)
  24999. defer resp.Body.Close()
  25000. body, ioErr := ioutil.ReadAll(resp.Body)
  25001. if ioErr != nil {
  25002. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25004. return
  25005. }
  25006. var respJSON map[string]interface{}
  25007. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25008. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25010. return
  25011. }
  25012. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25013. userJSONBytes, _ := json.Marshal(respJSON)
  25014. fmt.Println("log")
  25015. fmt.Println(string(userJSONBytes))
  25016. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25017. utils.ErrorLog("解析失败:%v", err)
  25018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25019. return
  25020. }
  25021. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25022. data := make(map[string]interface{})
  25023. client := &http.Client{}
  25024. data["psn_no"] = his.PsnNo
  25025. data["mdtrt_id"] = his.Number
  25026. data["opter"] = roles.UserName
  25027. data["org_name"] = miConfig.OrgName
  25028. if reg_type == 11 && his.Insutype == "390" {
  25029. data["med_type"] = "110104"
  25030. } else {
  25031. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25032. }
  25033. data["doctor_id"] = doctor_info.DoctorNumber
  25034. data["doctor_name"] = doctor_info.UserName
  25035. data["department"] = department.Name
  25036. data["fixmedins_code"] = miConfig.Code
  25037. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25038. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25039. data["secret_key"] = miConfig.SecretKey
  25040. data["sick_code"] = sickConfig.CountryCode
  25041. data["sick_name"] = sickConfig.ClassName
  25042. data["dept"] = strconv.FormatInt(department.ID, 10)
  25043. data["config"] = config
  25044. data["begin_time"] = begin_time
  25045. bytesData, _ := json.Marshal(data)
  25046. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25047. resp, _ := client.Do(req)
  25048. defer resp.Body.Close()
  25049. body, ioErr := ioutil.ReadAll(resp.Body)
  25050. if ioErr != nil {
  25051. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25053. return
  25054. }
  25055. var respJSON map[string]interface{}
  25056. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25059. return
  25060. }
  25061. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25062. userJSONBytes, _ := json.Marshal(respJSON)
  25063. fmt.Println("log")
  25064. fmt.Println(string(userJSONBytes))
  25065. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25066. utils.ErrorLog("解析失败:%v", err)
  25067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25068. return
  25069. }
  25070. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25071. data := make(map[string]interface{})
  25072. client := &http.Client{}
  25073. data["psn_no"] = his.PsnNo
  25074. data["mdtrt_id"] = his.Number
  25075. data["opter"] = roles.UserName
  25076. data["org_name"] = miConfig.OrgName
  25077. if reg_type == 11 && his.Insutype == "390" {
  25078. data["med_type"] = "110104"
  25079. } else {
  25080. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25081. }
  25082. data["doctor_id"] = doctor_info.DoctorNumber
  25083. data["doctor_name"] = doctor_info.UserName
  25084. data["department"] = department.Name
  25085. data["fixmedins_code"] = miConfig.Code
  25086. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25087. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25088. data["secret_key"] = miConfig.SecretKey
  25089. data["sick_code"] = sickConfig.CountryCode
  25090. data["sick_name"] = sickConfig.ClassName
  25091. data["dept"] = strconv.FormatInt(department.ID, 10)
  25092. data["config"] = config
  25093. data["begin_time"] = begin_time
  25094. bytesData, _ := json.Marshal(data)
  25095. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25096. resp, _ := client.Do(req)
  25097. defer resp.Body.Close()
  25098. body, ioErr := ioutil.ReadAll(resp.Body)
  25099. if ioErr != nil {
  25100. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25102. return
  25103. }
  25104. var respJSON map[string]interface{}
  25105. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25106. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25108. return
  25109. }
  25110. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25111. userJSONBytes, _ := json.Marshal(respJSON)
  25112. fmt.Println("log")
  25113. fmt.Println(string(userJSONBytes))
  25114. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25115. utils.ErrorLog("解析失败:%v", err)
  25116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25117. return
  25118. }
  25119. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25120. data := make(map[string]interface{})
  25121. client := &http.Client{}
  25122. data["psn_no"] = his.PsnNo
  25123. data["mdtrt_id"] = his.Number
  25124. data["doctor"] = roles.UserName
  25125. data["department"] = department.Name
  25126. data["org_name"] = miConfig.OrgName
  25127. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25128. data["doctor_id"] = doctor_info.DoctorNumber
  25129. data["new_doctor_name"] = doctor_info.UserName
  25130. data["fixmedins_code"] = miConfig.Code
  25131. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25132. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25133. data["secret_key"] = miConfig.SecretKey
  25134. data["sick_code"] = sickConfig.CountryCode
  25135. data["sick_name"] = sickConfig.ClassName
  25136. data["url"] = miConfig.Url
  25137. data["ak"] = miConfig.AccessKey
  25138. data["begin_time"] = begin_time
  25139. data["cainfo"] = miConfig.Cainfo
  25140. data["dept"] = strconv.FormatInt(department.ID, 10)
  25141. data["config"] = config
  25142. bytesData, _ := json.Marshal(data)
  25143. var req *http.Request
  25144. if miConfig.MdtrtareaAdmvs == "320921" {
  25145. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25146. //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 +
  25147. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  25148. } else {
  25149. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25150. }
  25151. resp, _ := client.Do(req)
  25152. defer resp.Body.Close()
  25153. body, ioErr := ioutil.ReadAll(resp.Body)
  25154. if ioErr != nil {
  25155. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25157. return
  25158. }
  25159. var respJSON map[string]interface{}
  25160. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25161. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25163. return
  25164. }
  25165. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25166. userJSONBytes, _ := json.Marshal(respJSON)
  25167. fmt.Println("log")
  25168. fmt.Println(string(userJSONBytes))
  25169. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25170. utils.ErrorLog("解析失败:%v", err)
  25171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25172. return
  25173. }
  25174. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25175. res2.Output = ressix10265.Output
  25176. res2.ErrMsg = ressix10265.ErrMsg
  25177. res2.Cainfo = ressix10265.Cainfo
  25178. res2.WarnMsg = ressix10265.WarnMsg
  25179. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25180. res2.Infcode = infocode
  25181. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25182. data := make(map[string]interface{})
  25183. client := &http.Client{}
  25184. data["psn_no"] = his.PsnNo
  25185. data["mdtrt_id"] = his.Number
  25186. data["doctor"] = roles.UserName
  25187. data["department"] = department.Name
  25188. data["org_name"] = miConfig.OrgName
  25189. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25190. data["doctor_id"] = doctor_info.DoctorNumber
  25191. data["new_doctor_name"] = doctor_info.UserName
  25192. data["fixmedins_code"] = miConfig.Code
  25193. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25194. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25195. data["secret_key"] = miConfig.SecretKey
  25196. data["sick_code"] = sickConfig.CountryCode
  25197. data["sick_name"] = sickConfig.ClassName
  25198. data["url"] = miConfig.Url
  25199. data["ak"] = miConfig.AccessKey
  25200. data["begin_time"] = begin_time
  25201. data["cainfo"] = miConfig.Cainfo
  25202. data["dept"] = strconv.FormatInt(department.ID, 10)
  25203. data["config"] = config
  25204. bytesData, _ := json.Marshal(data)
  25205. var req *http.Request
  25206. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  25207. resp, _ := client.Do(req)
  25208. defer resp.Body.Close()
  25209. body, ioErr := ioutil.ReadAll(resp.Body)
  25210. if ioErr != nil {
  25211. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25213. return
  25214. }
  25215. var respJSON map[string]interface{}
  25216. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25217. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25219. return
  25220. }
  25221. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25222. userJSONBytes, _ := json.Marshal(respJSON)
  25223. fmt.Println("log")
  25224. fmt.Println(string(userJSONBytes))
  25225. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  25226. utils.ErrorLog("解析失败:%v", err)
  25227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25228. return
  25229. }
  25230. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25231. res2.Output = ressix10265.Output
  25232. res2.ErrMsg = ressix10265.ErrMsg
  25233. res2.Cainfo = ressix10265.Cainfo
  25234. res2.WarnMsg = ressix10265.WarnMsg
  25235. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25236. res2.Infcode = infocode
  25237. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25238. 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)
  25239. saveLog(result, requestLog, "2203", "上传就诊信息")
  25240. var respJSON2 map[string]interface{}
  25241. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25242. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25244. return
  25245. }
  25246. userJSONBytes2, _ := json.Marshal(respJSON2)
  25247. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25248. utils.ErrorLog("解析失败:%v", err)
  25249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25250. return
  25251. }
  25252. 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)
  25253. fmt.Println(result2)
  25254. fmt.Println(src_request)
  25255. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25256. data := make(map[string]interface{})
  25257. client := &http.Client{}
  25258. data["psn_no"] = his.PsnNo
  25259. data["mdtrt_id"] = his.Number
  25260. data["doctor"] = roles.UserName
  25261. data["department"] = department.Name
  25262. data["org_name"] = miConfig.OrgName
  25263. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25264. data["doctor_id"] = doctor_info.DoctorNumber
  25265. data["new_doctor_name"] = doctor_info.UserName
  25266. data["fixmedins_code"] = miConfig.Code
  25267. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25268. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25269. data["secret_key"] = miConfig.SecretKey
  25270. data["sick_code"] = sickConfig.CountryCode
  25271. data["sick_name"] = sickConfig.ClassName
  25272. data["url"] = miConfig.Url
  25273. data["ak"] = miConfig.AccessKey
  25274. data["begin_time"] = begin_time
  25275. data["cainfo"] = miConfig.Cainfo
  25276. data["dept"] = strconv.FormatInt(department.ID, 10)
  25277. data["config"] = config
  25278. bytesData, _ := json.Marshal(data)
  25279. var req *http.Request
  25280. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  25281. resp, _ := client.Do(req)
  25282. defer resp.Body.Close()
  25283. body, ioErr := ioutil.ReadAll(resp.Body)
  25284. if ioErr != nil {
  25285. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25287. return
  25288. }
  25289. var respJSON map[string]interface{}
  25290. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25291. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25293. return
  25294. }
  25295. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25296. userJSONBytes, _ := json.Marshal(respJSON)
  25297. fmt.Println("log")
  25298. fmt.Println(string(userJSONBytes))
  25299. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25300. utils.ErrorLog("解析失败:%v", err)
  25301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25302. return
  25303. }
  25304. } else {
  25305. if miConfig.MdtrtareaAdmvs == "440781" { //
  25306. 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)
  25307. } else {
  25308. if miConfig.Code == "H15049901371" {
  25309. //赤峰地区国家医保医疗类别
  25310. //职工透析:医疗类别选特殊情况门诊990502
  25311. //居民定额血透门慢: 医疗类别选门诊慢病140104
  25312. var med_type string
  25313. if his.Insutype == "390" {
  25314. if reg_type == 14 {
  25315. med_type = "9933"
  25316. } else if reg_type == 11 {
  25317. med_type = "11"
  25318. }
  25319. } else if his.Insutype == "310" {
  25320. if reg_type == 14 {
  25321. med_type = "990502"
  25322. } else if reg_type == 11 {
  25323. med_type = "11"
  25324. }
  25325. }
  25326. 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)
  25327. } else {
  25328. 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)
  25329. }
  25330. }
  25331. saveLog(result, requestLog, "2203", "上传就诊信息")
  25332. var respJSON2 map[string]interface{}
  25333. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25334. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25336. return
  25337. }
  25338. userJSONBytes2, _ := json.Marshal(respJSON2)
  25339. if miConfig.Code == "H15049901371" {
  25340. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  25341. utils.ErrorLog("解析失败:%v", err)
  25342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25343. return
  25344. }
  25345. res2.InfRefmsgid = ressix10265.InfRefmsgid
  25346. res2.Output = ressix10265.Output
  25347. res2.ErrMsg = ressix10265.ErrMsg
  25348. res2.Cainfo = ressix10265.Cainfo
  25349. res2.WarnMsg = ressix10265.WarnMsg
  25350. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  25351. res2.Infcode = infocode
  25352. } else {
  25353. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25354. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  25355. utils.ErrorLog("解析失败:%v", err)
  25356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25357. return
  25358. }
  25359. res2.Infcode = res3.Infcode
  25360. } else {
  25361. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  25362. utils.ErrorLog("解析失败:%v", err)
  25363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25364. return
  25365. }
  25366. }
  25367. }
  25368. }
  25369. if res2.Infcode == -1 {
  25370. adminUser := c.GetAdminUserInfo()
  25371. errlog := &models.HisOrderError{
  25372. UserOrgId: adminUser.CurrentOrgId,
  25373. Ctime: time.Now().Unix(),
  25374. Mtime: time.Now().Unix(),
  25375. ErrMsg: res2.ErrMsg,
  25376. Status: 1,
  25377. PatientId: id,
  25378. RecordTime: recordDateTime,
  25379. Stage: 3,
  25380. }
  25381. service.CreateErrMsgLog(errlog)
  25382. c.ServeSuccessJSON(map[string]interface{}{
  25383. "failed_code": -10,
  25384. "msg": res2.ErrMsg,
  25385. })
  25386. return
  25387. } else {
  25388. his.Diagnosis = diagnosis_id
  25389. his.SickType = sickConfig.ID
  25390. //var p_type int64
  25391. //if reg_type == 1111 || reg_type == 1112 {
  25392. // p_type = 11
  25393. //
  25394. //}
  25395. his.PType = fmt.Sprintf("%d", reg_type)
  25396. service.UpdateHisPatientThree(&his)
  25397. data := make(map[string]interface{})
  25398. if settle_accounts_type == 1 { //日结
  25399. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  25400. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  25401. } else {
  25402. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  25403. }
  25404. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  25405. data["pre"] = prescriptions
  25406. } else { //月结
  25407. start_time_str := c.GetString("start_time")
  25408. end_time_str := c.GetString("end_time")
  25409. timeLayout := "2006-01-02"
  25410. loc, _ := time.LoadLocation("Local")
  25411. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  25412. if err != nil {
  25413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25414. return
  25415. }
  25416. recordStartTime := theStartTime.Unix()
  25417. start_time = recordStartTime
  25418. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  25419. if err != nil {
  25420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25421. return
  25422. }
  25423. recordEndTime := theEndTime.Unix()
  25424. end_time = recordEndTime
  25425. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  25426. data["pre"] = prescriptions
  25427. }
  25428. timestamp := time.Now().Unix()
  25429. tempTime := time.Unix(timestamp, 0)
  25430. timeFormat := tempTime.Format("20060102150405")
  25431. chrgBchno := rand.Intn(100000) + 10000
  25432. new_chrg_bchno := ""
  25433. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  25434. new_chrg_bchno = chrg_bchno
  25435. strconv.FormatInt(his.PatientId, 10)
  25436. client := &http.Client{}
  25437. if adminUser.CurrentOrgId == 10265 {
  25438. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  25439. new_chrg_bchno = "0000"
  25440. }
  25441. }
  25442. data["psn_no"] = his.PsnNo
  25443. data["mdtrt_id"] = his.Number
  25444. data["chrg_bchno"] = new_chrg_bchno
  25445. data["org_name"] = miConfig.OrgName
  25446. data["doctor"] = doctor_info.UserName
  25447. data["doctor_id"] = doctor_info.DoctorNumber
  25448. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  25449. data["fixmedins_code"] = miConfig.Code
  25450. data["dept_code"] = department.Number
  25451. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25452. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25453. data["secret_key"] = miConfig.SecretKey
  25454. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  25455. data["url"] = miConfig.Url
  25456. data["ak"] = miConfig.AccessKey
  25457. data["new_doctor_name"] = patientPrescription.Doctor
  25458. data["diag_code"] = sickConfig.CountryCode
  25459. data["cainfo"] = miConfig.Cainfo
  25460. data["opter"] = roles.UserName
  25461. var ids []int64
  25462. for _, item := range prescriptions {
  25463. ids = append(ids, item.ID)
  25464. }
  25465. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25466. if config.IsOpen == 1 { //对接了医保,走医保流程
  25467. var res ResultFour
  25468. var resFour10265 ResultFour10265
  25469. if miConfig.MdtrtareaAdmvs == "421300" {
  25470. bytesData, _ := json.Marshal(data)
  25471. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25472. resp, _ := client.Do(req)
  25473. defer resp.Body.Close()
  25474. body, ioErr := ioutil.ReadAll(resp.Body)
  25475. if ioErr != nil {
  25476. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25478. return
  25479. }
  25480. var respJSON map[string]interface{}
  25481. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25482. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25484. return
  25485. }
  25486. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25487. userJSONBytes, _ := json.Marshal(respJSON)
  25488. fmt.Println("log")
  25489. fmt.Println(string(userJSONBytes))
  25490. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25491. utils.ErrorLog("解析失败:%v", err)
  25492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25493. return
  25494. }
  25495. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25496. bytesData, _ := json.Marshal(data)
  25497. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  25498. resp, _ := client.Do(req)
  25499. defer resp.Body.Close()
  25500. body, ioErr := ioutil.ReadAll(resp.Body)
  25501. if ioErr != nil {
  25502. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25504. return
  25505. }
  25506. var respJSON map[string]interface{}
  25507. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25508. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25510. return
  25511. }
  25512. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25513. userJSONBytes, _ := json.Marshal(respJSON)
  25514. fmt.Println("log")
  25515. fmt.Println(string(userJSONBytes))
  25516. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25517. utils.ErrorLog("解析失败:%v", err)
  25518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25519. return
  25520. }
  25521. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25522. bytesData, _ := json.Marshal(data)
  25523. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25524. resp, _ := client.Do(req)
  25525. defer resp.Body.Close()
  25526. body, ioErr := ioutil.ReadAll(resp.Body)
  25527. if ioErr != nil {
  25528. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25530. return
  25531. }
  25532. var respJSON map[string]interface{}
  25533. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25534. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25536. return
  25537. }
  25538. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25539. userJSONBytes, _ := json.Marshal(respJSON)
  25540. fmt.Println("log")
  25541. fmt.Println(string(userJSONBytes))
  25542. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25543. utils.ErrorLog("解析失败:%v", err)
  25544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25545. return
  25546. }
  25547. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25548. bytesData, _ := json.Marshal(data)
  25549. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  25550. resp, _ := client.Do(req)
  25551. defer resp.Body.Close()
  25552. body, ioErr := ioutil.ReadAll(resp.Body)
  25553. if ioErr != nil {
  25554. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25556. return
  25557. }
  25558. var respJSON map[string]interface{}
  25559. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25560. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25562. return
  25563. }
  25564. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25565. userJSONBytes, _ := json.Marshal(respJSON)
  25566. fmt.Println("log")
  25567. fmt.Println(string(userJSONBytes))
  25568. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25569. utils.ErrorLog("解析失败:%v", err)
  25570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25571. return
  25572. }
  25573. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25574. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  25575. if result3101.Infcode == "0" {
  25576. if len(result3101.Output.Result) > 0 {
  25577. var errMsgs []string
  25578. for _, item := range result3101.Output.Result {
  25579. errMsgs = append(errMsgs, item.VolaCont)
  25580. }
  25581. c.ServeSuccessJSON(map[string]interface{}{
  25582. "failed_code": -10,
  25583. "msg": errMsgs,
  25584. })
  25585. return
  25586. }
  25587. }
  25588. bytesData, _ := json.Marshal(data)
  25589. var req *http.Request
  25590. if miConfig.MdtrtareaAdmvs == "320921" {
  25591. data["diag_code"] = sickConfig.CountryCode
  25592. fmt.Println(data)
  25593. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25594. } else {
  25595. data["diag_code"] = sickConfig.CountryCode
  25596. fmt.Println(data)
  25597. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25598. }
  25599. resp, _ := client.Do(req)
  25600. defer resp.Body.Close()
  25601. body, ioErr := ioutil.ReadAll(resp.Body)
  25602. if ioErr != nil {
  25603. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25605. return
  25606. }
  25607. var respJSON map[string]interface{}
  25608. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25609. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25611. return
  25612. }
  25613. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25614. userJSONBytes, _ := json.Marshal(respJSON)
  25615. fmt.Println("log")
  25616. fmt.Println(string(userJSONBytes))
  25617. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25618. utils.ErrorLog("解析失败:%v", err)
  25619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25620. return
  25621. }
  25622. res.InfRefmsgid = resFour10265.InfRefmsgid
  25623. res.Output = resFour10265.Output
  25624. res.ErrMsg = resFour10265.ErrMsg
  25625. res.Cainfo = resFour10265.Cainfo
  25626. res.WarnMsg = resFour10265.WarnMsg
  25627. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25628. res.Infcode = infocode
  25629. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25630. var pagesize int = 2
  25631. var start int = 1
  25632. var stop int
  25633. var pagecount int
  25634. var curpage int
  25635. var isSuccess bool = true
  25636. data["doctor_id"] = doctor_info.DoctorNumber
  25637. //总页数,向上取整,注意除之前要先转换类型为float64
  25638. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  25639. for curpage = 1; curpage <= pagecount; curpage++ {
  25640. if curpage == 1 {
  25641. start = 1
  25642. } else {
  25643. start = (curpage-1)*pagesize + 1
  25644. }
  25645. stop = curpage * pagesize
  25646. if stop > len(prescriptions) {
  25647. stop = len(prescriptions)
  25648. }
  25649. //var requestLog string
  25650. data["pre"] = prescriptions[start-1 : stop]
  25651. fmt.Println(data["pre"])
  25652. bytesData, _ := json.Marshal(data)
  25653. var req *http.Request
  25654. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  25655. resp, _ := client.Do(req)
  25656. defer resp.Body.Close()
  25657. body, ioErr := ioutil.ReadAll(resp.Body)
  25658. if ioErr != nil {
  25659. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25661. return
  25662. }
  25663. var respJSON map[string]interface{}
  25664. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25665. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25667. return
  25668. }
  25669. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25670. userJSONBytes, _ := json.Marshal(respJSON)
  25671. fmt.Println("log")
  25672. fmt.Println(string(userJSONBytes))
  25673. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25674. utils.ErrorLog("解析失败:%v", err)
  25675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25676. return
  25677. }
  25678. res.InfRefmsgid = resFour10265.InfRefmsgid
  25679. res.Output = resFour10265.Output
  25680. res.ErrMsg = resFour10265.ErrMsg
  25681. res.Cainfo = resFour10265.Cainfo
  25682. res.WarnMsg = resFour10265.WarnMsg
  25683. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25684. res.Infcode = infocode
  25685. if infocode == 0 {
  25686. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  25687. } else {
  25688. isSuccess = false
  25689. errlog := &models.HisOrderError{
  25690. UserOrgId: adminUser.CurrentOrgId,
  25691. Ctime: time.Now().Unix(),
  25692. Mtime: time.Now().Unix(),
  25693. Number: chrg_bchno,
  25694. ErrMsg: "",
  25695. Status: 1,
  25696. PatientId: id,
  25697. RecordTime: recordDateTime,
  25698. Stage: 4,
  25699. }
  25700. service.CreateErrMsgLog(errlog)
  25701. c.ServeSuccessJSON(map[string]interface{}{
  25702. "failed_code": -10,
  25703. "msg": res.ErrMsg,
  25704. })
  25705. return
  25706. }
  25707. }
  25708. if isSuccess {
  25709. res.Infcode = 0
  25710. }
  25711. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25712. 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)
  25713. var dat map[string]interface{}
  25714. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25715. fmt.Println(dat)
  25716. } else {
  25717. fmt.Println(err)
  25718. }
  25719. saveLog(result, request_log, "2204", "上传费用明细")
  25720. userJSONBytes, _ := json.Marshal(dat)
  25721. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25722. utils.ErrorLog("解析失败:%v", err)
  25723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25724. return
  25725. }
  25726. res.InfRefmsgid = resFour10265.InfRefmsgid
  25727. res.Output = resFour10265.Output
  25728. res.ErrMsg = resFour10265.ErrMsg
  25729. res.Cainfo = resFour10265.Cainfo
  25730. res.WarnMsg = resFour10265.WarnMsg
  25731. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25732. res.Infcode = infocode
  25733. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25734. bytesData, _ := json.Marshal(data)
  25735. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  25736. resp, _ := client.Do(req)
  25737. defer resp.Body.Close()
  25738. body, ioErr := ioutil.ReadAll(resp.Body)
  25739. if ioErr != nil {
  25740. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25742. return
  25743. }
  25744. var respJSON map[string]interface{}
  25745. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25746. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25748. return
  25749. }
  25750. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25751. userJSONBytes, _ := json.Marshal(respJSON)
  25752. fmt.Println("log")
  25753. fmt.Println(string(userJSONBytes))
  25754. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25755. utils.ErrorLog("解析失败:%v", err)
  25756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25757. return
  25758. }
  25759. } else {
  25760. if miConfig.Code == "H15049901371" {
  25761. 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)
  25762. var dat map[string]interface{}
  25763. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25764. fmt.Println(dat)
  25765. } else {
  25766. fmt.Println(err)
  25767. }
  25768. saveLog(result, request_log, "2204", "上传费用明细")
  25769. userJSONBytes, _ := json.Marshal(dat)
  25770. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  25771. utils.ErrorLog("解析失败:%v", err)
  25772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25773. return
  25774. }
  25775. res.InfRefmsgid = resFour10265.InfRefmsgid
  25776. res.Output = resFour10265.Output
  25777. res.ErrMsg = resFour10265.ErrMsg
  25778. res.Cainfo = resFour10265.Cainfo
  25779. res.WarnMsg = resFour10265.WarnMsg
  25780. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  25781. res.Infcode = infocode
  25782. } else {
  25783. 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)
  25784. var dat map[string]interface{}
  25785. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25786. fmt.Println(dat)
  25787. } else {
  25788. fmt.Println(err)
  25789. }
  25790. saveLog(result, request_log, "2204", "上传费用明细")
  25791. userJSONBytes, _ := json.Marshal(dat)
  25792. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25793. utils.ErrorLog("解析失败:%v", err)
  25794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25795. return
  25796. }
  25797. }
  25798. }
  25799. if res.Infcode == 0 {
  25800. order := &models.HisOrder{
  25801. UserOrgId: adminUser.CurrentOrgId,
  25802. HisPatientId: his.ID,
  25803. PatientId: his.PatientId,
  25804. SettleAccountsDate: recordDateTime,
  25805. MdtrtId: his.Number,
  25806. PsnNo: his.PsnNo,
  25807. MedType: strconv.FormatInt(reg_type, 10),
  25808. Ctime: time.Now().Unix(),
  25809. Mtime: time.Now().Unix(),
  25810. Status: 1,
  25811. Number: chrg_bchno,
  25812. Infcode: res.Infcode,
  25813. WarnMsg: res.WarnMsg,
  25814. Cainfo: res.Cainfo,
  25815. ErrMsg: res.ErrMsg,
  25816. RespondTime: res.RefmsgTime,
  25817. InfRefmsgid: res.InfRefmsgid,
  25818. OrderStatus: 1,
  25819. PayWay: pay_way,
  25820. PayWays: pay_ways,
  25821. OthDesc: oth_desc,
  25822. PayPrice: pay_price,
  25823. PayCardNo: pay_card_no,
  25824. DiscountPrice: discount_price,
  25825. PreferentialPrice: preferential_price,
  25826. RealityPrice: reality_price,
  25827. FoundPrice: found_price,
  25828. MedicalInsurancePrice: medical_insurance_price,
  25829. PrivatePrice: private_price,
  25830. IsMedicineInsurance: 1,
  25831. SettleType: settle_accounts_type,
  25832. SettleStartTime: start_time,
  25833. SettleEndTime: end_time,
  25834. Creator: roles.AdminUserId,
  25835. Modify: roles.AdminUserId,
  25836. FaPiaoNumber: fapiao_number,
  25837. FaPiaoCode: fapiao_code,
  25838. PType: 2,
  25839. Diagnosis: diagnosis_id,
  25840. CashPay: cash_pay,
  25841. WechatPay: wechat_pay,
  25842. AliPay: ali_pay,
  25843. JifenPay: jifen_pay,
  25844. BandCardPay: band_card_pay,
  25845. }
  25846. err = service.CreateOrder(order)
  25847. if err != nil {
  25848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  25849. return
  25850. }
  25851. for _, item := range res.Output.Result {
  25852. temp := strings.Split(item.FeedetlSn, "-")
  25853. var advice_id int64 = 0
  25854. var project_id int64 = 0
  25855. var types int64 = 0
  25856. id, _ := strconv.ParseInt(temp[2], 10, 64)
  25857. types, _ = strconv.ParseInt(temp[1], 10, 64)
  25858. if temp[1] == "1" {
  25859. advice_id = id
  25860. project_id = 0
  25861. } else if temp[1] == "2" {
  25862. advice_id = 0
  25863. project_id = id
  25864. }
  25865. if item.MedChrgitmType == "9" {
  25866. item.MedChrgitmType = "09"
  25867. }
  25868. info := &models.HisOrderInfo{
  25869. OrderNumber: order.Number,
  25870. FeedetlSn: item.FeedetlSn,
  25871. UploadDate: time.Now().Unix(),
  25872. AdviceId: advice_id,
  25873. DetItemFeeSumamt: item.DetItemFeeSumamt,
  25874. Cnt: item.Cnt,
  25875. Pric: float64(item.Pric),
  25876. PatientId: his.PatientId,
  25877. PricUplmtAmt: item.PricUplmtAmt,
  25878. SelfpayProp: item.SelfpayProp,
  25879. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  25880. OverlmtAmt: item.OverlmtAmt,
  25881. PreselfpayAmt: item.PreselfpayAmt,
  25882. BasMednFlag: item.BasMednFlag,
  25883. MedChrgitmType: item.MedChrgitmType,
  25884. HiNegoDrugFlag: item.HiNegoDrugFlag,
  25885. Status: 1,
  25886. Memo: item.Memo,
  25887. Mtime: time.Now().Unix(),
  25888. InscpScpAmt: item.InscpScpAmt,
  25889. DrtReimFlag: item.DrtReimFlag,
  25890. Ctime: time.Now().Unix(),
  25891. ListSpItemFlag: item.ListSpItemFlag,
  25892. ChldMedcFlag: item.ChldMedcFlag,
  25893. LmtUsedFlag: item.LmtUsedFlag,
  25894. ChrgitmLv: item.ChrgitmLv,
  25895. UserOrgId: adminUser.CurrentOrgId,
  25896. HisPatientId: his.ID,
  25897. OrderId: order.ID,
  25898. ProjectId: project_id,
  25899. Type: types,
  25900. }
  25901. service.CreateOrderInfo(info)
  25902. }
  25903. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  25904. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  25905. var total float64
  25906. for _, item := range prescriptions {
  25907. if item.Type == 1 { //药品
  25908. for _, subItem := range item.HisDoctorAdviceInfo {
  25909. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25910. total_one := price * subItem.PrescribingNumber
  25911. total = total + total_one
  25912. }
  25913. }
  25914. if item.Type == 2 { //项目
  25915. for _, subItem := range item.HisPrescriptionProject {
  25916. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  25917. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  25918. total_one := price * cnt
  25919. total = total + total_one
  25920. }
  25921. }
  25922. }
  25923. allTotal := fmt.Sprintf("%.2f", total)
  25924. //if adminUser.CurrentOrgId == 9919 {
  25925. //
  25926. // allTotal = fmt.Sprintf("%.2f", total)
  25927. //
  25928. //} else {
  25929. //
  25930. // allTotal = fmt.Sprintf("%.2f", total)
  25931. //
  25932. //}
  25933. if res.Infcode == 0 {
  25934. var rf []*ResultFive
  25935. json.Unmarshal([]byte(his.Iinfo), &rf)
  25936. chrg_bchno := chrg_bchno
  25937. cert_no := his.Certno
  25938. var insutypes []string
  25939. var insutype string
  25940. var is390 int = 0
  25941. var is310 int = 0
  25942. for _, item := range rf {
  25943. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25944. insutypes = append(insutypes, item.Insutype)
  25945. }
  25946. }
  25947. if len(insutypes) == 1 {
  25948. insutype = insutypes[0]
  25949. } else {
  25950. for _, i := range insutypes {
  25951. if i == "390" {
  25952. is390 = 1
  25953. }
  25954. if i == "310" {
  25955. is310 = 1
  25956. }
  25957. }
  25958. }
  25959. if is390 == 1 {
  25960. insutype = "390"
  25961. }
  25962. if is310 == 1 {
  25963. insutype = "310"
  25964. }
  25965. if len(insutypes) == 0 {
  25966. insutype = "310"
  25967. }
  25968. if len(insutypes) == 2 {
  25969. insutype = strconv.FormatInt(his.SocialType, 10)
  25970. }
  25971. insutype = strconv.FormatInt(his.SocialType, 10)
  25972. //insutype = "390"
  25973. if his.IdCardType == 1 {
  25974. // cert_no = his.MedicalInsuranceNumber
  25975. cert_no = his.Certno
  25976. } else {
  25977. cert_no = his.Certno
  25978. }
  25979. var res ResultSeven
  25980. var resSeven10265 ResultSeven10265
  25981. var gzresSeven10265Two GZResultSeven10265Two
  25982. var src_resquest string
  25983. var result2 string
  25984. if miConfig.MdtrtareaAdmvs == "421300" {
  25985. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25986. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25987. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25988. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25989. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25990. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25991. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25992. resp, requestErr := http.Get(api)
  25993. if requestErr != nil {
  25994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25995. return
  25996. }
  25997. body, ioErr := ioutil.ReadAll(resp.Body)
  25998. if ioErr != nil {
  25999. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26001. return
  26002. }
  26003. var respJSON map[string]interface{}
  26004. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26005. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26007. return
  26008. }
  26009. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26010. result, _ := json.Marshal(respJSON)
  26011. if miConfig.Code == "H15049901371" {
  26012. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26013. utils.ErrorLog("解析失败:%v", err)
  26014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26015. return
  26016. }
  26017. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26018. res.Output = resSeven10265.Output
  26019. res.ErrMsg = resSeven10265.ErrMsg
  26020. res.Cainfo = resSeven10265.Cainfo
  26021. res.WarnMsg = resSeven10265.WarnMsg
  26022. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26023. res.Infcode = infocode
  26024. } else {
  26025. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26026. utils.ErrorLog("解析失败:%v", err)
  26027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26028. return
  26029. }
  26030. }
  26031. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26032. if reg_type == 11 && his.Insutype == "390" {
  26033. reg_type = 110104
  26034. }
  26035. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26036. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26037. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26038. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26039. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26040. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26041. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26042. resp, requestErr := http.Get(api)
  26043. if requestErr != nil {
  26044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26045. return
  26046. }
  26047. body, ioErr := ioutil.ReadAll(resp.Body)
  26048. if ioErr != nil {
  26049. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26051. return
  26052. }
  26053. var respJSON map[string]interface{}
  26054. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26055. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26057. return
  26058. }
  26059. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26060. result, _ := json.Marshal(respJSON)
  26061. if miConfig.Code == "H15049901371" {
  26062. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26063. utils.ErrorLog("解析失败:%v", err)
  26064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26065. return
  26066. }
  26067. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26068. res.Output = resSeven10265.Output
  26069. res.ErrMsg = resSeven10265.ErrMsg
  26070. res.Cainfo = resSeven10265.Cainfo
  26071. res.WarnMsg = resSeven10265.WarnMsg
  26072. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26073. res.Infcode = infocode
  26074. } else {
  26075. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26076. utils.ErrorLog("解析失败:%v", err)
  26077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26078. return
  26079. }
  26080. }
  26081. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26082. if reg_type == 11 && his.Insutype == "390" {
  26083. reg_type = 110104
  26084. }
  26085. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26086. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26087. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26088. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26089. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26090. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26091. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26092. resp, requestErr := http.Get(api)
  26093. if requestErr != nil {
  26094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26095. return
  26096. }
  26097. body, ioErr := ioutil.ReadAll(resp.Body)
  26098. if ioErr != nil {
  26099. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26101. return
  26102. }
  26103. var respJSON map[string]interface{}
  26104. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26105. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26107. return
  26108. }
  26109. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26110. result, _ := json.Marshal(respJSON)
  26111. if miConfig.Code == "H15049901371" {
  26112. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26113. utils.ErrorLog("解析失败:%v", err)
  26114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26115. return
  26116. }
  26117. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26118. res.Output = resSeven10265.Output
  26119. res.ErrMsg = resSeven10265.ErrMsg
  26120. res.Cainfo = resSeven10265.Cainfo
  26121. res.WarnMsg = resSeven10265.WarnMsg
  26122. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26123. res.Infcode = infocode
  26124. } else {
  26125. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26126. utils.ErrorLog("解析失败:%v", err)
  26127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26128. return
  26129. }
  26130. }
  26131. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26132. if reg_type == 11 && his.Insutype == "390" {
  26133. reg_type = 110104
  26134. }
  26135. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26136. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26137. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26138. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26139. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26140. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26141. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26142. resp, requestErr := http.Get(api)
  26143. if requestErr != nil {
  26144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26145. return
  26146. }
  26147. body, ioErr := ioutil.ReadAll(resp.Body)
  26148. if ioErr != nil {
  26149. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26151. return
  26152. }
  26153. var respJSON map[string]interface{}
  26154. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26155. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26157. return
  26158. }
  26159. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26160. result, _ := json.Marshal(respJSON)
  26161. if miConfig.Code == "H15049901371" {
  26162. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26163. utils.ErrorLog("解析失败:%v", err)
  26164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26165. return
  26166. }
  26167. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26168. res.Output = resSeven10265.Output
  26169. res.ErrMsg = resSeven10265.ErrMsg
  26170. res.Cainfo = resSeven10265.Cainfo
  26171. res.WarnMsg = resSeven10265.WarnMsg
  26172. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26173. res.Infcode = infocode
  26174. } else {
  26175. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26176. utils.ErrorLog("解析失败:%v", err)
  26177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26178. return
  26179. }
  26180. }
  26181. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26182. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  26183. if result3101.Infcode == "0" {
  26184. if len(result3101.Output.Result) > 0 {
  26185. var errMsgs []string
  26186. for _, item := range result3101.Output.Result {
  26187. errMsgs = append(errMsgs, item.VolaCont)
  26188. }
  26189. c.ServeSuccessJSON(map[string]interface{}{
  26190. "failed_code": -10,
  26191. "msg": errMsgs,
  26192. })
  26193. return
  26194. } else {
  26195. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26196. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  26197. bas := strings.Split(psn_info.CardInfo, "|")
  26198. if his.IdCardType == 1 {
  26199. cert_no = bas[2]
  26200. } else if his.IdCardType == 3 {
  26201. cert_no = his.Certno
  26202. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  26203. } else if his.IdCardType == 4 {
  26204. cert_no = his.Certno
  26205. psn_info.VerifyNumber = psn_info.VerifyNumber
  26206. }
  26207. var api string
  26208. if miConfig.MdtrtareaAdmvs == "320921" {
  26209. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26210. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26211. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26212. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26213. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26214. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26215. "&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
  26216. } else {
  26217. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26218. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26219. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26220. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26221. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26222. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26223. "&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
  26224. }
  26225. resp, requestErr := http.Get(api)
  26226. if requestErr != nil {
  26227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26228. return
  26229. }
  26230. body, ioErr := ioutil.ReadAll(resp.Body)
  26231. if ioErr != nil {
  26232. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26234. return
  26235. }
  26236. var respJSON map[string]interface{}
  26237. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26238. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26240. return
  26241. }
  26242. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26243. result, _ := json.Marshal(respJSON)
  26244. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26245. utils.ErrorLog("解析失败:%v", err)
  26246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26247. return
  26248. }
  26249. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26250. res.Output = resSeven10265.Output
  26251. res.ErrMsg = resSeven10265.ErrMsg
  26252. res.Cainfo = resSeven10265.Cainfo
  26253. res.WarnMsg = resSeven10265.WarnMsg
  26254. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26255. res.Infcode = infocode
  26256. }
  26257. }
  26258. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26259. psn_info, _ := service.GetPsnByPatientId(id)
  26260. var verify_number string
  26261. if psn_info.IdCardType == 4 {
  26262. verify_number = psn_info.VerifyNumber
  26263. } else if psn_info.IdCardType == 1 {
  26264. bas := strings.Split(psn_info.CardInfo, "|")
  26265. cardNumber := bas[2]
  26266. verify_number = cardNumber
  26267. } else {
  26268. psn_info.IdCardType = 2
  26269. verify_number = psn_info.Certno
  26270. }
  26271. var api string
  26272. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26273. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26274. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26275. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26276. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26277. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26278. "&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
  26279. resp, requestErr := http.Get(api)
  26280. if requestErr != nil {
  26281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26282. return
  26283. }
  26284. body, ioErr := ioutil.ReadAll(resp.Body)
  26285. if ioErr != nil {
  26286. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26288. return
  26289. }
  26290. var respJSON map[string]interface{}
  26291. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26292. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26294. return
  26295. }
  26296. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26297. result, _ := json.Marshal(respJSON)
  26298. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  26299. utils.ErrorLog("解析失败:%v", err)
  26300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26301. return
  26302. }
  26303. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26304. res.Output = resSeven10265.Output
  26305. res.ErrMsg = resSeven10265.ErrMsg
  26306. res.Cainfo = resSeven10265.Cainfo
  26307. res.WarnMsg = resSeven10265.WarnMsg
  26308. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26309. res.Infcode = infocode
  26310. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26311. var cert_no string
  26312. if his.IdCardType == 4 {
  26313. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26314. cert_no = psn_info.VerifyNumber
  26315. 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)
  26316. } else if his.IdCardType == 1 {
  26317. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26318. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  26319. 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)
  26320. }
  26321. //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)
  26322. var dat map[string]interface{}
  26323. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26324. fmt.Println(dat)
  26325. } else {
  26326. fmt.Println(err)
  26327. }
  26328. saveLog(result2, src_resquest, "2207", "结算")
  26329. userJSONBytes, _ := json.Marshal(dat)
  26330. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26331. utils.ErrorLog("解析失败:%v", err)
  26332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26333. return
  26334. }
  26335. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26336. res.Output = resSeven10265.Output
  26337. res.ErrMsg = resSeven10265.ErrMsg
  26338. res.Cainfo = resSeven10265.Cainfo
  26339. res.WarnMsg = resSeven10265.WarnMsg
  26340. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26341. res.Infcode = infocode
  26342. } else if miConfig.MdtrtareaAdmvs == "450721" {
  26343. res2 := c.GetoleInfo()
  26344. if res2.Infcode == 0 {
  26345. var result string
  26346. var request_log string
  26347. var result_log string
  26348. if res2.Output.MdtrtCertType == "02" {
  26349. 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)
  26350. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26351. } else if res2.Output.MdtrtCertType == "01" {
  26352. 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)
  26353. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26354. } else {
  26355. 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)
  26356. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26357. }
  26358. var dat map[string]interface{}
  26359. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26360. fmt.Println(dat)
  26361. } else {
  26362. fmt.Println(err)
  26363. }
  26364. userJSONBytes, _ := json.Marshal(dat)
  26365. var res5 ResultTwo
  26366. //var resTwo10265 ResultTwo10265
  26367. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26368. utils.ErrorLog("解析失败:%v", err)
  26369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26370. return
  26371. }
  26372. if res5.Infcode == -1 {
  26373. c.ServeSuccessJSON(map[string]interface{}{
  26374. "failed_code": -10,
  26375. "msg": res5.ErrMsg,
  26376. })
  26377. return
  26378. }
  26379. var insutypes []string
  26380. var insutype string
  26381. var is390 int = 0
  26382. var is310 int = 0
  26383. for _, item := range res5.Output.Iinfo {
  26384. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26385. insutypes = append(insutypes, item.Insutype)
  26386. }
  26387. }
  26388. if len(insutypes) == 1 {
  26389. insutype = insutypes[0]
  26390. } else {
  26391. for _, i := range insutypes {
  26392. if i == "390" {
  26393. is390 = 1
  26394. }
  26395. if i == "310" {
  26396. is310 = 1
  26397. }
  26398. }
  26399. }
  26400. if is390 == 1 {
  26401. insutype = "390"
  26402. }
  26403. if is310 == 1 {
  26404. insutype = "310"
  26405. }
  26406. if len(insutypes) == 0 {
  26407. insutype = "310"
  26408. }
  26409. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26410. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26411. infoStr := string(Iinfos)
  26412. idetinfoStr := string(Idetinfos)
  26413. psn := &models.HisPsn{
  26414. PsnNo: res5.Output.Baseinfo.PsnNo,
  26415. PatientId: id,
  26416. Certno: res5.Output.Baseinfo.Certno,
  26417. Gend: res5.Output.Baseinfo.Gend,
  26418. Naty: res5.Output.Baseinfo.Naty,
  26419. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26420. PsnName: res5.Output.Baseinfo.PsnName,
  26421. Idetinfo: idetinfoStr,
  26422. Insuinfo: infoStr,
  26423. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26424. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26425. VerifyNumber: res2.Output.EcToken,
  26426. }
  26427. if res2.Output.MdtrtCertType == "01" {
  26428. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26429. psn.VerifyNumber = res2.Output.EcToken
  26430. } else if res2.Output.MdtrtCertType == "02" {
  26431. psn.VerifyNumber = res2.Output.CardNo
  26432. } else {
  26433. psn.VerifyNumber = res2.Output.MdtrtCertNo
  26434. }
  26435. service.CreateHisPsn(psn)
  26436. if res2.Output.MdtrtCertType == "01" {
  26437. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26438. token := res2.Output.EcToken
  26439. 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)
  26440. } else if res2.Output.MdtrtCertType == "02" {
  26441. 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)
  26442. } else {
  26443. 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)
  26444. }
  26445. var dat2 map[string]interface{}
  26446. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26447. fmt.Println(dat2)
  26448. } else {
  26449. fmt.Println(err)
  26450. }
  26451. userJSONBytes3, _ := json.Marshal(dat2)
  26452. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26453. utils.ErrorLog("解析失败:%v", err)
  26454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26455. return
  26456. }
  26457. saveLog(result2, src_resquest, "2207", "结算")
  26458. } else {
  26459. c.ServeSuccessJSON(map[string]interface{}{
  26460. "failed_code": -10,
  26461. "msg": res2.ErrMsg,
  26462. })
  26463. return
  26464. }
  26465. } else {
  26466. if miConfig.Code == "H15049901371" {
  26467. //赤峰地区国家医保医疗类别
  26468. //职工透析:医疗类别选特殊情况门诊990502
  26469. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26470. var med_type string
  26471. if his.Insutype == "390" {
  26472. if reg_type == 14 {
  26473. med_type = "9933"
  26474. } else if reg_type == 11 {
  26475. med_type = "11"
  26476. }
  26477. } else if his.Insutype == "310" {
  26478. if reg_type == 14 {
  26479. med_type = "990502"
  26480. } else if reg_type == 11 {
  26481. med_type = "11"
  26482. }
  26483. }
  26484. 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)
  26485. } else {
  26486. if his.IdCardType == 4 {
  26487. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26488. var token string
  26489. token = psn_info.VerifyNumber
  26490. 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)
  26491. } else {
  26492. if his.IdCardType == 1 {
  26493. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26494. bas := strings.Split(psn_info.CardInfo, "|")
  26495. basNumber := bas[2]
  26496. cert_no = basNumber
  26497. }
  26498. 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)
  26499. }
  26500. }
  26501. //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)
  26502. var dat map[string]interface{}
  26503. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26504. fmt.Println(dat)
  26505. } else {
  26506. fmt.Println(err)
  26507. }
  26508. saveLog(result2, src_resquest, "2207", "结算")
  26509. userJSONBytes, _ := json.Marshal(dat)
  26510. if miConfig.Code == "H15049901371" {
  26511. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  26512. utils.ErrorLog("解析失败:%v", err)
  26513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26514. return
  26515. }
  26516. res.InfRefmsgid = resSeven10265.InfRefmsgid
  26517. res.Output = resSeven10265.Output
  26518. res.ErrMsg = resSeven10265.ErrMsg
  26519. res.Cainfo = resSeven10265.Cainfo
  26520. res.WarnMsg = resSeven10265.WarnMsg
  26521. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  26522. res.Infcode = infocode
  26523. } else {
  26524. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26525. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  26526. utils.ErrorLog("解析失败:%v", err)
  26527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26528. return
  26529. }
  26530. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  26531. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  26532. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  26533. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26534. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  26535. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  26536. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  26537. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26538. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  26539. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26540. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26541. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26542. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26543. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  26544. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  26545. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  26546. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  26547. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  26548. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  26549. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  26550. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26551. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  26552. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  26553. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  26554. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  26555. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  26556. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  26557. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  26558. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  26559. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  26560. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  26561. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  26562. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  26563. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  26564. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  26565. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  26566. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  26567. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  26568. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  26569. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  26570. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  26571. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  26572. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  26573. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  26574. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  26575. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  26576. res.ErrMsg = gzresSeven10265Two.ErrMsg
  26577. res.Cainfo = gzresSeven10265Two.Cainfo
  26578. res.WarnMsg = gzresSeven10265Two.WarnMsg
  26579. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  26580. //res.Infcode = infocode
  26581. } else {
  26582. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26583. utils.ErrorLog("解析失败:%v", err)
  26584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26585. return
  26586. }
  26587. }
  26588. }
  26589. }
  26590. if res.Infcode == -1 {
  26591. errlog := &models.HisOrderError{
  26592. UserOrgId: adminUser.CurrentOrgId,
  26593. Ctime: time.Now().Unix(),
  26594. Mtime: time.Now().Unix(),
  26595. Number: chrg_bchno,
  26596. ErrMsg: res.ErrMsg,
  26597. Status: 1,
  26598. PatientId: id,
  26599. RecordTime: recordDateTime,
  26600. Stage: 6,
  26601. }
  26602. service.CreateErrMsgLog(errlog)
  26603. c.ServeSuccessJSON(map[string]interface{}{
  26604. "failed_code": -10,
  26605. "msg": res.ErrMsg,
  26606. })
  26607. return
  26608. } else {
  26609. sickConfig, _ := service.FindSickById(his.SickType)
  26610. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  26611. order.OrderStatus = 2
  26612. order.Status = 1
  26613. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  26614. order.SetlId = res.Output.Setlinfo.SetlID
  26615. order.PsnNo = res.Output.Setlinfo.PsnNo
  26616. order.PsnName = res.Output.Setlinfo.PsnName
  26617. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  26618. order.Certno = res.Output.Setlinfo.Certno
  26619. order.Gend = res.Output.Setlinfo.Gend
  26620. order.Naty = res.Output.Setlinfo.Naty
  26621. order.Age = res.Output.Setlinfo.Age
  26622. order.Insutype = res.Output.Setlinfo.Insutype
  26623. order.PsnType = res.Output.Setlinfo.PsnType
  26624. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  26625. order.SetlTime = res.Output.Setlinfo.SetlTime
  26626. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  26627. if res.Output.Setlinfo.MedType == "140101" {
  26628. order.MedType = "14"
  26629. } else {
  26630. if res.Output.Setlinfo.MedType == "110104" {
  26631. order.MedType = "11"
  26632. } else {
  26633. order.MedType = res.Output.Setlinfo.MedType
  26634. }
  26635. }
  26636. if reg_type == 1112 {
  26637. order.MedType = "1112"
  26638. }
  26639. if reg_type == 1111 {
  26640. order.MedType = "1111"
  26641. }
  26642. order.ClrType = res.Output.Setlinfo.ClrType
  26643. if adminUser.CurrentOrgId == 10480 {
  26644. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  26645. order.ClrType = "11"
  26646. } else {
  26647. order.ClrType = "9903"
  26648. }
  26649. }
  26650. if adminUser.CurrentOrgId == 10721 {
  26651. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  26652. order.ClrType = "11"
  26653. } else {
  26654. order.ClrType = "9903"
  26655. }
  26656. }
  26657. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  26658. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  26659. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  26660. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  26661. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  26662. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  26663. order.HifpPay = res.Output.Setlinfo.HifpPay
  26664. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  26665. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  26666. order.HifesPay = res.Output.Setlinfo.HifesPay
  26667. order.HifobPay = res.Output.Setlinfo.HifobPay
  26668. order.MafPay = res.Output.Setlinfo.MafPay
  26669. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  26670. order.OthPay = res.Output.Setlinfo.OthPay
  26671. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  26672. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  26673. order.AcctPay = res.Output.Setlinfo.AcctPay
  26674. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  26675. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  26676. order.Balc = res.Output.Setlinfo.Balc
  26677. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  26678. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  26679. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  26680. //order.ClrType = res.Output.Setlinfo.ClrType
  26681. order.ClrWay = res.Output.Setlinfo.ClrWay
  26682. order.Creator = order.Creator
  26683. order.Modify = roles.AdminUserId
  26684. order.RequestLog = src_resquest
  26685. order.FaPiaoNumber = fapiao_number
  26686. order.FaPiaoCode = fapiao_code
  26687. order.SickName = sickConfig.ClassName
  26688. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  26689. //detailStr := string(setlDetail)
  26690. //order.SetlDetail = detailStr
  26691. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  26692. err = service.UpDateOrder(order)
  26693. if err == nil {
  26694. //判断是否使用了押金
  26695. if dec_way == "true" {
  26696. tmpstring := strconv.FormatInt(order.ID, 10)
  26697. order.Decimal = decimal
  26698. service.UpDateOrder(order)
  26699. //扣押金
  26700. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  26701. if errmsg != nil {
  26702. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  26703. return
  26704. }
  26705. }
  26706. c.ServeSuccessJSON(map[string]interface{}{
  26707. "msg": "结算成功",
  26708. })
  26709. } else {
  26710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  26711. return
  26712. }
  26713. }
  26714. } else {
  26715. adminUser := c.GetAdminUserInfo()
  26716. errlog := &models.HisOrderError{
  26717. UserOrgId: adminUser.CurrentOrgId,
  26718. Ctime: time.Now().Unix(),
  26719. Mtime: time.Now().Unix(),
  26720. ErrMsg: res.ErrMsg,
  26721. Status: 1,
  26722. PatientId: id,
  26723. RecordTime: recordDateTime,
  26724. Stage: 4,
  26725. }
  26726. service.CreateErrMsgLog(errlog)
  26727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  26728. return
  26729. }
  26730. } else {
  26731. adminUser := c.GetAdminUserInfo()
  26732. errlog := &models.HisOrderError{
  26733. UserOrgId: adminUser.CurrentOrgId,
  26734. Ctime: time.Now().Unix(),
  26735. Mtime: time.Now().Unix(),
  26736. ErrMsg: res.ErrMsg,
  26737. Status: 1,
  26738. PatientId: id,
  26739. RecordTime: recordDateTime,
  26740. Stage: 4,
  26741. }
  26742. service.CreateErrMsgLog(errlog)
  26743. c.ServeSuccessJSON(map[string]interface{}{
  26744. "failed_code": -10,
  26745. "msg": res.ErrMsg,
  26746. })
  26747. return
  26748. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  26749. //return
  26750. }
  26751. }
  26752. }
  26753. } else if tempOrder.ID > 0 {
  26754. if tempOrder.IsPre == 1 {
  26755. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  26756. var rf []*ResultFive
  26757. json.Unmarshal([]byte(his.Iinfo), &rf)
  26758. chrg_bchno := tempOrder.Number
  26759. cert_no := his.Certno
  26760. var insutypes []string
  26761. var insutype string
  26762. var is390 int = 0
  26763. var is310 int = 0
  26764. for _, item := range rf {
  26765. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26766. insutypes = append(insutypes, item.Insutype)
  26767. }
  26768. }
  26769. if len(insutypes) == 1 {
  26770. insutype = insutypes[0]
  26771. } else {
  26772. for _, i := range insutypes {
  26773. if i == "390" {
  26774. is390 = 1
  26775. }
  26776. if i == "310" {
  26777. is310 = 1
  26778. }
  26779. }
  26780. }
  26781. if is390 == 1 {
  26782. insutype = "390"
  26783. }
  26784. if is310 == 1 {
  26785. insutype = "310"
  26786. }
  26787. if len(insutypes) == 0 {
  26788. insutype = "310"
  26789. }
  26790. if len(insutypes) == 2 {
  26791. insutype = strconv.FormatInt(his.SocialType, 10)
  26792. }
  26793. //insutype = "390"
  26794. if his.IdCardType == 1 {
  26795. // cert_no = his.MedicalInsuranceNumber
  26796. cert_no = his.Certno
  26797. } else {
  26798. cert_no = his.Certno
  26799. }
  26800. var res ResultSeven
  26801. var ahres ResultSevenAH
  26802. var resSeven10265 ResultSeven10265
  26803. var gzresSeven10265Two GZResultSeven10265Two
  26804. var src_resquest string
  26805. var result2 string
  26806. if miConfig.MdtrtareaAdmvs == "450721" {
  26807. res2 := c.GetoleInfo()
  26808. if res2.Infcode == 0 {
  26809. var result string
  26810. var request_log string
  26811. var result_log string
  26812. if res2.Output.MdtrtCertType == "02" {
  26813. 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)
  26814. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26815. } else if res2.Output.MdtrtCertType == "01" {
  26816. 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)
  26817. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26818. } else {
  26819. 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)
  26820. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  26821. }
  26822. var dat map[string]interface{}
  26823. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26824. fmt.Println(dat)
  26825. } else {
  26826. fmt.Println(err)
  26827. }
  26828. userJSONBytes, _ := json.Marshal(dat)
  26829. var res5 ResultTwo
  26830. //var resTwo10265 ResultTwo10265
  26831. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  26832. utils.ErrorLog("解析失败:%v", err)
  26833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26834. return
  26835. }
  26836. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  26837. if res5.Infcode == -1 {
  26838. c.ServeSuccessJSON(map[string]interface{}{
  26839. "failed_code": -10,
  26840. "msg": res5.ErrMsg,
  26841. })
  26842. return
  26843. }
  26844. var insutypes []string
  26845. var insutype string
  26846. var is390 int = 0
  26847. var is310 int = 0
  26848. for _, item := range res5.Output.Iinfo {
  26849. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26850. insutypes = append(insutypes, item.Insutype)
  26851. }
  26852. }
  26853. if len(insutypes) == 1 {
  26854. insutype = insutypes[0]
  26855. } else {
  26856. for _, i := range insutypes {
  26857. if i == "390" {
  26858. is390 = 1
  26859. }
  26860. if i == "310" {
  26861. is310 = 1
  26862. }
  26863. }
  26864. }
  26865. if is390 == 1 {
  26866. insutype = "390"
  26867. }
  26868. if is310 == 1 {
  26869. insutype = "310"
  26870. }
  26871. if len(insutypes) == 0 {
  26872. insutype = "310"
  26873. }
  26874. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  26875. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  26876. infoStr := string(Iinfos)
  26877. idetinfoStr := string(Idetinfos)
  26878. psn := &models.HisPsn{
  26879. PsnNo: res5.Output.Baseinfo.PsnNo,
  26880. PatientId: id,
  26881. Certno: res5.Output.Baseinfo.Certno,
  26882. Gend: res5.Output.Baseinfo.Gend,
  26883. Naty: res5.Output.Baseinfo.Naty,
  26884. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  26885. PsnName: res5.Output.Baseinfo.PsnName,
  26886. Idetinfo: idetinfoStr,
  26887. Insuinfo: infoStr,
  26888. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  26889. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  26890. VerifyNumber: res2.Output.EcToken,
  26891. }
  26892. service.CreateHisPsn(psn)
  26893. if res2.Output.MdtrtCertType == "01" {
  26894. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  26895. token := res2.Output.EcToken
  26896. 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)
  26897. } else if res2.Output.MdtrtCertType == "02" {
  26898. 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)
  26899. } else {
  26900. 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)
  26901. }
  26902. var dat2 map[string]interface{}
  26903. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26904. fmt.Println(dat2)
  26905. } else {
  26906. fmt.Println(err)
  26907. }
  26908. userJSONBytes3, _ := json.Marshal(dat2)
  26909. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  26910. utils.ErrorLog("解析失败:%v", err)
  26911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26912. return
  26913. }
  26914. saveLog(result2, src_resquest, "2207", "结算")
  26915. } else {
  26916. c.ServeSuccessJSON(map[string]interface{}{
  26917. "failed_code": -10,
  26918. "msg": res2.ErrMsg,
  26919. })
  26920. return
  26921. }
  26922. } else if miConfig.MdtrtareaAdmvs == "421300" {
  26923. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  26924. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  26925. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26926. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26927. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  26928. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  26929. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  26930. resp, requestErr := http.Get(api)
  26931. if requestErr != nil {
  26932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26933. return
  26934. }
  26935. body, ioErr := ioutil.ReadAll(resp.Body)
  26936. if ioErr != nil {
  26937. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26939. return
  26940. }
  26941. var respJSON map[string]interface{}
  26942. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26943. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26945. return
  26946. }
  26947. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26948. result, _ := json.Marshal(respJSON)
  26949. fmt.Println("log")
  26950. fmt.Println(string(result))
  26951. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26952. utils.ErrorLog("解析失败:%v", err)
  26953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26954. return
  26955. }
  26956. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26957. if reg_type == 11 && his.Insutype == "390" {
  26958. reg_type = 110104
  26959. }
  26960. api := "http://192.168.0.197: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 == "420902" {
  26994. if reg_type == 11 && his.Insutype == "390" {
  26995. reg_type = 110104
  26996. }
  26997. api := miConfig.Url + "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 == "421182" {
  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 == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27068. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  27069. if result3101.Infcode == "0" {
  27070. if len(result3101.Output.Result) > 0 {
  27071. var errMsgs []string
  27072. for _, item := range result3101.Output.Result {
  27073. errMsgs = append(errMsgs, item.VolaCont)
  27074. }
  27075. c.ServeSuccessJSON(map[string]interface{}{
  27076. "failed_code": -10,
  27077. "msg": errMsgs,
  27078. })
  27079. return
  27080. } else {
  27081. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27082. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27083. bas := strings.Split(psn_info.CardInfo, "|")
  27084. if his.IdCardType == 1 {
  27085. cert_no = bas[2]
  27086. } else if his.IdCardType == 3 {
  27087. cert_no = his.Certno
  27088. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27089. } else if his.IdCardType == 4 {
  27090. cert_no = his.Certno
  27091. psn_info.VerifyNumber = psn_info.VerifyNumber
  27092. }
  27093. //江苏地区国家医保医疗类别
  27094. //职工透析:医疗类别选特殊情况门诊9933
  27095. //居民血透门慢: 医疗类别选门诊慢病1402
  27096. //var med_type string
  27097. //if his.Insutype == "310" {
  27098. // if reg_type == 14 {
  27099. // med_type = "9933"
  27100. // } else if reg_type == 11 {
  27101. // med_type = "11"
  27102. //
  27103. // }
  27104. //} else if his.Insutype == "390" {
  27105. // if reg_type == 14 {
  27106. // med_type = "1402"
  27107. // } else if reg_type == 11 {
  27108. // med_type = "11"
  27109. // }
  27110. //}
  27111. var api string
  27112. if miConfig.MdtrtareaAdmvs == "320921" {
  27113. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27114. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27115. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27116. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27117. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27118. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27119. "&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
  27120. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27121. } else {
  27122. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27123. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27124. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27125. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27126. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27127. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27128. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27129. "&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
  27130. }
  27131. resp, requestErr := http.Get(api)
  27132. if requestErr != nil {
  27133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27134. return
  27135. }
  27136. body, ioErr := ioutil.ReadAll(resp.Body)
  27137. if ioErr != nil {
  27138. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27140. return
  27141. }
  27142. var respJSON map[string]interface{}
  27143. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27146. return
  27147. }
  27148. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27149. result, _ := json.Marshal(respJSON)
  27150. fmt.Println("log")
  27151. fmt.Println(string(result))
  27152. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27153. utils.ErrorLog("解析失败:%v", err)
  27154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27155. return
  27156. }
  27157. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27158. res.Output = resSeven10265.Output
  27159. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27160. res.ErrMsg = resSeven10265.ErrMsg
  27161. res.Cainfo = resSeven10265.Cainfo
  27162. res.WarnMsg = resSeven10265.WarnMsg
  27163. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27164. res.Infcode = infocode
  27165. }
  27166. }
  27167. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27168. psn_info, _ := service.GetPsnByPatientId(id)
  27169. var verify_number string
  27170. if psn_info.IdCardType == 4 {
  27171. verify_number = psn_info.VerifyNumber
  27172. } else if psn_info.IdCardType == 1 {
  27173. bas := strings.Split(psn_info.CardInfo, "|")
  27174. cardNumber := bas[2]
  27175. verify_number = cardNumber
  27176. } else {
  27177. verify_number = psn_info.Certno
  27178. psn_info.IdCardType = 2
  27179. }
  27180. var api string
  27181. new_chrg_bchno := chrg_bchno
  27182. if adminUser.CurrentOrgId == 10265 {
  27183. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27184. new_chrg_bchno = "0000"
  27185. }
  27186. }
  27187. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27188. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  27189. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27190. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27191. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27192. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27193. "&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
  27194. resp, requestErr := http.Get(api)
  27195. if requestErr != nil {
  27196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27197. return
  27198. }
  27199. body, ioErr := ioutil.ReadAll(resp.Body)
  27200. if ioErr != nil {
  27201. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27203. return
  27204. }
  27205. var respJSON map[string]interface{}
  27206. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27207. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27209. return
  27210. }
  27211. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27212. result, _ := json.Marshal(respJSON)
  27213. fmt.Println("log")
  27214. fmt.Println(string(result))
  27215. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27216. utils.ErrorLog("解析失败:%v", err)
  27217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27218. return
  27219. }
  27220. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27221. res.Output = resSeven10265.Output
  27222. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27223. res.ErrMsg = resSeven10265.ErrMsg
  27224. res.Cainfo = resSeven10265.Cainfo
  27225. res.WarnMsg = resSeven10265.WarnMsg
  27226. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27227. res.Infcode = infocode
  27228. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27229. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27230. var cert_no string
  27231. if his.IdCardType == 1 {
  27232. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27233. } else {
  27234. cert_no = psn_info.VerifyNumber
  27235. }
  27236. 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)
  27237. var dat map[string]interface{}
  27238. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27239. fmt.Println(dat)
  27240. } else {
  27241. fmt.Println(err)
  27242. }
  27243. saveLog(result2, src_resquest, "2207", "结算")
  27244. userJSONBytes, _ := json.Marshal(dat)
  27245. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27246. utils.ErrorLog("解析失败:%v", err)
  27247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27248. return
  27249. }
  27250. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27251. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27252. var cert_no string
  27253. var card_sn string
  27254. if his.IdCardType == 1 {
  27255. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27256. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27257. bas := strings.Split(psn_info.CardInfo, "|")
  27258. card_sn = bas[3]
  27259. } else if his.IdCardType == 2 {
  27260. cert_no = his.IdCardNo
  27261. } else {
  27262. cert_no = psn_info.VerifyNumber
  27263. }
  27264. var rf []*ResultFive
  27265. json.Unmarshal([]byte(his.Iinfo), &rf)
  27266. var psn_type string
  27267. for _, item := range rf {
  27268. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27269. psn_type = item.PsnType
  27270. }
  27271. }
  27272. 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)
  27273. var dat map[string]interface{}
  27274. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27275. fmt.Println(dat)
  27276. } else {
  27277. fmt.Println(err)
  27278. }
  27279. saveLog(result2, src_resquest, "2207", "结算")
  27280. userJSONBytes, _ := json.Marshal(dat)
  27281. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27282. utils.ErrorLog("解析失败:%v", err)
  27283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27284. return
  27285. }
  27286. } else if miConfig.MdtrtareaAdmvs == "361025" {
  27287. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27288. var cert_no string
  27289. var card_sn string
  27290. if his.IdCardType == 1 {
  27291. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27292. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27293. //bas := strings.Split(psn_info.CardInfo, "|")
  27294. card_sn = ""
  27295. } else if his.IdCardType == 2 {
  27296. cert_no = his.IdCardNo
  27297. } else {
  27298. cert_no = psn_info.VerifyNumber
  27299. }
  27300. var rf []*ResultFive
  27301. json.Unmarshal([]byte(his.Iinfo), &rf)
  27302. var psn_type string
  27303. for _, item := range rf {
  27304. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27305. psn_type = item.PsnType
  27306. }
  27307. }
  27308. 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)
  27309. var dat map[string]interface{}
  27310. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27311. fmt.Println(dat)
  27312. } else {
  27313. fmt.Println(err)
  27314. }
  27315. saveLog(result2, src_resquest, "2207", "结算")
  27316. userJSONBytes, _ := json.Marshal(dat)
  27317. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27318. utils.ErrorLog("解析失败:%v", err)
  27319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27320. return
  27321. }
  27322. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27323. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27324. if his.IdCardType == 1 {
  27325. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27326. bas := strings.Split(psn_info.CardInfo, "|")
  27327. cert_no = bas[2]
  27328. } else if his.IdCardType == 3 {
  27329. cert_no = his.Certno
  27330. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27331. } else if his.IdCardType == 4 {
  27332. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27333. cert_no = psn_info.VerifyNumber
  27334. psn_info.VerifyNumber = psn_info.VerifyNumber
  27335. } else {
  27336. cert_no = his.Certno
  27337. psn_info.VerifyNumber = his.Certno
  27338. }
  27339. var api string
  27340. var med_type string
  27341. if his.Insutype == "390" {
  27342. if reg_type == 992102 {
  27343. med_type = "992102"
  27344. }
  27345. if reg_type == 140104 {
  27346. med_type = "140104"
  27347. }
  27348. if reg_type == 140201 {
  27349. med_type = "140201"
  27350. }
  27351. if reg_type == 14 {
  27352. med_type = "14"
  27353. }
  27354. } else if his.Insutype == "310" {
  27355. if reg_type == 992102 {
  27356. med_type = "992102"
  27357. }
  27358. if reg_type == 140104 {
  27359. med_type = "140104"
  27360. }
  27361. if reg_type == 140201 {
  27362. med_type = "140201"
  27363. }
  27364. if reg_type == 14 {
  27365. med_type = "14"
  27366. }
  27367. }
  27368. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27369. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27370. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27371. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27372. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27373. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27374. "&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
  27375. resp, requestErr := http.Get(api)
  27376. if requestErr != nil {
  27377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27378. return
  27379. }
  27380. body, ioErr := ioutil.ReadAll(resp.Body)
  27381. if ioErr != nil {
  27382. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27384. return
  27385. }
  27386. var respJSON map[string]interface{}
  27387. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27388. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27390. return
  27391. }
  27392. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27393. if status == "0" {
  27394. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27395. c.ServeSuccessJSON(map[string]interface{}{
  27396. "failed_code": -10,
  27397. "msg": err_msg,
  27398. })
  27399. return
  27400. }
  27401. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27402. result, _ := json.Marshal(respJSON)
  27403. fmt.Println("log")
  27404. fmt.Println(string(result))
  27405. if err := json.Unmarshal(result, &ahres); err != nil {
  27406. utils.ErrorLog("解析失败:%v", err)
  27407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27408. return
  27409. }
  27410. res.InfRefmsgid = ahres.InfRefmsgid
  27411. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27412. // 创建对应的Time类型
  27413. t := time.UnixMilli(timestamp)
  27414. // 格式化成指定的日期字符串
  27415. str := t.Format("2006-01-02 15:04:05")
  27416. res.Output.Setlinfo.SetlTime = str
  27417. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27418. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27419. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27420. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27421. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27422. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27423. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27424. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27425. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27426. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27427. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27428. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27429. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27430. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27431. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27432. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27433. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27434. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27435. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27436. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27437. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27438. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27439. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27440. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27441. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27442. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27443. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27444. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27445. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27446. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27447. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27448. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27449. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27450. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27451. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27452. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27453. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27454. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27455. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27456. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27457. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27458. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27459. res.Output.Setldetail = ahres.Output.Setldetail
  27460. res.ErrMsg = ahres.ErrMsg
  27461. res.Cainfo = ahres.Cainfo
  27462. res.WarnMsg = ahres.WarnMsg
  27463. res.Infcode = ahres.Infcode
  27464. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27465. res.Output.Setlinfo.ClrType = "11"
  27466. } else {
  27467. res.Output.Setlinfo.ClrType = "9903"
  27468. }
  27469. } else if miConfig.MdtrtareaAdmvs == "340699" {
  27470. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27471. if his.IdCardType == 1 {
  27472. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27473. bas := strings.Split(psn_info.CardInfo, "|")
  27474. cert_no = bas[2]
  27475. } else if his.IdCardType == 3 {
  27476. cert_no = his.Certno
  27477. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27478. } else if his.IdCardType == 4 {
  27479. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27480. cert_no = his.Certno
  27481. psn_info.VerifyNumber = psn_info.VerifyNumber
  27482. } else {
  27483. cert_no = his.Certno
  27484. psn_info.VerifyNumber = his.Certno
  27485. }
  27486. var api string
  27487. var med_type string
  27488. if his.Insutype == "390" {
  27489. if reg_type == 992102 {
  27490. med_type = "992102"
  27491. }
  27492. if reg_type == 140104 {
  27493. med_type = "140104"
  27494. }
  27495. if reg_type == 14 {
  27496. med_type = "14"
  27497. }
  27498. if reg_type == 140201 {
  27499. med_type = "140201"
  27500. }
  27501. } else if his.Insutype == "310" {
  27502. if reg_type == 992102 {
  27503. med_type = "992102"
  27504. }
  27505. if reg_type == 14 {
  27506. med_type = "14"
  27507. }
  27508. if reg_type == 140104 {
  27509. med_type = "140104"
  27510. }
  27511. if reg_type == 140201 {
  27512. med_type = "140201"
  27513. }
  27514. }
  27515. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27516. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27517. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27518. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27519. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27520. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27521. "&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
  27522. resp, requestErr := http.Get(api)
  27523. if requestErr != nil {
  27524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27525. return
  27526. }
  27527. body, ioErr := ioutil.ReadAll(resp.Body)
  27528. if ioErr != nil {
  27529. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27531. return
  27532. }
  27533. var respJSON map[string]interface{}
  27534. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27535. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27537. return
  27538. }
  27539. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27540. if status == "0" {
  27541. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27542. c.ServeSuccessJSON(map[string]interface{}{
  27543. "failed_code": -10,
  27544. "msg": err_msg,
  27545. })
  27546. return
  27547. }
  27548. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27549. result, _ := json.Marshal(respJSON)
  27550. fmt.Println("log")
  27551. fmt.Println(string(result))
  27552. if err := json.Unmarshal(result, &ahres); err != nil {
  27553. utils.ErrorLog("解析失败:%v", err)
  27554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27555. return
  27556. }
  27557. res.InfRefmsgid = ahres.InfRefmsgid
  27558. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27559. // 创建对应的Time类型
  27560. t := time.UnixMilli(timestamp)
  27561. // 格式化成指定的日期字符串
  27562. str := t.Format("2006-01-02 15:04:05")
  27563. res.Output.Setlinfo.SetlTime = str
  27564. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27565. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27566. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27567. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27568. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27569. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27570. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27571. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27572. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27573. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27574. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27575. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27576. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27577. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27578. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27579. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27580. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27581. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27582. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27583. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27584. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27585. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27586. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27587. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27588. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27589. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27590. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27591. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27592. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27593. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27594. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27595. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27596. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27597. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27598. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27599. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27600. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  27601. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27602. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27603. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27604. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27605. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27606. res.Output.Setldetail = ahres.Output.Setldetail
  27607. res.ErrMsg = ahres.ErrMsg
  27608. res.Cainfo = ahres.Cainfo
  27609. res.WarnMsg = ahres.WarnMsg
  27610. res.Infcode = ahres.Infcode
  27611. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  27612. res.Output.Setlinfo.ClrType = "11"
  27613. } else {
  27614. res.Output.Setlinfo.ClrType = "9903"
  27615. }
  27616. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27617. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27618. var cert_no string
  27619. if his.IdCardType == 1 {
  27620. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27621. } else if his.IdCardType == 2 {
  27622. cert_no = his.IdCardNo
  27623. } else {
  27624. cert_no = psn_info.VerifyNumber
  27625. }
  27626. 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, "")
  27627. var dat map[string]interface{}
  27628. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27629. fmt.Println(dat)
  27630. } else {
  27631. fmt.Println(err)
  27632. }
  27633. saveLog(result2, src_resquest, "2207", "结算")
  27634. userJSONBytes, _ := json.Marshal(dat)
  27635. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27636. utils.ErrorLog("解析失败:%v", err)
  27637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27638. return
  27639. }
  27640. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27641. psn_info, _ := service.GetPsnByPatientId(id)
  27642. var verify_number string
  27643. if psn_info.IdCardType == 4 {
  27644. verify_number = psn_info.VerifyNumber
  27645. } else if psn_info.IdCardType == 1 {
  27646. bas := strings.Split(psn_info.CardInfo, "|")
  27647. cardNumber := bas[2]
  27648. verify_number = cardNumber
  27649. } else {
  27650. verify_number = psn_info.Certno
  27651. psn_info.IdCardType = 2
  27652. }
  27653. var api string
  27654. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27655. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27656. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27657. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27658. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27659. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27660. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  27661. resp, requestErr := http.Get(api)
  27662. if requestErr != nil {
  27663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27664. return
  27665. }
  27666. body, ioErr := ioutil.ReadAll(resp.Body)
  27667. if ioErr != nil {
  27668. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27670. return
  27671. }
  27672. var respJSON map[string]interface{}
  27673. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27674. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27676. return
  27677. }
  27678. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27679. result, _ := json.Marshal(respJSON)
  27680. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27681. utils.ErrorLog("解析失败:%v", err)
  27682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27683. return
  27684. }
  27685. } else {
  27686. var src_resquest string
  27687. if miConfig.Code == "H15049901371" {
  27688. //赤峰地区国家医保医疗类别
  27689. //职工透析:医疗类别选特殊情况门诊990502
  27690. //居民定额血透门慢: 医疗类别选门诊慢病140104
  27691. var med_type string
  27692. if his.Insutype == "390" {
  27693. if reg_type == 14 {
  27694. med_type = "9933"
  27695. } else if reg_type == 11 {
  27696. med_type = "11"
  27697. }
  27698. } else if his.Insutype == "310" {
  27699. if reg_type == 14 {
  27700. med_type = "990502"
  27701. } else if reg_type == 11 {
  27702. med_type = "11"
  27703. }
  27704. }
  27705. 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)
  27706. } else {
  27707. if his.IdCardType == 4 {
  27708. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27709. token := psn_info.VerifyNumber
  27710. 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)
  27711. } else {
  27712. 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)
  27713. }
  27714. }
  27715. var dat map[string]interface{}
  27716. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27717. fmt.Println(dat)
  27718. } else {
  27719. fmt.Println(err)
  27720. }
  27721. saveLog(result2, src_resquest, "2207", "结算")
  27722. userJSONBytes, _ := json.Marshal(dat)
  27723. if miConfig.Code == "H15049901371" {
  27724. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27725. utils.ErrorLog("解析失败:%v", err)
  27726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27727. return
  27728. }
  27729. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27730. res.Output = resSeven10265.Output
  27731. res.ErrMsg = resSeven10265.ErrMsg
  27732. res.Cainfo = resSeven10265.Cainfo
  27733. res.WarnMsg = resSeven10265.WarnMsg
  27734. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27735. res.Infcode = infocode
  27736. } else {
  27737. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27738. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  27739. utils.ErrorLog("解析失败:%v", err)
  27740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27741. return
  27742. }
  27743. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  27744. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  27745. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  27746. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27747. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  27748. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  27749. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  27750. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27751. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  27752. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27753. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27754. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27755. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27756. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27757. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27758. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  27759. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  27760. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  27761. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  27762. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  27763. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27764. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  27765. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  27766. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  27767. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  27768. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  27769. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  27770. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  27771. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  27772. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27773. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  27774. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  27775. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  27776. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27777. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27778. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27779. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27780. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27781. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27782. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27783. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27784. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27785. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27786. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27787. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27788. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27789. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27790. res.Cainfo = gzresSeven10265Two.Cainfo
  27791. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27792. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27793. //res.Infcode = infocode
  27794. } else {
  27795. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27796. utils.ErrorLog("解析失败:%v", err)
  27797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27798. return
  27799. }
  27800. }
  27801. }
  27802. }
  27803. if res.Infcode == -1 {
  27804. errlog := &models.HisOrderError{
  27805. UserOrgId: adminUser.CurrentOrgId,
  27806. Ctime: time.Now().Unix(),
  27807. Mtime: time.Now().Unix(),
  27808. Number: chrg_bchno,
  27809. ErrMsg: res.ErrMsg,
  27810. Status: 1,
  27811. PatientId: id,
  27812. RecordTime: recordDateTime,
  27813. Stage: 6,
  27814. }
  27815. service.CreateErrMsgLog(errlog)
  27816. c.ServeSuccessJSON(map[string]interface{}{
  27817. "failed_code": -10,
  27818. "msg": res.ErrMsg,
  27819. })
  27820. return
  27821. } else {
  27822. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27823. order.OrderStatus = 2
  27824. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27825. order.SetlId = res.Output.Setlinfo.SetlID
  27826. order.PsnNo = res.Output.Setlinfo.PsnNo
  27827. order.PsnName = res.Output.Setlinfo.PsnName
  27828. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  27829. order.Certno = res.Output.Setlinfo.Certno
  27830. order.Gend = res.Output.Setlinfo.Gend
  27831. order.Naty = res.Output.Setlinfo.Naty
  27832. order.Age = res.Output.Setlinfo.Age
  27833. order.Insutype = res.Output.Setlinfo.Insutype
  27834. order.PsnType = res.Output.Setlinfo.PsnType
  27835. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  27836. order.SetlTime = res.Output.Setlinfo.SetlTime
  27837. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  27838. order.PayWays = pay_ways
  27839. order.AcctUsedFlag = acct_used_flag
  27840. order.WechatPay = wechat_pay
  27841. order.AliPay = ali_pay
  27842. order.JifenPay = jifen_pay
  27843. order.BandCardPay = band_card_pay
  27844. order.CashPay = cash_pay
  27845. order.OthDesc = oth_desc
  27846. //order.MedType = res.Output.Setlinfo.MedType
  27847. if reg_type == 1112 {
  27848. order.MedType = "1112"
  27849. }
  27850. if reg_type == 1111 {
  27851. order.MedType = "1111"
  27852. }
  27853. order.ClrType = res.Output.Setlinfo.ClrType
  27854. if adminUser.CurrentOrgId == 10480 {
  27855. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  27856. order.ClrType = "11"
  27857. } else {
  27858. order.ClrType = "9903"
  27859. }
  27860. }
  27861. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  27862. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  27863. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  27864. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  27865. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  27866. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  27867. order.HifpPay = res.Output.Setlinfo.HifpPay
  27868. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  27869. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  27870. order.HifesPay = res.Output.Setlinfo.HifesPay
  27871. order.HifobPay = res.Output.Setlinfo.HifobPay
  27872. order.MafPay = res.Output.Setlinfo.MafPay
  27873. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  27874. order.OthPay = res.Output.Setlinfo.OthPay
  27875. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  27876. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  27877. order.AcctPay = res.Output.Setlinfo.AcctPay
  27878. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  27879. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  27880. order.Balc = res.Output.Setlinfo.Balc
  27881. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  27882. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  27883. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  27884. order.ClrWay = res.Output.Setlinfo.ClrWay
  27885. order.Creator = order.Creator
  27886. order.Modify = roles.AdminUserId
  27887. order.RequestLog = src_resquest
  27888. order.Diagnosis = diagnosis_id
  27889. order.FaPiaoNumber = fapiao_number
  27890. order.FaPiaoCode = fapiao_code
  27891. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  27892. detailStr := string(setlDetail)
  27893. order.SetlDetail = detailStr
  27894. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  27895. err = service.UpDateOrder(order)
  27896. if err == nil {
  27897. //判断是否使用了押金
  27898. if dec_way == "true" {
  27899. tmpstring := strconv.FormatInt(order.ID, 10)
  27900. //扣押金
  27901. order.Decimal = decimal
  27902. service.UpDateOrder(order)
  27903. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  27904. if errmsg != nil {
  27905. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  27906. return
  27907. }
  27908. }
  27909. c.ServeSuccessJSON(map[string]interface{}{
  27910. "msg": "结算成功",
  27911. })
  27912. } else {
  27913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  27914. return
  27915. }
  27916. }
  27917. }
  27918. }
  27919. }
  27920. // 上传明细-预结算-
  27921. func (c *HisApiController) GetPreUploadInfo() {
  27922. id, _ := c.GetInt64("id")
  27923. record_time := c.GetString("record_time")
  27924. his_patient_id, _ := c.GetInt64("his_patient_id")
  27925. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  27926. admin_user_id, _ := c.GetInt64("admin_user_id")
  27927. diagnosis_id := c.GetString("diagnosis")
  27928. sick_type, _ := c.GetInt64("sick_type")
  27929. reg_type, _ := c.GetInt64("p_type")
  27930. begin_time := c.GetString("begin_time")
  27931. acct_used_flag := c.GetString("acct_used_flag")
  27932. id_str := c.GetString("ids")
  27933. ids_arr := strings.Split(id_str, ",")
  27934. timeLayout := "2006-01-02"
  27935. loc, _ := time.LoadLocation("Local")
  27936. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27937. if err != nil {
  27938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27939. return
  27940. }
  27941. recordDateTime := theTime.Unix()
  27942. adminUser := c.GetAdminUserInfo()
  27943. diagnosis_ids := strings.Split(diagnosis_id, ",")
  27944. var config []*models.HisXtDiagnoseConfig
  27945. for _, item := range diagnosis_ids {
  27946. id, _ := strconv.ParseInt(item, 10, 64)
  27947. if id > 0 {
  27948. diagnosisConfig, _ := service.FindDiagnoseById(id)
  27949. config = append(config, &diagnosisConfig)
  27950. }
  27951. }
  27952. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  27953. sickConfig, _ := service.FindSickById(sick_type)
  27954. var prescriptions []*models.HisPrescription
  27955. var start_time int64
  27956. var end_time int64
  27957. var isSuccess bool = true
  27958. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27959. fmt.Println(his_patient_id)
  27960. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  27961. timestamp := time.Now().Unix()
  27962. tempTime := time.Unix(timestamp, 0)
  27963. timeFormat := tempTime.Format("20060102150405")
  27964. chrgBchno := rand.Intn(100000) + 10000
  27965. new_chrg_bchno := ""
  27966. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  27967. new_chrg_bchno = chrg_bchno
  27968. if adminUser.CurrentOrgId == 10265 {
  27969. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  27970. new_chrg_bchno = "0000"
  27971. }
  27972. }
  27973. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27974. var patientPrescription models.HisPrescriptionInfo
  27975. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  27976. if patientPrescription.ID == 0 {
  27977. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  27978. }
  27979. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27980. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27981. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  27982. strconv.FormatInt(his.PatientId, 10)
  27983. var res2406 Result2406
  27984. //安徽单病种处理
  27985. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  27986. data := make(map[string]interface{})
  27987. client := &http.Client{}
  27988. data["psn_no"] = his.PsnNo
  27989. data["mdtrt_id"] = his.Number
  27990. data["operator"] = roles.UserName
  27991. data["cert_no"] = his.IdCardNo
  27992. data["org_name"] = miConfig.OrgName
  27993. data["psn_name"] = his.Name
  27994. data["ipt_otp_no"] = his.IptOtpNo
  27995. data["ipt_psn_sp_flag_type"] = "0901"
  27996. data["ipt_psn_sp_flag"] = "1"
  27997. data["fixmedins_code"] = miConfig.Code
  27998. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  27999. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28000. data["url"] = miConfig.Url
  28001. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  28002. bytesData, _ := json.Marshal(data)
  28003. var req *http.Request
  28004. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  28005. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  28006. resp, _ := client.Do(req)
  28007. defer resp.Body.Close()
  28008. body, ioErr := ioutil.ReadAll(resp.Body)
  28009. if ioErr != nil {
  28010. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28012. return
  28013. }
  28014. var respJSON map[string]interface{}
  28015. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28016. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28018. return
  28019. }
  28020. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28021. if status == "0" {
  28022. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28023. c.ServeSuccessJSON(map[string]interface{}{
  28024. "failed_code": -10,
  28025. "msg": err_msg,
  28026. })
  28027. return
  28028. }
  28029. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28030. userJSONBytes, _ := json.Marshal(respJSON)
  28031. fmt.Println("log")
  28032. fmt.Println(string(userJSONBytes))
  28033. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  28034. utils.ErrorLog("解析失败:%v", err)
  28035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28036. return
  28037. }
  28038. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  28039. data := make(map[string]interface{})
  28040. client := &http.Client{}
  28041. data["psn_no"] = his.PsnNo
  28042. data["mdtrt_id"] = his.Number
  28043. data["operator"] = roles.UserName
  28044. data["cert_no"] = his.IdCardNo
  28045. data["org_name"] = miConfig.OrgName
  28046. data["psn_name"] = his.Name
  28047. data["ipt_otp_no"] = his.IptOtpNo
  28048. data["ipt_psn_sp_flag_type"] = "0901"
  28049. data["ipt_psn_sp_flag"] = "1"
  28050. data["fixmedins_code"] = miConfig.Code
  28051. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28052. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28053. data["url"] = miConfig.Url
  28054. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  28055. bytesData, _ := json.Marshal(data)
  28056. var req *http.Request
  28057. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  28058. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  28059. resp, _ := client.Do(req)
  28060. defer resp.Body.Close()
  28061. body, ioErr := ioutil.ReadAll(resp.Body)
  28062. if ioErr != nil {
  28063. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28065. return
  28066. }
  28067. var respJSON map[string]interface{}
  28068. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28069. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28071. return
  28072. }
  28073. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28074. if status == "0" {
  28075. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28076. c.ServeSuccessJSON(map[string]interface{}{
  28077. "failed_code": -10,
  28078. "msg": err_msg,
  28079. })
  28080. return
  28081. }
  28082. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28083. userJSONBytes, _ := json.Marshal(respJSON)
  28084. fmt.Println("log")
  28085. fmt.Println(string(userJSONBytes))
  28086. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  28087. utils.ErrorLog("解析失败:%v", err)
  28088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28089. return
  28090. }
  28091. }
  28092. if res2406.Infcode != 0 {
  28093. adminUser := c.GetAdminUserInfo()
  28094. errlog := &models.HisOrderError{
  28095. UserOrgId: adminUser.CurrentOrgId,
  28096. Ctime: time.Now().Unix(),
  28097. Mtime: time.Now().Unix(),
  28098. ErrMsg: res2406.ErrMsg,
  28099. Status: 1,
  28100. PatientId: id,
  28101. RecordTime: recordDateTime,
  28102. Stage: 3,
  28103. }
  28104. service.CreateErrMsgLog(errlog)
  28105. c.ServeSuccessJSON(map[string]interface{}{
  28106. "failed_code": -10,
  28107. "msg": res2406.ErrMsg,
  28108. })
  28109. return
  28110. }
  28111. var res2 ResultSix
  28112. var res3 GZResultSix
  28113. var resSix10265 ResultSix10265
  28114. //var time_stamp string
  28115. if miConfig.MdtrtareaAdmvs == "421300" {
  28116. data := make(map[string]interface{})
  28117. client := &http.Client{}
  28118. data["psn_no"] = his.PsnNo
  28119. data["mdtrt_id"] = his.Number
  28120. data["department"] = department.Name
  28121. data["org_name"] = miConfig.OrgName
  28122. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28123. data["doctor_id"] = doctor_info.DoctorNumber
  28124. data["doctor_name"] = roles.UserName
  28125. data["fixmedins_code"] = miConfig.Code
  28126. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28127. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28128. data["secret_key"] = miConfig.SecretKey
  28129. data["sick_code"] = sickConfig.CountryCode
  28130. data["sick_name"] = sickConfig.ClassName
  28131. data["begin_time"] = begin_time
  28132. data["dept"] = strconv.FormatInt(department.ID, 10)
  28133. data["config"] = config
  28134. data["opter"] = roles.UserName
  28135. fmt.Println(data)
  28136. bytesData, _ := json.Marshal(data)
  28137. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28138. resp, _ := client.Do(req)
  28139. defer resp.Body.Close()
  28140. body, ioErr := ioutil.ReadAll(resp.Body)
  28141. if ioErr != nil {
  28142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28144. return
  28145. }
  28146. var respJSON map[string]interface{}
  28147. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28150. return
  28151. }
  28152. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28153. userJSONBytes, _ := json.Marshal(respJSON)
  28154. fmt.Println("log")
  28155. fmt.Println(string(userJSONBytes))
  28156. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28157. utils.ErrorLog("解析失败:%v", err)
  28158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28159. return
  28160. }
  28161. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28162. data := make(map[string]interface{})
  28163. client := &http.Client{}
  28164. data["psn_no"] = his.PsnNo
  28165. data["mdtrt_id"] = his.Number
  28166. data["department"] = department.Name
  28167. data["org_name"] = miConfig.OrgName
  28168. if reg_type == 11 && his.Insutype == "390" {
  28169. data["med_type"] = "110104"
  28170. } else {
  28171. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28172. }
  28173. data["doctor_id"] = doctor_info.DoctorNumber
  28174. data["doctor_name"] = roles.UserName
  28175. data["fixmedins_code"] = miConfig.Code
  28176. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28177. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28178. data["secret_key"] = miConfig.SecretKey
  28179. data["sick_code"] = sickConfig.CountryCode
  28180. data["sick_name"] = sickConfig.ClassName
  28181. data["begin_time"] = begin_time
  28182. data["dept"] = strconv.FormatInt(department.ID, 10)
  28183. data["config"] = config
  28184. data["opter"] = roles.UserName
  28185. fmt.Println(data)
  28186. bytesData, _ := json.Marshal(data)
  28187. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  28188. resp, _ := client.Do(req)
  28189. defer resp.Body.Close()
  28190. body, ioErr := ioutil.ReadAll(resp.Body)
  28191. if ioErr != nil {
  28192. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28194. return
  28195. }
  28196. var respJSON map[string]interface{}
  28197. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28198. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28200. return
  28201. }
  28202. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28203. userJSONBytes, _ := json.Marshal(respJSON)
  28204. fmt.Println("log")
  28205. fmt.Println(string(userJSONBytes))
  28206. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28207. utils.ErrorLog("解析失败:%v", err)
  28208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28209. return
  28210. }
  28211. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28212. data := make(map[string]interface{})
  28213. client := &http.Client{}
  28214. data["psn_no"] = his.PsnNo
  28215. data["mdtrt_id"] = his.Number
  28216. data["department"] = department.Name
  28217. data["org_name"] = miConfig.OrgName
  28218. if reg_type == 11 && his.Insutype == "390" {
  28219. data["med_type"] = "110104"
  28220. } else {
  28221. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28222. }
  28223. data["doctor_id"] = doctor_info.DoctorNumber
  28224. data["doctor_name"] = roles.UserName
  28225. data["fixmedins_code"] = miConfig.Code
  28226. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28227. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28228. data["secret_key"] = miConfig.SecretKey
  28229. data["sick_code"] = sickConfig.CountryCode
  28230. data["sick_name"] = sickConfig.ClassName
  28231. data["begin_time"] = begin_time
  28232. data["dept"] = strconv.FormatInt(department.ID, 10)
  28233. data["config"] = config
  28234. data["opter"] = roles.UserName
  28235. fmt.Println(data)
  28236. bytesData, _ := json.Marshal(data)
  28237. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28238. resp, _ := client.Do(req)
  28239. defer resp.Body.Close()
  28240. body, ioErr := ioutil.ReadAll(resp.Body)
  28241. if ioErr != nil {
  28242. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28244. return
  28245. }
  28246. var respJSON map[string]interface{}
  28247. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28248. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28250. return
  28251. }
  28252. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28253. userJSONBytes, _ := json.Marshal(respJSON)
  28254. fmt.Println("log")
  28255. fmt.Println(string(userJSONBytes))
  28256. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28257. utils.ErrorLog("解析失败:%v", err)
  28258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28259. return
  28260. }
  28261. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28262. data := make(map[string]interface{})
  28263. client := &http.Client{}
  28264. data["psn_no"] = his.PsnNo
  28265. data["mdtrt_id"] = his.Number
  28266. data["department"] = department.Name
  28267. data["org_name"] = miConfig.OrgName
  28268. if reg_type == 11 && his.Insutype == "390" {
  28269. data["med_type"] = "110104"
  28270. } else {
  28271. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28272. }
  28273. data["doctor_id"] = doctor_info.DoctorNumber
  28274. data["doctor_name"] = roles.UserName
  28275. data["fixmedins_code"] = miConfig.Code
  28276. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28277. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28278. data["secret_key"] = miConfig.SecretKey
  28279. data["sick_code"] = sickConfig.CountryCode
  28280. data["sick_name"] = sickConfig.ClassName
  28281. data["begin_time"] = begin_time
  28282. data["dept"] = strconv.FormatInt(department.ID, 10)
  28283. data["config"] = config
  28284. data["opter"] = roles.UserName
  28285. fmt.Println(data)
  28286. bytesData, _ := json.Marshal(data)
  28287. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  28288. resp, _ := client.Do(req)
  28289. defer resp.Body.Close()
  28290. body, ioErr := ioutil.ReadAll(resp.Body)
  28291. if ioErr != nil {
  28292. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28294. return
  28295. }
  28296. var respJSON map[string]interface{}
  28297. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28300. return
  28301. }
  28302. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28303. userJSONBytes, _ := json.Marshal(respJSON)
  28304. fmt.Println("log")
  28305. fmt.Println(string(userJSONBytes))
  28306. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28307. utils.ErrorLog("解析失败:%v", err)
  28308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28309. return
  28310. }
  28311. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28312. data := make(map[string]interface{})
  28313. client := &http.Client{}
  28314. data["psn_no"] = his.PsnNo
  28315. data["mdtrt_id"] = his.Number
  28316. data["doctor"] = roles.UserName
  28317. data["department"] = department.Name
  28318. data["org_name"] = miConfig.OrgName
  28319. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28320. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28321. data["fixmedins_code"] = miConfig.Code
  28322. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28323. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28324. data["secret_key"] = miConfig.SecretKey
  28325. data["sick_code"] = sickConfig.CountryCode
  28326. data["sick_name"] = sickConfig.ClassName
  28327. data["begin_time"] = begin_time
  28328. data["dept"] = strconv.FormatInt(department.ID, 10)
  28329. data["config"] = config
  28330. data["url"] = miConfig.Url
  28331. data["ak"] = miConfig.AccessKey
  28332. data["cainfo"] = miConfig.Cainfo
  28333. bytesData, _ := json.Marshal(data)
  28334. var req *http.Request
  28335. if miConfig.MdtrtareaAdmvs == "320921" {
  28336. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28337. } else {
  28338. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  28339. }
  28340. resp, _ := client.Do(req)
  28341. defer resp.Body.Close()
  28342. body, ioErr := ioutil.ReadAll(resp.Body)
  28343. if ioErr != nil {
  28344. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28346. return
  28347. }
  28348. var respJSON map[string]interface{}
  28349. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28352. return
  28353. }
  28354. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28355. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28356. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28357. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28358. userJSONBytes, _ := json.Marshal(respJSON)
  28359. fmt.Println("log")
  28360. fmt.Println(string(userJSONBytes))
  28361. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28362. utils.ErrorLog("解析失败:%v", err)
  28363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28364. return
  28365. }
  28366. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28367. res2.Output = resSix10265.Output
  28368. res2.ErrMsg = resSix10265.ErrMsg
  28369. res2.Cainfo = resSix10265.Cainfo
  28370. res2.WarnMsg = resSix10265.WarnMsg
  28371. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28372. res2.Infcode = infocode
  28373. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28374. data := make(map[string]interface{})
  28375. client := &http.Client{}
  28376. data["psn_no"] = his.PsnNo
  28377. data["mdtrt_id"] = his.Number
  28378. data["doctor"] = roles.UserName
  28379. data["department"] = department.Name
  28380. data["org_name"] = miConfig.OrgName
  28381. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28382. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  28383. data["fixmedins_code"] = miConfig.Code
  28384. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28385. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28386. data["secret_key"] = miConfig.SecretKey
  28387. data["sick_code"] = sickConfig.CountryCode
  28388. data["sick_name"] = sickConfig.ClassName
  28389. data["begin_time"] = begin_time
  28390. data["dept"] = strconv.FormatInt(department.ID, 10)
  28391. data["config"] = config
  28392. //data["url"] = miConfig.Url
  28393. //data["ak"] = miConfig.AccessKey
  28394. data["cainfo"] = miConfig.Cainfo
  28395. fmt.Println(data)
  28396. bytesData, _ := json.Marshal(data)
  28397. var req *http.Request
  28398. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  28399. resp, _ := client.Do(req)
  28400. defer resp.Body.Close()
  28401. body, ioErr := ioutil.ReadAll(resp.Body)
  28402. if ioErr != nil {
  28403. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28405. return
  28406. }
  28407. var respJSON map[string]interface{}
  28408. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28409. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28411. return
  28412. }
  28413. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  28414. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  28415. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  28416. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28417. userJSONBytes, _ := json.Marshal(respJSON)
  28418. fmt.Println("log")
  28419. fmt.Println(string(userJSONBytes))
  28420. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  28421. utils.ErrorLog("解析失败:%v", err)
  28422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28423. return
  28424. }
  28425. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28426. res2.Output = resSix10265.Output
  28427. res2.ErrMsg = resSix10265.ErrMsg
  28428. res2.Cainfo = resSix10265.Cainfo
  28429. res2.WarnMsg = resSix10265.WarnMsg
  28430. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28431. res2.Infcode = infocode
  28432. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28433. 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)
  28434. saveLog(result, requestLog, "2203", "上传就诊信息")
  28435. var respJSON2 map[string]interface{}
  28436. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28437. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28439. return
  28440. }
  28441. userJSONBytes2, _ := json.Marshal(respJSON2)
  28442. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28443. utils.ErrorLog("解析失败:%v", err)
  28444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28445. return
  28446. }
  28447. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28448. var result string
  28449. var requestLog string
  28450. 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, "")
  28451. saveLog(result, requestLog, "2203", "上传就诊信息")
  28452. var respJSON2 map[string]interface{}
  28453. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28454. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28456. return
  28457. }
  28458. userJSONBytes2, _ := json.Marshal(respJSON2)
  28459. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28460. utils.ErrorLog("解析失败:%v", err)
  28461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28462. return
  28463. }
  28464. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28465. var result string
  28466. var requestLog string
  28467. 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, "")
  28468. saveLog(result, requestLog, "2203", "上传就诊信息")
  28469. var respJSON2 map[string]interface{}
  28470. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28471. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28473. return
  28474. }
  28475. userJSONBytes2, _ := json.Marshal(respJSON2)
  28476. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28477. utils.ErrorLog("解析失败:%v", err)
  28478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28479. return
  28480. }
  28481. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28482. data := make(map[string]interface{})
  28483. client := &http.Client{}
  28484. data["psn_no"] = his.PsnNo
  28485. data["mdtrt_id"] = his.Number
  28486. data["operator"] = roles.UserName
  28487. data["department"] = department.Name
  28488. data["org_name"] = miConfig.OrgName
  28489. var med_type string
  28490. if his.Insutype == "390" {
  28491. if reg_type == 992102 {
  28492. med_type = "992102"
  28493. data["sick_code"] = "ZDZ940"
  28494. data["sick_name"] = "慢性肾衰竭"
  28495. }
  28496. if reg_type == 140104 {
  28497. med_type = "140104"
  28498. data["sick_code"] = sickConfig.CountryCode
  28499. data["sick_name"] = sickConfig.ClassName
  28500. }
  28501. if reg_type == 14 {
  28502. med_type = "140104"
  28503. data["sick_code"] = sickConfig.CountryCode
  28504. data["sick_name"] = sickConfig.ClassName
  28505. }
  28506. } else if his.Insutype == "310" {
  28507. if reg_type == 992102 {
  28508. med_type = "992102"
  28509. data["sick_code"] = "ZDZ940"
  28510. data["sick_name"] = "慢性肾衰竭"
  28511. }
  28512. if reg_type == 140104 {
  28513. med_type = "140104"
  28514. data["sick_code"] = sickConfig.CountryCode
  28515. data["sick_name"] = sickConfig.ClassName
  28516. }
  28517. if reg_type == 14 {
  28518. med_type = "14"
  28519. data["sick_code"] = sickConfig.CountryCode
  28520. data["sick_name"] = sickConfig.ClassName
  28521. }
  28522. }
  28523. data["med_type"] = med_type
  28524. data["doctor_number"] = doctor_info.DoctorNumber
  28525. data["doctor_name"] = doctor_info.UserName
  28526. data["fixmedins_code"] = miConfig.Code
  28527. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28528. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28529. data["secret_key"] = miConfig.SecretKey
  28530. data["begin_time"] = begin_time
  28531. data["dept"] = strconv.FormatInt(department.ID, 10)
  28532. data["config"] = config
  28533. data["url"] = miConfig.Url
  28534. data["ak"] = miConfig.AccessKey
  28535. data["cainfo"] = miConfig.Cainfo
  28536. bytesData, _ := json.Marshal(data)
  28537. var req *http.Request
  28538. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28539. resp, _ := client.Do(req)
  28540. defer resp.Body.Close()
  28541. body, ioErr := ioutil.ReadAll(resp.Body)
  28542. if ioErr != nil {
  28543. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28545. return
  28546. }
  28547. var respJSON map[string]interface{}
  28548. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28549. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28551. return
  28552. }
  28553. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28554. if status == "0" {
  28555. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28556. c.ServeSuccessJSON(map[string]interface{}{
  28557. "failed_code": -10,
  28558. "msg": err_msg,
  28559. })
  28560. return
  28561. }
  28562. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28563. userJSONBytes, _ := json.Marshal(respJSON)
  28564. fmt.Println("log")
  28565. fmt.Println(string(userJSONBytes))
  28566. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28567. utils.ErrorLog("解析失败:%v", err)
  28568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28569. return
  28570. }
  28571. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28572. data := make(map[string]interface{})
  28573. client := &http.Client{}
  28574. data["psn_no"] = his.PsnNo
  28575. data["mdtrt_id"] = his.Number
  28576. data["operator"] = roles.UserName
  28577. data["department"] = department.Name
  28578. data["org_name"] = miConfig.OrgName
  28579. var med_type string
  28580. if his.Insutype == "390" {
  28581. if reg_type == 992102 {
  28582. med_type = "992102"
  28583. data["sick_code"] = sickConfig.CountryCode
  28584. data["sick_name"] = sickConfig.ClassName
  28585. }
  28586. if reg_type == 140104 {
  28587. med_type = "140104"
  28588. data["sick_code"] = sickConfig.CountryCode
  28589. data["sick_name"] = sickConfig.ClassName
  28590. }
  28591. if reg_type == 140201 {
  28592. med_type = "140201"
  28593. data["sick_code"] = sickConfig.CountryCode
  28594. data["sick_name"] = sickConfig.ClassName
  28595. }
  28596. if reg_type == 14 {
  28597. med_type = "14"
  28598. data["sick_code"] = sickConfig.CountryCode
  28599. data["sick_name"] = sickConfig.ClassName
  28600. }
  28601. } else if his.Insutype == "310" {
  28602. if reg_type == 992102 {
  28603. med_type = "992102"
  28604. data["sick_code"] = sickConfig.CountryCode
  28605. data["sick_name"] = sickConfig.ClassName
  28606. }
  28607. if reg_type == 140104 {
  28608. med_type = "140104"
  28609. data["sick_code"] = sickConfig.CountryCode
  28610. data["sick_name"] = sickConfig.ClassName
  28611. }
  28612. if reg_type == 140201 {
  28613. med_type = "140201"
  28614. data["sick_code"] = sickConfig.CountryCode
  28615. data["sick_name"] = sickConfig.ClassName
  28616. }
  28617. if reg_type == 14 {
  28618. med_type = "14"
  28619. data["sick_code"] = sickConfig.CountryCode
  28620. data["sick_name"] = sickConfig.ClassName
  28621. }
  28622. }
  28623. data["med_type"] = med_type
  28624. data["doctor_number"] = doctor_info.DoctorNumber
  28625. data["doctor_name"] = doctor_info.UserName
  28626. data["fixmedins_code"] = miConfig.Code
  28627. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28628. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28629. data["secret_key"] = miConfig.SecretKey
  28630. data["begin_time"] = begin_time
  28631. data["dept"] = strconv.FormatInt(department.ID, 10)
  28632. data["config"] = config
  28633. data["url"] = miConfig.Url
  28634. data["ak"] = miConfig.AccessKey
  28635. data["cainfo"] = miConfig.Cainfo
  28636. bytesData, _ := json.Marshal(data)
  28637. var req *http.Request
  28638. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  28639. resp, _ := client.Do(req)
  28640. defer resp.Body.Close()
  28641. body, ioErr := ioutil.ReadAll(resp.Body)
  28642. if ioErr != nil {
  28643. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28645. return
  28646. }
  28647. var respJSON map[string]interface{}
  28648. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28649. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28651. return
  28652. }
  28653. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28654. if status == "0" {
  28655. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28656. c.ServeSuccessJSON(map[string]interface{}{
  28657. "failed_code": -10,
  28658. "msg": err_msg,
  28659. })
  28660. return
  28661. }
  28662. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28663. userJSONBytes, _ := json.Marshal(respJSON)
  28664. fmt.Println("log")
  28665. fmt.Println(string(userJSONBytes))
  28666. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28667. utils.ErrorLog("解析失败:%v", err)
  28668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28669. return
  28670. }
  28671. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28672. var result string
  28673. var requestLog string
  28674. 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, "")
  28675. saveLog(result, requestLog, "2203", "上传就诊信息")
  28676. var respJSON2 map[string]interface{}
  28677. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28678. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28680. return
  28681. }
  28682. userJSONBytes2, _ := json.Marshal(respJSON2)
  28683. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28684. utils.ErrorLog("解析失败:%v", err)
  28685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28686. return
  28687. }
  28688. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28689. data := make(map[string]interface{})
  28690. client := &http.Client{}
  28691. data["psn_no"] = his.PsnNo
  28692. data["mdtrt_id"] = his.Number
  28693. data["doctor"] = roles.UserName
  28694. data["department"] = department.Name
  28695. data["org_name"] = miConfig.OrgName
  28696. data["med_type"] = strconv.FormatInt(reg_type, 10)
  28697. data["doctor_id"] = doctor_info.DoctorNumber
  28698. data["fixmedins_code"] = miConfig.Code
  28699. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28700. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28701. data["secret_key"] = miConfig.SecretKey
  28702. data["sick_code"] = sickConfig.CountryCode
  28703. data["sick_name"] = sickConfig.ClassName
  28704. data["begin_time"] = begin_time
  28705. data["new_doctor_name"] = doctor_info.UserName
  28706. data["dept"] = strconv.FormatInt(department.ID, 10)
  28707. data["config"] = config
  28708. bytesData, _ := json.Marshal(data)
  28709. var req *http.Request
  28710. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  28711. resp, _ := client.Do(req)
  28712. defer resp.Body.Close()
  28713. body, ioErr := ioutil.ReadAll(resp.Body)
  28714. if ioErr != nil {
  28715. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28717. return
  28718. }
  28719. var respJSON map[string]interface{}
  28720. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28721. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28723. return
  28724. }
  28725. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28726. userJSONBytes, _ := json.Marshal(respJSON)
  28727. fmt.Println("log")
  28728. fmt.Println(string(userJSONBytes))
  28729. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28730. utils.ErrorLog("解析失败:%v", err)
  28731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28732. return
  28733. }
  28734. } else {
  28735. var result string
  28736. var requestLog string
  28737. if miConfig.MdtrtareaAdmvs == "440781" { //
  28738. 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)
  28739. } else {
  28740. if miConfig.Code == "H15049901371" {
  28741. //赤峰地区国家医保医疗类别
  28742. //职工透析:医疗类别选特殊情况门诊990502
  28743. //居民定额血透门慢: 医疗类别选门诊慢病140104
  28744. var med_type string
  28745. if his.Insutype == "390" {
  28746. if reg_type == 14 {
  28747. med_type = "9933"
  28748. } else if reg_type == 11 {
  28749. med_type = "11"
  28750. }
  28751. } else if his.Insutype == "310" {
  28752. if reg_type == 14 {
  28753. med_type = "990502"
  28754. } else if reg_type == 11 {
  28755. med_type = "11"
  28756. }
  28757. }
  28758. 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)
  28759. } else {
  28760. 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)
  28761. }
  28762. saveLog(result, requestLog, "2203", "上传就诊信息")
  28763. var respJSON2 map[string]interface{}
  28764. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  28765. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28767. return
  28768. }
  28769. userJSONBytes2, _ := json.Marshal(respJSON2)
  28770. if miConfig.Code == "H15049901371" {
  28771. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  28772. utils.ErrorLog("解析失败:%v", err)
  28773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28774. return
  28775. }
  28776. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28777. res2.Output = resSix10265.Output
  28778. res2.ErrMsg = resSix10265.ErrMsg
  28779. res2.Cainfo = resSix10265.Cainfo
  28780. res2.WarnMsg = resSix10265.WarnMsg
  28781. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28782. res2.Infcode = infocode
  28783. } else {
  28784. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28785. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  28786. utils.ErrorLog("解析失败:%v", err)
  28787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28788. return
  28789. }
  28790. res2.Infcode = res3.Infcode
  28791. } else {
  28792. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28793. utils.ErrorLog("解析失败:%v", err)
  28794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28795. return
  28796. }
  28797. }
  28798. }
  28799. }
  28800. }
  28801. if res2.Infcode == -1 {
  28802. adminUser := c.GetAdminUserInfo()
  28803. errlog := &models.HisOrderError{
  28804. UserOrgId: adminUser.CurrentOrgId,
  28805. Ctime: time.Now().Unix(),
  28806. Mtime: time.Now().Unix(),
  28807. ErrMsg: res2.ErrMsg,
  28808. Status: 1,
  28809. PatientId: id,
  28810. RecordTime: recordDateTime,
  28811. Stage: 3,
  28812. }
  28813. service.CreateErrMsgLog(errlog)
  28814. c.ServeSuccessJSON(map[string]interface{}{
  28815. "failed_code": -10,
  28816. "msg": res2.ErrMsg,
  28817. })
  28818. return
  28819. }
  28820. if res2.Infcode != 0 {
  28821. adminUser := c.GetAdminUserInfo()
  28822. errlog := &models.HisOrderError{
  28823. UserOrgId: adminUser.CurrentOrgId,
  28824. Ctime: time.Now().Unix(),
  28825. Mtime: time.Now().Unix(),
  28826. ErrMsg: res2.ErrMsg,
  28827. Status: 1,
  28828. PatientId: id,
  28829. RecordTime: recordDateTime,
  28830. Stage: 3,
  28831. }
  28832. service.CreateErrMsgLog(errlog)
  28833. c.ServeSuccessJSON(map[string]interface{}{
  28834. "failed_code": -10,
  28835. "msg": res2.ErrMsg,
  28836. })
  28837. return
  28838. } else {
  28839. his.Diagnosis = diagnosis_id
  28840. his.SickType = sickConfig.ID
  28841. his.PType = fmt.Sprintf("%d", reg_type)
  28842. service.UpdateHisPatientThree(&his)
  28843. data := make(map[string]interface{})
  28844. if settle_accounts_type == 1 { //日结
  28845. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  28846. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  28847. } else {
  28848. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  28849. }
  28850. data["pre"] = prescriptions
  28851. } else { //月结
  28852. start_time_str := c.GetString("start_time")
  28853. end_time_str := c.GetString("end_time")
  28854. timeLayout := "2006-01-02"
  28855. loc, _ := time.LoadLocation("Local")
  28856. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  28857. if err != nil {
  28858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28859. return
  28860. }
  28861. recordStartTime := theStartTime.Unix()
  28862. start_time = recordStartTime
  28863. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  28864. if err != nil {
  28865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28866. return
  28867. }
  28868. recordEndTime := theEndTime.Unix()
  28869. end_time = recordEndTime
  28870. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  28871. data["pre"] = prescriptions
  28872. }
  28873. client := &http.Client{}
  28874. data["psn_no"] = his.PsnNo
  28875. data["mdtrt_id"] = his.Number
  28876. data["chrg_bchno"] = new_chrg_bchno
  28877. data["org_name"] = miConfig.OrgName
  28878. data["doctor"] = doctor_info.UserName
  28879. data["doctor_id"] = doctor_info.DoctorNumber
  28880. data["dept"] = department.Name
  28881. data["fixmedins_code"] = miConfig.Code
  28882. data["opter"] = roles.UserName
  28883. data["dept_code"] = department.Number
  28884. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  28885. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28886. data["secret_key"] = miConfig.SecretKey
  28887. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  28888. data["url"] = miConfig.Url
  28889. data["ak"] = miConfig.AccessKey
  28890. data["new_doctor_name"] = patientPrescription.Doctor
  28891. if his.Insutype == "390" {
  28892. if reg_type == 992102 {
  28893. data["diag_code"] = "ZDZ940"
  28894. }
  28895. if reg_type == 140104 {
  28896. data["diag_code"] = sickConfig.CountryCode
  28897. }
  28898. if reg_type == 140201 {
  28899. data["diag_code"] = sickConfig.CountryCode
  28900. }
  28901. if reg_type == 14 {
  28902. data["diag_code"] = sickConfig.CountryCode
  28903. }
  28904. } else if his.Insutype == "310" {
  28905. if miConfig.MdtrtareaAdmvs == "341203" {
  28906. if reg_type == 992102 {
  28907. data["diag_code"] = "ZDZ940"
  28908. }
  28909. if reg_type != 992102 {
  28910. data["diag_code"] = sickConfig.CountryCode
  28911. }
  28912. } else {
  28913. data["diag_code"] = sickConfig.CountryCode
  28914. }
  28915. }
  28916. data["cainfo"] = miConfig.Cainfo
  28917. data["opter"] = roles.UserName
  28918. var ids []int64
  28919. for _, item := range prescriptions {
  28920. ids = append(ids, item.ID)
  28921. }
  28922. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28923. if config.IsOpen == 1 { //对接了医保,走医保流程
  28924. var res ResultFour
  28925. var resFour10265 ResultFour10265
  28926. if miConfig.MdtrtareaAdmvs == "421300" {
  28927. bytesData, _ := json.Marshal(data)
  28928. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  28929. resp, _ := client.Do(req)
  28930. defer resp.Body.Close()
  28931. body, ioErr := ioutil.ReadAll(resp.Body)
  28932. if ioErr != nil {
  28933. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28935. return
  28936. }
  28937. var respJSON map[string]interface{}
  28938. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28939. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28941. return
  28942. }
  28943. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28944. userJSONBytes, _ := json.Marshal(respJSON)
  28945. fmt.Println("log")
  28946. fmt.Println(string(userJSONBytes))
  28947. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28948. utils.ErrorLog("解析失败:%v", err)
  28949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28950. return
  28951. }
  28952. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28953. bytesData, _ := json.Marshal(data)
  28954. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  28955. resp, _ := client.Do(req)
  28956. defer resp.Body.Close()
  28957. body, ioErr := ioutil.ReadAll(resp.Body)
  28958. if ioErr != nil {
  28959. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28961. return
  28962. }
  28963. var respJSON map[string]interface{}
  28964. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28965. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28967. return
  28968. }
  28969. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28970. userJSONBytes, _ := json.Marshal(respJSON)
  28971. fmt.Println("log")
  28972. fmt.Println(string(userJSONBytes))
  28973. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28974. utils.ErrorLog("解析失败:%v", err)
  28975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28976. return
  28977. }
  28978. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28979. bytesData, _ := json.Marshal(data)
  28980. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  28981. resp, _ := client.Do(req)
  28982. defer resp.Body.Close()
  28983. body, ioErr := ioutil.ReadAll(resp.Body)
  28984. if ioErr != nil {
  28985. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28987. return
  28988. }
  28989. var respJSON map[string]interface{}
  28990. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28991. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28993. return
  28994. }
  28995. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28996. userJSONBytes, _ := json.Marshal(respJSON)
  28997. fmt.Println("log")
  28998. fmt.Println(string(userJSONBytes))
  28999. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29000. utils.ErrorLog("解析失败:%v", err)
  29001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29002. return
  29003. }
  29004. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29005. bytesData, _ := json.Marshal(data)
  29006. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  29007. resp, _ := client.Do(req)
  29008. defer resp.Body.Close()
  29009. body, ioErr := ioutil.ReadAll(resp.Body)
  29010. if ioErr != nil {
  29011. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29013. return
  29014. }
  29015. var respJSON map[string]interface{}
  29016. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29017. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29019. return
  29020. }
  29021. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29022. userJSONBytes, _ := json.Marshal(respJSON)
  29023. fmt.Println("log")
  29024. fmt.Println(string(userJSONBytes))
  29025. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29026. utils.ErrorLog("解析失败:%v", err)
  29027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29028. return
  29029. }
  29030. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29031. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29032. if result3101.Infcode == "0" {
  29033. if len(result3101.Output.Result) > 0 {
  29034. var errMsgs []string
  29035. for _, item := range result3101.Output.Result {
  29036. errMsgs = append(errMsgs, item.VolaCont)
  29037. }
  29038. c.ServeSuccessJSON(map[string]interface{}{
  29039. "failed_code": -10,
  29040. "msg": errMsgs,
  29041. })
  29042. return
  29043. } else {
  29044. if miConfig.MdtrtareaAdmvs == "320921" {
  29045. data["doctor_id"] = "D320923012139"
  29046. } else {
  29047. data["doctor_id"] = "D371621008686"
  29048. }
  29049. bytesData, _ := json.Marshal(data)
  29050. var req *http.Request
  29051. if miConfig.MdtrtareaAdmvs == "320921" {
  29052. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29053. } else {
  29054. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29055. }
  29056. resp, _ := client.Do(req)
  29057. defer resp.Body.Close()
  29058. body, ioErr := ioutil.ReadAll(resp.Body)
  29059. if ioErr != nil {
  29060. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29062. return
  29063. }
  29064. var respJSON map[string]interface{}
  29065. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29066. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29068. return
  29069. }
  29070. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29071. userJSONBytes, _ := json.Marshal(respJSON)
  29072. fmt.Println("log")
  29073. fmt.Println(string(userJSONBytes))
  29074. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29075. utils.ErrorLog("解析失败:%v", err)
  29076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29077. return
  29078. }
  29079. res.InfRefmsgid = resFour10265.InfRefmsgid
  29080. res.Output = resFour10265.Output
  29081. res.ErrMsg = resFour10265.ErrMsg
  29082. res.Cainfo = resFour10265.Cainfo
  29083. res.WarnMsg = resFour10265.WarnMsg
  29084. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29085. res.Infcode = infocode
  29086. }
  29087. }
  29088. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29089. var pagesize int = 5
  29090. var start int = 1
  29091. var stop int
  29092. var pagecount int
  29093. var curpage int
  29094. data["doctor_id"] = doctor_info.DoctorNumber
  29095. var res2 ResultFour
  29096. //var result res.
  29097. //总页数,向上取整,注意除之前要先转换类型为float64
  29098. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  29099. for curpage = 1; curpage <= pagecount; curpage++ {
  29100. if curpage == 1 {
  29101. start = 1
  29102. } else {
  29103. start = (curpage-1)*pagesize + 1
  29104. }
  29105. stop = curpage * pagesize
  29106. if stop > len(prescriptions) {
  29107. stop = len(prescriptions)
  29108. }
  29109. //var requestLog string
  29110. data["pre"] = prescriptions[start-1 : stop]
  29111. fmt.Println(data["pre"])
  29112. bytesData, _ := json.Marshal(data)
  29113. var req *http.Request
  29114. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  29115. resp, _ := client.Do(req)
  29116. defer resp.Body.Close()
  29117. body, ioErr := ioutil.ReadAll(resp.Body)
  29118. if ioErr != nil {
  29119. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29121. return
  29122. }
  29123. var respJSON map[string]interface{}
  29124. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29125. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29127. return
  29128. }
  29129. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29130. userJSONBytes, _ := json.Marshal(respJSON)
  29131. fmt.Println("log")
  29132. fmt.Println(string(userJSONBytes))
  29133. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29134. utils.ErrorLog("解析失败:%v", err)
  29135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29136. return
  29137. }
  29138. res.InfRefmsgid = resFour10265.InfRefmsgid
  29139. res.Output = resFour10265.Output
  29140. res.ErrMsg = resFour10265.ErrMsg
  29141. res.Cainfo = resFour10265.Cainfo
  29142. res.WarnMsg = resFour10265.WarnMsg
  29143. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29144. res.Infcode = infocode
  29145. if infocode == 0 {
  29146. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  29147. } else {
  29148. isSuccess = false
  29149. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  29150. res.Infcode = -1
  29151. res.ErrMsg = resFour10265.ErrMsg
  29152. errlog := &models.HisOrderError{
  29153. UserOrgId: adminUser.CurrentOrgId,
  29154. Ctime: time.Now().Unix(),
  29155. Mtime: time.Now().Unix(),
  29156. Number: chrg_bchno,
  29157. ErrMsg: "",
  29158. Status: 1,
  29159. PatientId: id,
  29160. RecordTime: recordDateTime,
  29161. Stage: 4,
  29162. }
  29163. service.CreateErrMsgLog(errlog)
  29164. }
  29165. }
  29166. if isSuccess {
  29167. res.Infcode = 0
  29168. res.Output.Result = res2.Output.Result
  29169. } else {
  29170. order := &models.HisOrder{
  29171. UserOrgId: adminUser.CurrentOrgId,
  29172. HisPatientId: his.ID,
  29173. PatientId: his.PatientId,
  29174. SettleAccountsDate: recordDateTime,
  29175. Ctime: time.Now().Unix(),
  29176. Mtime: time.Now().Unix(),
  29177. MdtrtId: his.Number,
  29178. PsnNo: his.PsnNo,
  29179. MedType: strconv.FormatInt(reg_type, 10),
  29180. Status: 1,
  29181. Number: chrg_bchno,
  29182. Infcode: res.Infcode,
  29183. WarnMsg: res.WarnMsg,
  29184. Cainfo: res.Cainfo,
  29185. ErrMsg: res.ErrMsg,
  29186. RespondTime: res.RefmsgTime,
  29187. InfRefmsgid: res.InfRefmsgid,
  29188. OrderStatus: 1,
  29189. IsMedicineInsurance: 1,
  29190. SettleType: settle_accounts_type,
  29191. SettleStartTime: start_time,
  29192. SettleEndTime: end_time,
  29193. Creator: roles.AdminUserId,
  29194. Modify: roles.AdminUserId,
  29195. PType: 2,
  29196. Diagnosis: diagnosis_id,
  29197. }
  29198. err = service.CreateOrder(order)
  29199. if err != nil {
  29200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29201. return
  29202. }
  29203. c.ServeSuccessJSON(map[string]interface{}{
  29204. "failed_code": -10,
  29205. "msg": res2.ErrMsg,
  29206. })
  29207. return
  29208. }
  29209. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29210. 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)
  29211. var dat map[string]interface{}
  29212. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29213. fmt.Println(dat)
  29214. } else {
  29215. fmt.Println(err)
  29216. }
  29217. saveLog(result, request_log, "2204", "上传费用明细")
  29218. userJSONBytes, _ := json.Marshal(dat)
  29219. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29220. utils.ErrorLog("解析失败:%v", err)
  29221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29222. return
  29223. }
  29224. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29225. 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, "", "")
  29226. var dat map[string]interface{}
  29227. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29228. fmt.Println(dat)
  29229. } else {
  29230. fmt.Println(err)
  29231. }
  29232. saveLog(result, request_log, "2204", "上传费用明细")
  29233. userJSONBytes, _ := json.Marshal(dat)
  29234. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29235. utils.ErrorLog("解析失败:%v", err)
  29236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29237. return
  29238. }
  29239. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29240. 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, "", "")
  29241. var dat map[string]interface{}
  29242. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29243. fmt.Println(dat)
  29244. } else {
  29245. fmt.Println(err)
  29246. }
  29247. saveLog(result, request_log, "2204", "上传费用明细")
  29248. userJSONBytes, _ := json.Marshal(dat)
  29249. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29250. utils.ErrorLog("解析失败:%v", err)
  29251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29252. return
  29253. }
  29254. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29255. bytesData, _ := json.Marshal(data)
  29256. var req *http.Request
  29257. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29258. resp, _ := client.Do(req)
  29259. defer resp.Body.Close()
  29260. body, ioErr := ioutil.ReadAll(resp.Body)
  29261. if ioErr != nil {
  29262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29264. return
  29265. }
  29266. var respJSON map[string]interface{}
  29267. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29270. return
  29271. }
  29272. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29273. if status == "0" {
  29274. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29275. c.ServeSuccessJSON(map[string]interface{}{
  29276. "failed_code": -10,
  29277. "msg": err_msg,
  29278. })
  29279. return
  29280. }
  29281. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29282. userJSONBytes, _ := json.Marshal(respJSON)
  29283. fmt.Println("log")
  29284. fmt.Println(string(userJSONBytes))
  29285. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29286. utils.ErrorLog("解析失败:%v", err)
  29287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29288. return
  29289. }
  29290. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29291. bytesData, _ := json.Marshal(data)
  29292. var req *http.Request
  29293. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  29294. resp, _ := client.Do(req)
  29295. defer resp.Body.Close()
  29296. body, ioErr := ioutil.ReadAll(resp.Body)
  29297. if ioErr != nil {
  29298. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29300. return
  29301. }
  29302. var respJSON map[string]interface{}
  29303. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29304. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29306. return
  29307. }
  29308. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29309. if status == "0" {
  29310. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29311. c.ServeSuccessJSON(map[string]interface{}{
  29312. "failed_code": -10,
  29313. "msg": err_msg,
  29314. })
  29315. return
  29316. }
  29317. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29318. userJSONBytes, _ := json.Marshal(respJSON)
  29319. fmt.Println("log")
  29320. fmt.Println(string(userJSONBytes))
  29321. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29322. utils.ErrorLog("解析失败:%v", err)
  29323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29324. return
  29325. }
  29326. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29327. 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, "", "")
  29328. var dat map[string]interface{}
  29329. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29330. fmt.Println(dat)
  29331. } else {
  29332. fmt.Println(err)
  29333. }
  29334. saveLog(result, request_log, "2204", "上传费用明细")
  29335. userJSONBytes, _ := json.Marshal(dat)
  29336. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29337. utils.ErrorLog("解析失败:%v", err)
  29338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29339. return
  29340. }
  29341. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29342. bytesData, _ := json.Marshal(data)
  29343. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  29344. resp, _ := client.Do(req)
  29345. defer resp.Body.Close()
  29346. body, ioErr := ioutil.ReadAll(resp.Body)
  29347. if ioErr != nil {
  29348. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29350. return
  29351. }
  29352. var respJSON map[string]interface{}
  29353. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29354. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29356. return
  29357. }
  29358. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29359. userJSONBytes, _ := json.Marshal(respJSON)
  29360. fmt.Println("log")
  29361. fmt.Println(string(userJSONBytes))
  29362. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29363. utils.ErrorLog("解析失败:%v", err)
  29364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29365. return
  29366. }
  29367. } else {
  29368. if miConfig.MdtrtareaAdmvs == "441202" {
  29369. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29370. if result3101.Infcode == 0 {
  29371. if len(result3101.Output.Result) > 0 {
  29372. var errMsgs []string
  29373. for _, item := range result3101.Output.Result {
  29374. errMsgs = append(errMsgs, item.VolaCont)
  29375. }
  29376. c.ServeSuccessJSON(map[string]interface{}{
  29377. "failed_code": -10,
  29378. "msg": errMsgs,
  29379. })
  29380. return
  29381. } else {
  29382. 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)
  29383. var dat map[string]interface{}
  29384. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29385. fmt.Println(dat)
  29386. } else {
  29387. fmt.Println(err)
  29388. }
  29389. saveLog(result, request_log, "2204", "上传费用明细")
  29390. userJSONBytes, _ := json.Marshal(dat)
  29391. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29392. utils.ErrorLog("解析失败:%v", err)
  29393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29394. return
  29395. }
  29396. }
  29397. } else {
  29398. c.ServeSuccessJSON(map[string]interface{}{
  29399. "failed_code": -10,
  29400. "msg": result3101.ErrMsg,
  29401. })
  29402. return
  29403. }
  29404. } else if miConfig.MdtrtareaAdmvs == "440205" {
  29405. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29406. if result3101.Infcode == 0 {
  29407. if len(result3101.Output.Result) > 0 {
  29408. var errMsgs []string
  29409. for _, item := range result3101.Output.Result {
  29410. errMsgs = append(errMsgs, item.VolaCont)
  29411. }
  29412. c.ServeSuccessJSON(map[string]interface{}{
  29413. "failed_code": -10,
  29414. "msg": errMsgs,
  29415. })
  29416. return
  29417. } else {
  29418. 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)
  29419. var dat map[string]interface{}
  29420. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29421. fmt.Println(dat)
  29422. } else {
  29423. fmt.Println(err)
  29424. }
  29425. saveLog(result, request_log, "2204", "上传费用明细")
  29426. userJSONBytes, _ := json.Marshal(dat)
  29427. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29428. utils.ErrorLog("解析失败:%v", err)
  29429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29430. return
  29431. }
  29432. }
  29433. } else {
  29434. c.ServeSuccessJSON(map[string]interface{}{
  29435. "failed_code": -10,
  29436. "msg": result3101.ErrMsg,
  29437. })
  29438. return
  29439. }
  29440. } else {
  29441. if miConfig.Code == "H15049901371" {
  29442. 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)
  29443. var dat map[string]interface{}
  29444. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29445. fmt.Println(dat)
  29446. } else {
  29447. fmt.Println(err)
  29448. }
  29449. saveLog(result, request_log, "2204", "上传费用明细")
  29450. userJSONBytes, _ := json.Marshal(dat)
  29451. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  29452. utils.ErrorLog("解析失败:%v", err)
  29453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29454. return
  29455. }
  29456. res.InfRefmsgid = resFour10265.InfRefmsgid
  29457. res.Output = resFour10265.Output
  29458. res.ErrMsg = resFour10265.ErrMsg
  29459. res.Cainfo = resFour10265.Cainfo
  29460. res.WarnMsg = resFour10265.WarnMsg
  29461. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  29462. res.Infcode = infocode
  29463. } else {
  29464. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" {
  29465. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  29466. if result3101.Infcode == 0 {
  29467. if len(result3101.Output.Result) > 0 {
  29468. var errMsgs []string
  29469. for _, item := range result3101.Output.Result {
  29470. errMsgs = append(errMsgs, item.VolaCont)
  29471. }
  29472. c.ServeSuccessJSON(map[string]interface{}{
  29473. "failed_code": -10,
  29474. "msg": errMsgs,
  29475. })
  29476. return
  29477. } else {
  29478. 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)
  29479. var dat map[string]interface{}
  29480. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29481. fmt.Println(dat)
  29482. } else {
  29483. fmt.Println(err)
  29484. }
  29485. saveLog(result, request_log, "2204", "上传费用明细")
  29486. userJSONBytes, _ := json.Marshal(dat)
  29487. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29488. utils.ErrorLog("解析失败:%v", err)
  29489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29490. return
  29491. }
  29492. }
  29493. } else {
  29494. c.ServeSuccessJSON(map[string]interface{}{
  29495. "failed_code": -10,
  29496. "msg": result3101.ErrMsg,
  29497. })
  29498. return
  29499. }
  29500. } else {
  29501. 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)
  29502. var dat map[string]interface{}
  29503. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29504. fmt.Println(dat)
  29505. } else {
  29506. fmt.Println(err)
  29507. }
  29508. saveLog(result, request_log, "2204", "上传费用明细")
  29509. userJSONBytes, _ := json.Marshal(dat)
  29510. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29511. utils.ErrorLog("解析失败:%v", err)
  29512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29513. return
  29514. }
  29515. }
  29516. }
  29517. }
  29518. }
  29519. var total_two float64
  29520. if res.Infcode == -1 {
  29521. errlog := &models.HisOrderError{
  29522. UserOrgId: adminUser.CurrentOrgId,
  29523. Ctime: time.Now().Unix(),
  29524. Mtime: time.Now().Unix(),
  29525. Number: chrg_bchno,
  29526. ErrMsg: res.ErrMsg,
  29527. Status: 1,
  29528. PatientId: id,
  29529. RecordTime: recordDateTime,
  29530. Stage: 4,
  29531. }
  29532. service.CreateErrMsgLog(errlog)
  29533. c.ServeSuccessJSON(map[string]interface{}{
  29534. "failed_code": -10,
  29535. "msg": res.ErrMsg,
  29536. })
  29537. return
  29538. }
  29539. if res.Infcode == 0 {
  29540. order := &models.HisOrder{
  29541. UserOrgId: adminUser.CurrentOrgId,
  29542. HisPatientId: his.ID,
  29543. PatientId: his.PatientId,
  29544. SettleAccountsDate: recordDateTime,
  29545. Ctime: time.Now().Unix(),
  29546. Mtime: time.Now().Unix(),
  29547. MdtrtId: his.Number,
  29548. PsnNo: his.PsnNo,
  29549. MedType: strconv.FormatInt(reg_type, 10),
  29550. Status: 1,
  29551. Number: chrg_bchno,
  29552. Infcode: res.Infcode,
  29553. WarnMsg: res.WarnMsg,
  29554. Cainfo: res.Cainfo,
  29555. ErrMsg: res.ErrMsg,
  29556. RespondTime: res.RefmsgTime,
  29557. InfRefmsgid: res.InfRefmsgid,
  29558. OrderStatus: 1,
  29559. IsMedicineInsurance: 1,
  29560. SettleType: settle_accounts_type,
  29561. SettleStartTime: start_time,
  29562. SettleEndTime: end_time,
  29563. Creator: roles.AdminUserId,
  29564. Modify: roles.AdminUserId,
  29565. PType: 2,
  29566. Diagnosis: diagnosis_id,
  29567. }
  29568. err = service.CreateOrder(order)
  29569. if err != nil {
  29570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  29571. return
  29572. }
  29573. for _, item := range res.Output.Result {
  29574. temp := strings.Split(item.FeedetlSn, "-")
  29575. var advice_id int64 = 0
  29576. var project_id int64 = 0
  29577. var types int64 = 0
  29578. id, _ := strconv.ParseInt(temp[2], 10, 64)
  29579. types, _ = strconv.ParseInt(temp[1], 10, 64)
  29580. if temp[1] == "1" {
  29581. advice_id = id
  29582. project_id = 0
  29583. } else if temp[1] == "2" {
  29584. advice_id = 0
  29585. project_id = id
  29586. }
  29587. total_two = total_two + item.DetItemFeeSumamt
  29588. info := &models.HisOrderInfo{
  29589. OrderNumber: order.Number,
  29590. FeedetlSn: item.FeedetlSn,
  29591. UploadDate: time.Now().Unix(),
  29592. AdviceId: advice_id,
  29593. DetItemFeeSumamt: item.DetItemFeeSumamt,
  29594. Cnt: item.Cnt,
  29595. Pric: float64(item.Pric),
  29596. PatientId: his.PatientId,
  29597. PricUplmtAmt: item.PricUplmtAmt,
  29598. SelfpayProp: item.SelfpayProp,
  29599. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  29600. OverlmtAmt: item.OverlmtAmt,
  29601. PreselfpayAmt: item.PreselfpayAmt,
  29602. BasMednFlag: item.BasMednFlag,
  29603. MedChrgitmType: item.MedChrgitmType,
  29604. HiNegoDrugFlag: item.HiNegoDrugFlag,
  29605. Status: 1,
  29606. Memo: item.Memo,
  29607. Mtime: time.Now().Unix(),
  29608. InscpScpAmt: item.InscpScpAmt,
  29609. DrtReimFlag: item.DrtReimFlag,
  29610. Ctime: time.Now().Unix(),
  29611. ListSpItemFlag: item.ListSpItemFlag,
  29612. ChldMedcFlag: item.ChldMedcFlag,
  29613. LmtUsedFlag: item.LmtUsedFlag,
  29614. ChrgitmLv: item.ChrgitmLv,
  29615. UserOrgId: adminUser.CurrentOrgId,
  29616. HisPatientId: his.ID,
  29617. OrderId: order.ID,
  29618. ProjectId: project_id,
  29619. Type: types,
  29620. }
  29621. service.CreateOrderInfo(info)
  29622. }
  29623. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  29624. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  29625. var total float64
  29626. for _, item := range prescriptions {
  29627. if item.Type == 1 { //药品
  29628. for _, subItem := range item.HisDoctorAdviceInfo {
  29629. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29630. total_one := price * subItem.PrescribingNumber
  29631. fmt.Println("subItem")
  29632. fmt.Println(subItem.Price)
  29633. fmt.Println("price")
  29634. fmt.Println(price)
  29635. fmt.Println("total_one")
  29636. fmt.Println(total_one)
  29637. total = total + total_one
  29638. fmt.Println(total)
  29639. }
  29640. }
  29641. if item.Type == 2 { //项目
  29642. for _, subItem := range item.HisPrescriptionProject {
  29643. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  29644. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  29645. total_one := price * cnt
  29646. total = total + total_one
  29647. }
  29648. }
  29649. }
  29650. allTotal := fmt.Sprintf("%.2f", total)
  29651. if res.Infcode == 0 {
  29652. var rf []*ResultFive
  29653. json.Unmarshal([]byte(his.Iinfo), &rf)
  29654. chrg_bchno := chrg_bchno
  29655. cert_no := his.Certno
  29656. var insutypes []string
  29657. var insutype string
  29658. var is390 int = 0
  29659. var is310 int = 0
  29660. for _, item := range rf {
  29661. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  29662. insutypes = append(insutypes, item.Insutype)
  29663. }
  29664. }
  29665. if len(insutypes) == 1 {
  29666. insutype = insutypes[0]
  29667. } else {
  29668. for _, i := range insutypes {
  29669. if i == "390" {
  29670. is390 = 1
  29671. }
  29672. if i == "310" {
  29673. is310 = 1
  29674. }
  29675. }
  29676. }
  29677. if is390 == 1 {
  29678. insutype = "390"
  29679. }
  29680. if is310 == 1 {
  29681. insutype = "310"
  29682. }
  29683. if len(insutypes) == 0 {
  29684. insutype = "390"
  29685. }
  29686. if len(insutypes) == 2 {
  29687. insutype = strconv.FormatInt(his.SocialType, 10)
  29688. }
  29689. //insutype = "390"
  29690. if his.IdCardType == 1 {
  29691. cert_no = his.MedicalInsuranceNumber
  29692. } else {
  29693. cert_no = his.Certno
  29694. }
  29695. var res ResultSeven
  29696. var ahres ResultSevenAH
  29697. var resSeven10265 ResultSeven10265
  29698. var resSeven10265Two ResultSeven10265Two
  29699. var gzresSeven10265Two GZResultSeven10265Two
  29700. if miConfig.MdtrtareaAdmvs == "421300" {
  29701. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  29702. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29703. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29704. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29705. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29706. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29707. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29708. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29709. resp, requestErr := http.Get(api)
  29710. if requestErr != nil {
  29711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29712. return
  29713. }
  29714. body, ioErr := ioutil.ReadAll(resp.Body)
  29715. if ioErr != nil {
  29716. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29718. return
  29719. }
  29720. var respJSON map[string]interface{}
  29721. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29722. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29724. return
  29725. }
  29726. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29727. result, _ := json.Marshal(respJSON)
  29728. fmt.Println("log")
  29729. fmt.Println(string(result))
  29730. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29731. utils.ErrorLog("解析失败:%v", err)
  29732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29733. return
  29734. }
  29735. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29736. if reg_type == 11 && his.Insutype == "390" {
  29737. reg_type = 110104
  29738. }
  29739. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29740. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29741. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29742. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29743. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29744. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29745. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29746. resp, requestErr := http.Get(api)
  29747. if requestErr != nil {
  29748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29749. return
  29750. }
  29751. body, ioErr := ioutil.ReadAll(resp.Body)
  29752. if ioErr != nil {
  29753. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29755. return
  29756. }
  29757. var respJSON map[string]interface{}
  29758. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29761. return
  29762. }
  29763. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29764. result, _ := json.Marshal(respJSON)
  29765. fmt.Println("log")
  29766. fmt.Println(string(result))
  29767. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29768. utils.ErrorLog("解析失败:%v", err)
  29769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29770. return
  29771. }
  29772. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29773. if reg_type == 11 && his.Insutype == "390" {
  29774. reg_type = 110104
  29775. }
  29776. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29777. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29778. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29779. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29780. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29781. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29782. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29783. resp, requestErr := http.Get(api)
  29784. if requestErr != nil {
  29785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29786. return
  29787. }
  29788. body, ioErr := ioutil.ReadAll(resp.Body)
  29789. if ioErr != nil {
  29790. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29792. return
  29793. }
  29794. var respJSON map[string]interface{}
  29795. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29798. return
  29799. }
  29800. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29801. result, _ := json.Marshal(respJSON)
  29802. fmt.Println("log")
  29803. fmt.Println(string(result))
  29804. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29805. utils.ErrorLog("解析失败:%v", err)
  29806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29807. return
  29808. }
  29809. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29810. if reg_type == 11 && his.Insutype == "390" {
  29811. reg_type = 110104
  29812. }
  29813. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29814. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29815. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29816. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29817. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29818. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29819. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  29820. resp, requestErr := http.Get(api)
  29821. if requestErr != nil {
  29822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29823. return
  29824. }
  29825. body, ioErr := ioutil.ReadAll(resp.Body)
  29826. if ioErr != nil {
  29827. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29829. return
  29830. }
  29831. var respJSON map[string]interface{}
  29832. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29835. return
  29836. }
  29837. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29838. result, _ := json.Marshal(respJSON)
  29839. fmt.Println("log")
  29840. fmt.Println(string(result))
  29841. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29842. utils.ErrorLog("解析失败:%v", err)
  29843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29844. return
  29845. }
  29846. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29847. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  29848. if result3101.Infcode == "0" {
  29849. if len(result3101.Output.Result) > 0 {
  29850. var errMsgs []string
  29851. for _, item := range result3101.Output.Result {
  29852. errMsgs = append(errMsgs, item.VolaCont)
  29853. }
  29854. c.ServeSuccessJSON(map[string]interface{}{
  29855. "failed_code": -10,
  29856. "msg": errMsgs,
  29857. })
  29858. return
  29859. } else {
  29860. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29861. if his.IdCardType != 4 {
  29862. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29863. bas := strings.Split(psn_info.CardInfo, "|")
  29864. if his.IdCardType == 1 {
  29865. cert_no = bas[2]
  29866. } else {
  29867. cert_no = bas[1]
  29868. }
  29869. } else {
  29870. cert_no = his.Certno
  29871. }
  29872. //江苏地区国家医保医疗类别
  29873. //职工透析:医疗类别选特殊情况门诊9933
  29874. //居民血透门慢: 医疗类别选门诊慢病1402
  29875. //var med_type string
  29876. //if his.Insutype == "310" {
  29877. // if reg_type == 14 {
  29878. // med_type = "9933"
  29879. // } else if reg_type == 11 {
  29880. // med_type = "11"
  29881. //
  29882. // }
  29883. //} else if his.Insutype == "390" {
  29884. // if reg_type == 14 {
  29885. // med_type = "1402"
  29886. // } else if reg_type == 11 {
  29887. // med_type = "11"
  29888. // }
  29889. //}
  29890. var api string
  29891. if miConfig.MdtrtareaAdmvs == "320921" {
  29892. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29893. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29894. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29895. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29896. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29897. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29898. "&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
  29899. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29900. } else {
  29901. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29902. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29903. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29904. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29905. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29906. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29907. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29908. "&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
  29909. }
  29910. resp, requestErr := http.Get(api)
  29911. if requestErr != nil {
  29912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29913. return
  29914. }
  29915. body, ioErr := ioutil.ReadAll(resp.Body)
  29916. if ioErr != nil {
  29917. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29919. return
  29920. }
  29921. var respJSON map[string]interface{}
  29922. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29923. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29925. return
  29926. }
  29927. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29928. result, _ := json.Marshal(respJSON)
  29929. fmt.Println("log")
  29930. fmt.Println(string(result))
  29931. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  29932. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  29933. utils.ErrorLog("解析失败:%v", err)
  29934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29935. return
  29936. }
  29937. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29938. res.Output = resSeven10265.Output
  29939. res.ErrMsg = resSeven10265.ErrMsg
  29940. res.Cainfo = resSeven10265.Cainfo
  29941. res.WarnMsg = resSeven10265.WarnMsg
  29942. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29943. res.Infcode = infocode
  29944. } else {
  29945. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  29946. utils.ErrorLog("解析失败:%v", err)
  29947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29948. return
  29949. }
  29950. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  29951. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  29952. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  29953. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  29954. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  29955. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  29956. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  29957. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  29958. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  29959. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  29960. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  29961. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  29962. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  29963. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  29964. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  29965. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  29966. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  29967. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  29968. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  29969. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  29970. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  29971. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29972. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  29973. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  29974. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  29975. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  29976. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  29977. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  29978. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  29979. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  29980. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  29981. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  29982. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  29983. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  29984. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  29985. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29986. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  29987. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  29988. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  29989. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  29990. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  29991. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  29992. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  29993. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  29994. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  29995. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  29996. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  29997. res.ErrMsg = resSeven10265Two.ErrMsg
  29998. res.Cainfo = resSeven10265Two.Cainfo
  29999. res.WarnMsg = resSeven10265Two.WarnMsg
  30000. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  30001. res.Infcode = infocode
  30002. }
  30003. }
  30004. }
  30005. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30006. psn_info, _ := service.GetPsnByPatientId(id)
  30007. var verify_number string
  30008. if psn_info.IdCardType == 4 {
  30009. verify_number = psn_info.VerifyNumber
  30010. } else if psn_info.IdCardType == 1 {
  30011. bas := strings.Split(psn_info.CardInfo, "|")
  30012. cardNumber := bas[2]
  30013. verify_number = cardNumber
  30014. } else {
  30015. psn_info.IdCardType = 2
  30016. verify_number = psn_info.Certno
  30017. }
  30018. var api string
  30019. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30020. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  30021. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30022. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30023. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  30024. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30025. "&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
  30026. resp, requestErr := http.Get(api)
  30027. if requestErr != nil {
  30028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30029. return
  30030. }
  30031. body, ioErr := ioutil.ReadAll(resp.Body)
  30032. if ioErr != nil {
  30033. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30035. return
  30036. }
  30037. var respJSON map[string]interface{}
  30038. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30039. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30041. return
  30042. }
  30043. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30044. result, _ := json.Marshal(respJSON)
  30045. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  30046. utils.ErrorLog("解析失败:%v", err)
  30047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30048. return
  30049. }
  30050. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30051. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  30052. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  30053. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  30054. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  30055. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  30056. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  30057. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  30058. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  30059. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  30060. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  30061. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  30062. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  30063. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  30064. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  30065. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  30066. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  30067. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  30068. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  30069. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  30070. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30071. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  30072. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  30073. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  30074. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  30075. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  30076. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  30077. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  30078. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  30079. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  30080. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  30081. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  30082. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  30083. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  30084. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30085. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  30086. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  30087. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  30088. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  30089. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  30090. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  30091. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  30092. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  30093. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  30094. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  30095. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  30096. res.ErrMsg = resSeven10265.ErrMsg
  30097. res.Cainfo = resSeven10265.Cainfo
  30098. res.WarnMsg = resSeven10265.WarnMsg
  30099. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30100. res.Infcode = infocode
  30101. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30102. acct_used_flag := "1"
  30103. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  30104. var result string
  30105. var request_log string
  30106. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  30107. 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)
  30108. } else {
  30109. 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)
  30110. }
  30111. var dat map[string]interface{}
  30112. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30113. fmt.Println(dat)
  30114. } else {
  30115. fmt.Println(err)
  30116. }
  30117. saveLog(result, request_log, "2206", "预结算")
  30118. userJSONBytes, _ := json.Marshal(dat)
  30119. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30120. utils.ErrorLog("解析失败:%v", err)
  30121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30122. return
  30123. }
  30124. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30125. var result string
  30126. var request_log string
  30127. if his.IdCardType == 2 {
  30128. insutype = strconv.FormatInt(his.SocialType, 10)
  30129. 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, "")
  30130. } else if his.IdCardType == 1 {
  30131. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30132. bas := strings.Split(psn_info.CardInfo, "|")
  30133. basNumber := bas[2]
  30134. card_sn := bas[3]
  30135. var rf []*ResultFive
  30136. json.Unmarshal([]byte(his.Iinfo), &rf)
  30137. var psn_type string
  30138. for _, item := range rf {
  30139. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30140. psn_type = item.PsnType
  30141. }
  30142. }
  30143. insutype = strconv.FormatInt(his.SocialType, 10)
  30144. 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)
  30145. } else {
  30146. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30147. //bas := strings.Split(psn_info.CardInfo, "|")
  30148. //basNumber := bas[2]
  30149. //card_sn := bas[3]
  30150. var rf []*ResultFive
  30151. json.Unmarshal([]byte(his.Iinfo), &rf)
  30152. var psn_type string
  30153. for _, item := range rf {
  30154. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30155. psn_type = item.PsnType
  30156. }
  30157. }
  30158. insutype = strconv.FormatInt(his.SocialType, 10)
  30159. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30160. 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)
  30161. }
  30162. var dat map[string]interface{}
  30163. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30164. fmt.Println(dat)
  30165. } else {
  30166. fmt.Println(err)
  30167. }
  30168. saveLog(result, request_log, "2206", "预结算")
  30169. userJSONBytes, _ := json.Marshal(dat)
  30170. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30171. utils.ErrorLog("解析失败:%v", err)
  30172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30173. return
  30174. }
  30175. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30176. var result string
  30177. var request_log string
  30178. if his.IdCardType == 2 {
  30179. insutype = strconv.FormatInt(his.SocialType, 10)
  30180. 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, "")
  30181. } else if his.IdCardType == 1 {
  30182. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30183. bas := strings.Split(psn_info.CardInfo, "|")
  30184. basNumber := bas[0]
  30185. card_sn := ""
  30186. var rf []*ResultFive
  30187. json.Unmarshal([]byte(his.Iinfo), &rf)
  30188. var psn_type string
  30189. for _, item := range rf {
  30190. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30191. psn_type = item.PsnType
  30192. }
  30193. }
  30194. insutype = strconv.FormatInt(his.SocialType, 10)
  30195. 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)
  30196. } else {
  30197. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30198. //bas := strings.Split(psn_info.CardInfo, "|")
  30199. //basNumber := bas[2]
  30200. //card_sn := bas[3]
  30201. var rf []*ResultFive
  30202. json.Unmarshal([]byte(his.Iinfo), &rf)
  30203. var psn_type string
  30204. for _, item := range rf {
  30205. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  30206. psn_type = item.PsnType
  30207. }
  30208. }
  30209. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30210. 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)
  30211. }
  30212. var dat map[string]interface{}
  30213. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30214. fmt.Println(dat)
  30215. } else {
  30216. fmt.Println(err)
  30217. }
  30218. saveLog(result, request_log, "2206", "预结算")
  30219. userJSONBytes, _ := json.Marshal(dat)
  30220. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30221. utils.ErrorLog("解析失败:%v", err)
  30222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30223. return
  30224. }
  30225. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30226. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30227. if his.IdCardType == 4 {
  30228. psn_info.VerifyNumber = psn_info.VerifyNumber
  30229. cert_no = psn_info.VerifyNumber
  30230. } else if his.IdCardType == 2 {
  30231. cert_no = psn_info.Certno
  30232. psn_info.VerifyNumber = psn_info.Certno
  30233. } else {
  30234. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30235. bas := strings.Split(psn_info.CardInfo, "|")
  30236. if his.IdCardType == 1 {
  30237. cert_no = bas[2]
  30238. } else {
  30239. cert_no = bas[1]
  30240. }
  30241. }
  30242. var api string
  30243. var med_type string
  30244. if his.Insutype == "390" {
  30245. if reg_type == 992102 {
  30246. med_type = "992102"
  30247. }
  30248. if reg_type == 140104 {
  30249. med_type = "140104"
  30250. }
  30251. if reg_type == 140201 {
  30252. med_type = "140201"
  30253. }
  30254. if reg_type == 14 {
  30255. med_type = "140104"
  30256. }
  30257. } else if his.Insutype == "310" {
  30258. if reg_type == 992102 {
  30259. med_type = "992102"
  30260. }
  30261. if reg_type == 140104 {
  30262. med_type = "140104"
  30263. }
  30264. if reg_type == 140201 {
  30265. med_type = "140201"
  30266. }
  30267. if reg_type == 14 {
  30268. med_type = "140104"
  30269. }
  30270. }
  30271. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30272. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30273. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30274. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30275. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30276. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30277. "&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
  30278. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30279. resp, requestErr := http.Get(api)
  30280. if requestErr != nil {
  30281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30282. return
  30283. }
  30284. body, ioErr := ioutil.ReadAll(resp.Body)
  30285. if ioErr != nil {
  30286. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30288. return
  30289. }
  30290. var respJSON map[string]interface{}
  30291. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30292. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30294. return
  30295. }
  30296. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30297. if status == "0" {
  30298. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30299. c.ServeSuccessJSON(map[string]interface{}{
  30300. "failed_code": -10,
  30301. "msg": err_msg,
  30302. })
  30303. return
  30304. }
  30305. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30306. result, _ := json.Marshal(respJSON)
  30307. fmt.Println("log")
  30308. fmt.Println(string(result))
  30309. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30310. utils.ErrorLog("解析失败:%v", err)
  30311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30312. return
  30313. }
  30314. res.InfRefmsgid = ahres.InfRefmsgid
  30315. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30316. // 创建对应的Time类型
  30317. t := time.UnixMilli(timestamp)
  30318. // 格式化成指定的日期字符串
  30319. str := t.Format("2006-01-02 15:04:05")
  30320. res.Output.Setlinfo.SetlTime = str
  30321. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30322. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30323. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30324. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30325. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30326. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30327. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30328. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30329. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30330. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30331. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30332. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30333. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30334. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30335. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30336. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30337. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30338. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30339. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30340. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30341. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30342. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30343. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30344. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30345. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30346. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30347. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30348. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30349. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30350. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30351. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30352. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30353. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30354. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30355. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30356. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30357. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30358. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30359. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30360. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30361. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30362. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30363. //res.Output.Setldetail = ahres.Output.Setldetail
  30364. res.ErrMsg = ahres.ErrMsg
  30365. res.Cainfo = ahres.Cainfo
  30366. res.WarnMsg = ahres.WarnMsg
  30367. res.Infcode = ahres.Infcode
  30368. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30369. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30370. if his.IdCardType == 4 {
  30371. psn_info.VerifyNumber = psn_info.VerifyNumber
  30372. cert_no = psn_info.Certno
  30373. } else if his.IdCardType == 2 {
  30374. cert_no = psn_info.Certno
  30375. psn_info.VerifyNumber = psn_info.Certno
  30376. } else {
  30377. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  30378. bas := strings.Split(psn_info.CardInfo, "|")
  30379. if his.IdCardType == 1 {
  30380. cert_no = bas[2]
  30381. } else {
  30382. cert_no = bas[1]
  30383. }
  30384. }
  30385. var api string
  30386. var med_type string
  30387. if his.Insutype == "390" {
  30388. if reg_type == 992102 {
  30389. med_type = "992102"
  30390. }
  30391. if reg_type == 140104 {
  30392. med_type = "140104"
  30393. }
  30394. if reg_type == 140201 {
  30395. med_type = "140201"
  30396. }
  30397. if reg_type == 14 {
  30398. med_type = "14"
  30399. }
  30400. } else if his.Insutype == "310" {
  30401. if reg_type == 992102 {
  30402. med_type = "992102"
  30403. }
  30404. if reg_type == 140104 {
  30405. med_type = "140104"
  30406. }
  30407. if reg_type == 140201 {
  30408. med_type = "140201"
  30409. }
  30410. if reg_type == 14 {
  30411. med_type = "14"
  30412. }
  30413. }
  30414. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30415. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30416. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30417. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30418. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30419. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30420. "&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
  30421. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30422. resp, requestErr := http.Get(api)
  30423. if requestErr != nil {
  30424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30425. return
  30426. }
  30427. body, ioErr := ioutil.ReadAll(resp.Body)
  30428. if ioErr != nil {
  30429. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30431. return
  30432. }
  30433. var respJSON map[string]interface{}
  30434. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30435. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30437. return
  30438. }
  30439. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30440. if status == "0" {
  30441. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30442. c.ServeSuccessJSON(map[string]interface{}{
  30443. "failed_code": -10,
  30444. "msg": err_msg,
  30445. })
  30446. return
  30447. }
  30448. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30449. result, _ := json.Marshal(respJSON)
  30450. fmt.Println("log")
  30451. fmt.Println(string(result))
  30452. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  30453. utils.ErrorLog("解析失败:%v", err)
  30454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30455. return
  30456. }
  30457. res.InfRefmsgid = ahres.InfRefmsgid
  30458. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  30459. // 创建对应的Time类型
  30460. t := time.UnixMilli(timestamp)
  30461. // 格式化成指定的日期字符串
  30462. str := t.Format("2006-01-02 15:04:05")
  30463. res.Output.Setlinfo.SetlTime = str
  30464. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  30465. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  30466. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30467. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  30468. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  30469. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  30470. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30471. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  30472. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  30473. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  30474. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  30475. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  30476. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  30477. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  30478. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  30479. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  30480. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  30481. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  30482. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  30483. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30484. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  30485. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  30486. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  30487. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  30488. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  30489. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  30490. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  30491. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  30492. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  30493. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  30494. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  30495. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  30496. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  30497. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  30498. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  30499. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  30500. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  30501. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  30502. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  30503. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  30504. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  30505. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  30506. //res.Output.Setldetail = ahres.Output.Setldetail
  30507. res.ErrMsg = ahres.ErrMsg
  30508. res.Cainfo = ahres.Cainfo
  30509. res.WarnMsg = ahres.WarnMsg
  30510. res.Infcode = ahres.Infcode
  30511. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30512. var result string
  30513. var request_log string
  30514. if his.IdCardType == 2 {
  30515. 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")
  30516. } else if his.IdCardType == 1 {
  30517. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30518. bas := strings.Split(psn_info.CardInfo, "|")
  30519. basNumber := bas[2]
  30520. card_sn := bas[3]
  30521. 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")
  30522. } else {
  30523. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30524. 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")
  30525. }
  30526. var dat map[string]interface{}
  30527. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30528. fmt.Println(dat)
  30529. } else {
  30530. fmt.Println(err)
  30531. }
  30532. saveLog(result, request_log, "2206", "预结算")
  30533. userJSONBytes, _ := json.Marshal(dat)
  30534. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30535. utils.ErrorLog("解析失败:%v", err)
  30536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30537. return
  30538. }
  30539. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30540. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  30541. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  30542. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  30543. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30544. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  30545. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  30546. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  30547. resp, requestErr := http.Get(api)
  30548. if requestErr != nil {
  30549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30550. return
  30551. }
  30552. body, ioErr := ioutil.ReadAll(resp.Body)
  30553. if ioErr != nil {
  30554. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30556. return
  30557. }
  30558. var respJSON map[string]interface{}
  30559. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30560. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30562. return
  30563. }
  30564. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30565. result, _ := json.Marshal(respJSON)
  30566. fmt.Println("log")
  30567. fmt.Println(string(result))
  30568. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30569. utils.ErrorLog("解析失败:%v", err)
  30570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30571. return
  30572. }
  30573. } else {
  30574. if miConfig.MdtrtareaAdmvs == "441202" {
  30575. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30576. if result3101.Infcode == 0 {
  30577. if len(result3101.Output.Result) > 0 {
  30578. var errMsgs []string
  30579. for _, item := range result3101.Output.Result {
  30580. errMsgs = append(errMsgs, item.VolaCont)
  30581. }
  30582. c.ServeSuccessJSON(map[string]interface{}{
  30583. "failed_code": -10,
  30584. "msg": errMsgs,
  30585. })
  30586. return
  30587. } else {
  30588. var result string
  30589. var request_log string
  30590. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30591. allTotal = fmt.Sprintf("%.2f", total_two)
  30592. if his.IdCardType == 4 {
  30593. 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)
  30594. } else {
  30595. 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)
  30596. }
  30597. var dat map[string]interface{}
  30598. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30599. fmt.Println(dat)
  30600. } else {
  30601. fmt.Println(err)
  30602. }
  30603. saveLog(result, request_log, "2206", "预结算")
  30604. //userJSONBytes, _ := json.Marshal(dat)
  30605. //
  30606. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30607. // utils.ErrorLog("解析失败:%v", err)
  30608. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30609. // return
  30610. //}
  30611. userJSONBytes, _ := json.Marshal(dat)
  30612. if miConfig.Code == "H15049901371" {
  30613. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30614. utils.ErrorLog("解析失败:%v", err)
  30615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30616. return
  30617. }
  30618. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30619. res.Output = resSeven10265.Output
  30620. res.ErrMsg = resSeven10265.ErrMsg
  30621. res.Cainfo = resSeven10265.Cainfo
  30622. res.WarnMsg = resSeven10265.WarnMsg
  30623. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30624. res.Infcode = infocode
  30625. } else {
  30626. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30627. utils.ErrorLog("解析失败:%v", err)
  30628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30629. return
  30630. }
  30631. }
  30632. }
  30633. } else {
  30634. c.ServeSuccessJSON(map[string]interface{}{
  30635. "failed_code": -10,
  30636. "msg": result3101.ErrMsg,
  30637. })
  30638. return
  30639. }
  30640. } else if miConfig.MdtrtareaAdmvs == "440205" {
  30641. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30642. if result3101.Infcode == 0 {
  30643. if len(result3101.Output.Result) > 0 {
  30644. var errMsgs []string
  30645. for _, item := range result3101.Output.Result {
  30646. errMsgs = append(errMsgs, item.VolaCont)
  30647. }
  30648. c.ServeSuccessJSON(map[string]interface{}{
  30649. "failed_code": -10,
  30650. "msg": errMsgs,
  30651. })
  30652. return
  30653. } else {
  30654. var result string
  30655. var request_log string
  30656. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30657. allTotal = fmt.Sprintf("%.2f", total_two)
  30658. if his.IdCardType == 4 {
  30659. 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)
  30660. } else {
  30661. 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)
  30662. }
  30663. var dat map[string]interface{}
  30664. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30665. fmt.Println(dat)
  30666. } else {
  30667. fmt.Println(err)
  30668. }
  30669. saveLog(result, request_log, "2206", "预结算")
  30670. //userJSONBytes, _ := json.Marshal(dat)
  30671. //
  30672. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30673. // utils.ErrorLog("解析失败:%v", err)
  30674. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30675. // return
  30676. //}
  30677. userJSONBytes, _ := json.Marshal(dat)
  30678. if miConfig.Code == "H15049901371" {
  30679. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30680. utils.ErrorLog("解析失败:%v", err)
  30681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30682. return
  30683. }
  30684. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30685. res.Output = resSeven10265.Output
  30686. res.ErrMsg = resSeven10265.ErrMsg
  30687. res.Cainfo = resSeven10265.Cainfo
  30688. res.WarnMsg = resSeven10265.WarnMsg
  30689. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30690. res.Infcode = infocode
  30691. } else {
  30692. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30693. utils.ErrorLog("解析失败:%v", err)
  30694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30695. return
  30696. }
  30697. }
  30698. }
  30699. } else {
  30700. c.ServeSuccessJSON(map[string]interface{}{
  30701. "failed_code": -10,
  30702. "msg": result3101.ErrMsg,
  30703. })
  30704. return
  30705. }
  30706. } else {
  30707. var result string
  30708. var request_log string
  30709. var dat map[string]interface{}
  30710. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30711. allTotal = fmt.Sprintf("%.2f", total_two)
  30712. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" {
  30713. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  30714. if result3101.Infcode == 0 {
  30715. if len(result3101.Output.Result) > 0 {
  30716. var errMsgs []string
  30717. for _, item := range result3101.Output.Result {
  30718. errMsgs = append(errMsgs, item.VolaCont)
  30719. }
  30720. c.ServeSuccessJSON(map[string]interface{}{
  30721. "failed_code": -10,
  30722. "msg": errMsgs,
  30723. })
  30724. return
  30725. } else {
  30726. var result string
  30727. var request_log string
  30728. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  30729. allTotal = fmt.Sprintf("%.2f", total_two)
  30730. if his.IdCardType == 4 {
  30731. 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)
  30732. } else {
  30733. if his.IdCardType == 2 {
  30734. cert_no = psn_info.Certno
  30735. psn_info.VerifyNumber = psn_info.Certno
  30736. } else {
  30737. bas := strings.Split(psn_info.CardInfo, "|")
  30738. cert_no = bas[2]
  30739. }
  30740. 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)
  30741. }
  30742. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30743. fmt.Println(dat)
  30744. } else {
  30745. fmt.Println(err)
  30746. }
  30747. saveLog(result, request_log, "2206", "预结算")
  30748. }
  30749. } else {
  30750. c.ServeSuccessJSON(map[string]interface{}{
  30751. "failed_code": -10,
  30752. "msg": result3101.ErrMsg,
  30753. })
  30754. return
  30755. }
  30756. } else {
  30757. if his.IdCardType == 4 {
  30758. 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)
  30759. } else {
  30760. if his.IdCardType == 2 {
  30761. cert_no = psn_info.Certno
  30762. psn_info.VerifyNumber = psn_info.Certno
  30763. } else {
  30764. bas := strings.Split(psn_info.CardInfo, "|")
  30765. cert_no = bas[2]
  30766. }
  30767. 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)
  30768. }
  30769. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30770. fmt.Println(dat)
  30771. } else {
  30772. fmt.Println(err)
  30773. }
  30774. saveLog(result, request_log, "2206", "预结算")
  30775. }
  30776. //userJSONBytes, _ := json.Marshal(dat)
  30777. //
  30778. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30779. // utils.ErrorLog("解析失败:%v", err)
  30780. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30781. // return
  30782. //}
  30783. userJSONBytes, _ := json.Marshal(dat)
  30784. if miConfig.Code == "H15049901371" {
  30785. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  30786. utils.ErrorLog("解析失败:%v", err)
  30787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30788. return
  30789. }
  30790. res.InfRefmsgid = resSeven10265.InfRefmsgid
  30791. res.Output = resSeven10265.Output
  30792. res.ErrMsg = resSeven10265.ErrMsg
  30793. res.Cainfo = resSeven10265.Cainfo
  30794. res.WarnMsg = resSeven10265.WarnMsg
  30795. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  30796. res.Infcode = infocode
  30797. } else {
  30798. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30799. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  30800. utils.ErrorLog("解析失败:%v", err)
  30801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30802. return
  30803. }
  30804. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  30805. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  30806. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  30807. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30808. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  30809. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  30810. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  30811. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  30812. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  30813. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30814. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30815. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30816. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30817. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  30818. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  30819. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  30820. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  30821. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  30822. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  30823. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  30824. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  30825. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  30826. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  30827. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  30828. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  30829. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  30830. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  30831. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  30832. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  30833. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  30834. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  30835. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  30836. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  30837. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  30838. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  30839. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  30840. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  30841. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  30842. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  30843. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  30844. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  30845. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  30846. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  30847. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  30848. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  30849. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  30850. res.ErrMsg = gzresSeven10265Two.ErrMsg
  30851. res.Cainfo = gzresSeven10265Two.Cainfo
  30852. res.WarnMsg = gzresSeven10265Two.WarnMsg
  30853. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  30854. //res.Infcode = infocode
  30855. } else {
  30856. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30857. utils.ErrorLog("解析失败:%v", err)
  30858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30859. return
  30860. }
  30861. }
  30862. }
  30863. }
  30864. }
  30865. utils.ErrorLog("解析失败:%v", res.Infcode)
  30866. if res.Infcode == -1 {
  30867. errlog := &models.HisOrderError{
  30868. UserOrgId: adminUser.CurrentOrgId,
  30869. Ctime: time.Now().Unix(),
  30870. Mtime: time.Now().Unix(),
  30871. Number: chrg_bchno,
  30872. ErrMsg: res.ErrMsg,
  30873. Status: 1,
  30874. PatientId: id,
  30875. RecordTime: recordDateTime,
  30876. Stage: 20,
  30877. }
  30878. service.CreateErrMsgLog(errlog)
  30879. c.ServeSuccessJSON(map[string]interface{}{
  30880. "failed_code": -10,
  30881. "msg": res.ErrMsg,
  30882. })
  30883. return
  30884. }
  30885. if res.Infcode != 0 {
  30886. errlog := &models.HisOrderError{
  30887. UserOrgId: adminUser.CurrentOrgId,
  30888. Ctime: time.Now().Unix(),
  30889. Mtime: time.Now().Unix(),
  30890. Number: chrg_bchno,
  30891. ErrMsg: res.ErrMsg,
  30892. Status: 1,
  30893. PatientId: id,
  30894. RecordTime: recordDateTime,
  30895. Stage: 20,
  30896. }
  30897. service.CreateErrMsgLog(errlog)
  30898. c.ServeSuccessJSON(map[string]interface{}{
  30899. "failed_code": -10,
  30900. "msg": res.ErrMsg,
  30901. })
  30902. return
  30903. } else {
  30904. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  30905. order.OrderStatus = 1
  30906. order.IsPre = 1
  30907. order.Status = 1
  30908. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  30909. order.SetlId = res.Output.Setlinfo.SetlID
  30910. order.PsnNo = res.Output.Setlinfo.PsnNo
  30911. order.PsnName = res.Output.Setlinfo.PsnName
  30912. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  30913. order.Certno = res.Output.Setlinfo.Certno
  30914. order.Gend = res.Output.Setlinfo.Gend
  30915. order.Naty = res.Output.Setlinfo.Naty
  30916. order.Age = res.Output.Setlinfo.Age
  30917. order.Insutype = res.Output.Setlinfo.Insutype
  30918. order.PsnType = res.Output.Setlinfo.PsnType
  30919. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  30920. order.SetlTime = res.Output.Setlinfo.SetlTime
  30921. order.AcctUsedFlag = acct_used_flag
  30922. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  30923. if res.Output.Setlinfo.MedType == "140101" {
  30924. order.MedType = "14"
  30925. } else {
  30926. if res.Output.Setlinfo.MedType == "110104" {
  30927. order.MedType = "11"
  30928. } else {
  30929. order.MedType = res.Output.Setlinfo.MedType
  30930. }
  30931. }
  30932. if res.Output.Setlinfo.MedType == "992102" {
  30933. order.MedType = "992102"
  30934. }
  30935. if res.Output.Setlinfo.MedType == "140104" {
  30936. order.MedType = "140104"
  30937. }
  30938. if res.Output.Setlinfo.MedType == "140201" {
  30939. order.MedType = "140201"
  30940. }
  30941. if res.Output.Setlinfo.MedType == "14" {
  30942. order.MedType = "14"
  30943. }
  30944. if reg_type == 1112 {
  30945. order.MedType = "1112"
  30946. }
  30947. if reg_type == 1111 {
  30948. order.MedType = "1111"
  30949. }
  30950. order.ClrType = res.Output.Setlinfo.ClrType
  30951. if adminUser.CurrentOrgId == 10480 {
  30952. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  30953. order.ClrType = "11"
  30954. } else {
  30955. order.ClrType = "9903"
  30956. }
  30957. }
  30958. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  30959. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  30960. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  30961. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  30962. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  30963. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  30964. order.HifpPay = res.Output.Setlinfo.HifpPay
  30965. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  30966. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  30967. order.HifesPay = res.Output.Setlinfo.HifesPay
  30968. order.HifobPay = res.Output.Setlinfo.HifobPay
  30969. order.MafPay = res.Output.Setlinfo.MafPay
  30970. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  30971. order.OthPay = res.Output.Setlinfo.OthPay
  30972. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  30973. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  30974. order.AcctPay = res.Output.Setlinfo.AcctPay
  30975. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  30976. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  30977. order.Balc = res.Output.Setlinfo.Balc
  30978. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  30979. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  30980. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  30981. order.ClrWay = res.Output.Setlinfo.ClrWay
  30982. order.Creator = order.Creator
  30983. order.Modify = roles.AdminUserId
  30984. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  30985. //detailStr := string(setlDetail)
  30986. //order.SetlDetail = detailStr
  30987. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  30988. err = service.UpDateOrder(order)
  30989. if err == nil {
  30990. c.ServeSuccessJSON(map[string]interface{}{
  30991. "msg": "预结算成功",
  30992. })
  30993. } else {
  30994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  30995. return
  30996. }
  30997. }
  30998. } else {
  30999. adminUser := c.GetAdminUserInfo()
  31000. errlog := &models.HisOrderError{
  31001. UserOrgId: adminUser.CurrentOrgId,
  31002. Ctime: time.Now().Unix(),
  31003. Mtime: time.Now().Unix(),
  31004. ErrMsg: res.ErrMsg,
  31005. Status: 1,
  31006. PatientId: id,
  31007. RecordTime: recordDateTime,
  31008. Stage: 4,
  31009. }
  31010. service.CreateErrMsgLog(errlog)
  31011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  31012. return
  31013. }
  31014. } else {
  31015. if miConfig.MdtrtareaAdmvs == "150499" {
  31016. order := &models.HisOrder{
  31017. UserOrgId: adminUser.CurrentOrgId,
  31018. HisPatientId: his.ID,
  31019. PatientId: his.PatientId,
  31020. SettleAccountsDate: recordDateTime,
  31021. Ctime: time.Now().Unix(),
  31022. Mtime: time.Now().Unix(),
  31023. MdtrtId: his.Number,
  31024. PsnNo: his.PsnNo,
  31025. MedType: strconv.FormatInt(reg_type, 10),
  31026. Status: 1,
  31027. Number: chrg_bchno,
  31028. Infcode: res.Infcode,
  31029. WarnMsg: res.WarnMsg,
  31030. Cainfo: res.Cainfo,
  31031. ErrMsg: res.ErrMsg,
  31032. RespondTime: res.RefmsgTime,
  31033. InfRefmsgid: res.InfRefmsgid,
  31034. OrderStatus: 1,
  31035. IsMedicineInsurance: 1,
  31036. SettleType: settle_accounts_type,
  31037. SettleStartTime: start_time,
  31038. SettleEndTime: end_time,
  31039. Creator: roles.AdminUserId,
  31040. Modify: roles.AdminUserId,
  31041. PType: 2,
  31042. Diagnosis: diagnosis_id,
  31043. }
  31044. err = service.CreateOrder(order)
  31045. if err != nil {
  31046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  31047. return
  31048. }
  31049. }
  31050. adminUser := c.GetAdminUserInfo()
  31051. errlog := &models.HisOrderError{
  31052. UserOrgId: adminUser.CurrentOrgId,
  31053. Ctime: time.Now().Unix(),
  31054. Mtime: time.Now().Unix(),
  31055. ErrMsg: res.ErrMsg,
  31056. Status: 1,
  31057. PatientId: id,
  31058. RecordTime: recordDateTime,
  31059. Stage: 4,
  31060. }
  31061. service.CreateErrMsgLog(errlog)
  31062. c.ServeSuccessJSON(map[string]interface{}{
  31063. "failed_code": -10,
  31064. "msg": res.ErrMsg,
  31065. })
  31066. return
  31067. }
  31068. }
  31069. }
  31070. }
  31071. // 退款
  31072. func (c *HisApiController) Refund() {
  31073. order_id, _ := c.GetInt64("order_id")
  31074. admin_user_id, _ := c.GetInt64("admin_user_id")
  31075. adminUser := c.GetAdminUserInfo()
  31076. var order models.HisOrder
  31077. order, _ = service.GetHisOrderByID(order_id)
  31078. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  31079. if fapiao.ID > 0 {
  31080. c.ServeSuccessJSON(map[string]interface{}{
  31081. "failed_code": -10,
  31082. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  31083. })
  31084. return
  31085. }
  31086. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31087. if order.ID == 0 {
  31088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  31089. return
  31090. }
  31091. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  31092. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31093. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31094. if config.IsOpen == 1 { //对接了医保,走医保流程
  31095. var res ResultSixteen
  31096. var ahres ResultSevenAH
  31097. var resSixteen10265 ResultSixteen10265
  31098. var resSixteen10265Two ResultSixteen10265Two
  31099. var gz ResultgzSixteen10265Two
  31100. var src_resquest string
  31101. var result string
  31102. if miConfig.MdtrtareaAdmvs == "421300" {
  31103. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  31104. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31105. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31106. resp3, requestErr3 := http.Get(api3)
  31107. if requestErr3 != nil {
  31108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31109. return
  31110. }
  31111. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31112. if ioErr3 != nil {
  31113. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31115. return
  31116. }
  31117. var respJSON3 map[string]interface{}
  31118. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31119. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31121. return
  31122. }
  31123. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31124. userJSONBytes3, _ := json.Marshal(respJSON3)
  31125. fmt.Println("log")
  31126. fmt.Println(string(userJSONBytes3))
  31127. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31128. utils.ErrorLog("解析失败:%v", err)
  31129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31130. return
  31131. }
  31132. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31133. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  31134. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31135. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31136. resp3, requestErr3 := http.Get(api3)
  31137. if requestErr3 != nil {
  31138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31139. return
  31140. }
  31141. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31142. if ioErr3 != nil {
  31143. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31145. return
  31146. }
  31147. var respJSON3 map[string]interface{}
  31148. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31149. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31151. return
  31152. }
  31153. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31154. userJSONBytes3, _ := json.Marshal(respJSON3)
  31155. fmt.Println("log")
  31156. fmt.Println(string(userJSONBytes3))
  31157. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31158. utils.ErrorLog("解析失败:%v", err)
  31159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31160. return
  31161. }
  31162. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31163. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31164. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31165. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31166. resp3, requestErr3 := http.Get(api3)
  31167. if requestErr3 != nil {
  31168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31169. return
  31170. }
  31171. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31172. if ioErr3 != nil {
  31173. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31175. return
  31176. }
  31177. var respJSON3 map[string]interface{}
  31178. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31179. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31181. return
  31182. }
  31183. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31184. userJSONBytes3, _ := json.Marshal(respJSON3)
  31185. fmt.Println("log")
  31186. fmt.Println(string(userJSONBytes3))
  31187. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31188. utils.ErrorLog("解析失败:%v", err)
  31189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31190. return
  31191. }
  31192. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31193. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  31194. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31195. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31196. resp3, requestErr3 := http.Get(api3)
  31197. if requestErr3 != nil {
  31198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31199. return
  31200. }
  31201. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31202. if ioErr3 != nil {
  31203. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31205. return
  31206. }
  31207. var respJSON3 map[string]interface{}
  31208. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31209. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31211. return
  31212. }
  31213. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31214. userJSONBytes3, _ := json.Marshal(respJSON3)
  31215. fmt.Println("log")
  31216. fmt.Println(string(userJSONBytes3))
  31217. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31218. utils.ErrorLog("解析失败:%v", err)
  31219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31220. return
  31221. }
  31222. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31223. var api3 string
  31224. if miConfig.MdtrtareaAdmvs == "320921" {
  31225. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31226. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31227. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31228. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31229. } else {
  31230. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31231. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  31232. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31233. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31234. }
  31235. resp3, requestErr3 := http.Get(api3)
  31236. if requestErr3 != nil {
  31237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31238. return
  31239. }
  31240. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31241. if ioErr3 != nil {
  31242. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31244. return
  31245. }
  31246. var respJSON3 map[string]interface{}
  31247. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31248. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31250. return
  31251. }
  31252. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31253. userJSONBytes3, _ := json.Marshal(respJSON3)
  31254. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31255. utils.ErrorLog("解析失败:%v", err)
  31256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31257. return
  31258. }
  31259. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31260. res.Output = resSixteen10265.Output
  31261. res.ErrMsg = resSixteen10265.ErrMsg
  31262. res.Cainfo = resSixteen10265.Cainfo
  31263. res.WarnMsg = resSixteen10265.WarnMsg
  31264. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31265. res.Infcode = infocode
  31266. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31267. var api3 string
  31268. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  31269. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31270. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31271. resp3, requestErr3 := http.Get(api3)
  31272. if requestErr3 != nil {
  31273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31274. return
  31275. }
  31276. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31277. if ioErr3 != nil {
  31278. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31280. return
  31281. }
  31282. var respJSON3 map[string]interface{}
  31283. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31284. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31286. return
  31287. }
  31288. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31289. userJSONBytes3, _ := json.Marshal(respJSON3)
  31290. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  31291. utils.ErrorLog("解析失败:%v", err)
  31292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31293. return
  31294. }
  31295. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31296. res.Output = resSixteen10265.Output
  31297. res.ErrMsg = resSixteen10265.ErrMsg
  31298. res.Cainfo = resSixteen10265.Cainfo
  31299. res.WarnMsg = resSixteen10265.WarnMsg
  31300. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31301. res.Infcode = infocode
  31302. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31303. 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)
  31304. var dat map[string]interface{}
  31305. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31306. fmt.Println(dat)
  31307. } else {
  31308. fmt.Println(err)
  31309. }
  31310. saveLog(result, src_resquest, "2208", "退费")
  31311. userJSONBytes, _ := json.Marshal(dat)
  31312. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31313. utils.ErrorLog("解析失败:%v", err)
  31314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31315. return
  31316. }
  31317. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31318. 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, "")
  31319. var dat map[string]interface{}
  31320. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31321. fmt.Println(dat)
  31322. } else {
  31323. fmt.Println(err)
  31324. }
  31325. saveLog(result, src_resquest, "2208", "退费")
  31326. userJSONBytes, _ := json.Marshal(dat)
  31327. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31328. utils.ErrorLog("解析失败:%v", err)
  31329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31330. return
  31331. }
  31332. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31333. 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, "")
  31334. var dat map[string]interface{}
  31335. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31336. fmt.Println(dat)
  31337. } else {
  31338. fmt.Println(err)
  31339. }
  31340. saveLog(result, src_resquest, "2208", "退费")
  31341. userJSONBytes, _ := json.Marshal(dat)
  31342. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31343. utils.ErrorLog("解析失败:%v", err)
  31344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31345. return
  31346. }
  31347. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31348. var api3 string
  31349. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31350. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31351. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31352. resp3, requestErr3 := http.Get(api3)
  31353. if requestErr3 != nil {
  31354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31355. return
  31356. }
  31357. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31358. if ioErr3 != nil {
  31359. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31361. return
  31362. }
  31363. var respJSON3 map[string]interface{}
  31364. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31367. return
  31368. }
  31369. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31370. if status == "0" {
  31371. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31372. c.ServeSuccessJSON(map[string]interface{}{
  31373. "failed_code": -10,
  31374. "msg": err_msg,
  31375. })
  31376. return
  31377. }
  31378. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31379. userJSONBytes3, _ := json.Marshal(respJSON3)
  31380. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31381. // utils.ErrorLog("解析失败:%v", err)
  31382. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31383. // return
  31384. //}
  31385. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31386. utils.ErrorLog("解析失败:%v", err)
  31387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31388. return
  31389. }
  31390. res.InfRefmsgid = ahres.InfRefmsgid
  31391. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31392. // 创建对应的Time类型
  31393. t := time.UnixMilli(timestamp)
  31394. // 格式化成指定的日期字符串
  31395. str := t.Format("2006-01-02 15:04:05")
  31396. res.Output.Setlinfo.SetlTime = str
  31397. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31398. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31399. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31400. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31401. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31402. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31403. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31404. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31405. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31406. //
  31407. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31408. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31409. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31410. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31411. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31412. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31413. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31414. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31415. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31416. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31417. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31418. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31419. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31420. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31421. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31422. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31423. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31424. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31425. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31426. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31427. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31428. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31429. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31430. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31431. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31432. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31433. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31434. //res.Output.Setldetail = ahres.Output.Setldetail
  31435. res.ErrMsg = ahres.ErrMsg
  31436. res.Cainfo = ahres.Cainfo
  31437. res.WarnMsg = ahres.WarnMsg
  31438. res.Infcode = ahres.Infcode
  31439. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31440. var api3 string
  31441. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  31442. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31443. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31444. resp3, requestErr3 := http.Get(api3)
  31445. if requestErr3 != nil {
  31446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31447. return
  31448. }
  31449. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31450. if ioErr3 != nil {
  31451. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31453. return
  31454. }
  31455. var respJSON3 map[string]interface{}
  31456. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31459. return
  31460. }
  31461. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31462. if status == "0" {
  31463. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31464. c.ServeSuccessJSON(map[string]interface{}{
  31465. "failed_code": -10,
  31466. "msg": err_msg,
  31467. })
  31468. return
  31469. }
  31470. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31471. userJSONBytes3, _ := json.Marshal(respJSON3)
  31472. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31473. // utils.ErrorLog("解析失败:%v", err)
  31474. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31475. // return
  31476. //}
  31477. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  31478. utils.ErrorLog("解析失败:%v", err)
  31479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31480. return
  31481. }
  31482. res.InfRefmsgid = ahres.InfRefmsgid
  31483. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31484. // 创建对应的Time类型
  31485. t := time.UnixMilli(timestamp)
  31486. // 格式化成指定的日期字符串
  31487. str := t.Format("2006-01-02 15:04:05")
  31488. res.Output.Setlinfo.SetlTime = str
  31489. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  31490. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  31491. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31492. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  31493. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  31494. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  31495. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31496. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  31497. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  31498. //
  31499. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  31500. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  31501. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  31502. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  31503. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  31504. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  31505. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  31506. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  31507. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  31508. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  31509. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31510. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  31511. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  31512. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  31513. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  31514. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31515. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  31516. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  31517. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  31518. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  31519. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  31520. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  31521. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  31522. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  31523. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  31524. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31525. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  31526. //res.Output.Setldetail = ahres.Output.Setldetail
  31527. res.ErrMsg = ahres.ErrMsg
  31528. res.Cainfo = ahres.Cainfo
  31529. res.WarnMsg = ahres.WarnMsg
  31530. res.Infcode = ahres.Infcode
  31531. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31532. 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, "")
  31533. var dat map[string]interface{}
  31534. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31535. fmt.Println(dat)
  31536. } else {
  31537. fmt.Println(err)
  31538. }
  31539. saveLog(result, src_resquest, "2208", "退费")
  31540. userJSONBytes, _ := json.Marshal(dat)
  31541. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31542. utils.ErrorLog("解析失败:%v", err)
  31543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31544. return
  31545. }
  31546. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31547. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  31548. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31549. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31550. resp3, requestErr3 := http.Get(api3)
  31551. if requestErr3 != nil {
  31552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31553. return
  31554. }
  31555. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31556. if ioErr3 != nil {
  31557. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31559. return
  31560. }
  31561. var respJSON3 map[string]interface{}
  31562. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31563. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31565. return
  31566. }
  31567. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31568. userJSONBytes3, _ := json.Marshal(respJSON3)
  31569. fmt.Println("log")
  31570. fmt.Println(string(userJSONBytes3))
  31571. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  31572. utils.ErrorLog("解析失败:%v", err)
  31573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31574. return
  31575. }
  31576. } else {
  31577. if miConfig.Code == "H15049901371" {
  31578. 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)
  31579. var dat map[string]interface{}
  31580. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31581. fmt.Println(dat)
  31582. } else {
  31583. fmt.Println(err)
  31584. }
  31585. saveLog(result, src_resquest, "2208", "退费")
  31586. if strings.Contains(result, "Post") {
  31587. res.Infcode = -1
  31588. res.ErrMsg = result
  31589. }
  31590. userJSONBytes, _ := json.Marshal(dat)
  31591. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  31592. utils.ErrorLog("解析失败:%v", err)
  31593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31594. return
  31595. }
  31596. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  31597. res.Output = resSixteen10265.Output
  31598. res.ErrMsg = resSixteen10265.ErrMsg
  31599. res.Cainfo = resSixteen10265.Cainfo
  31600. res.WarnMsg = resSixteen10265.WarnMsg
  31601. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  31602. res.Infcode = infocode
  31603. } else {
  31604. 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)
  31605. var dat map[string]interface{}
  31606. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31607. fmt.Println(dat)
  31608. } else {
  31609. fmt.Println(err)
  31610. }
  31611. saveLog(result, src_resquest, "2208", "退费")
  31612. userJSONBytes, _ := json.Marshal(dat)
  31613. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  31614. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  31615. utils.ErrorLog("解析失败:%v", err)
  31616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31617. return
  31618. }
  31619. res.Infcode = gz.Infcode
  31620. } else {
  31621. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31622. utils.ErrorLog("解析失败:%v", err)
  31623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31624. return
  31625. }
  31626. }
  31627. if strings.Contains(result, "Post") {
  31628. res.Infcode = -1
  31629. res.ErrMsg = result
  31630. }
  31631. }
  31632. }
  31633. if res.Infcode == -1 {
  31634. c.ServeSuccessJSON(map[string]interface{}{
  31635. "failed_code": -10,
  31636. "msg": res.ErrMsg,
  31637. })
  31638. return
  31639. }
  31640. if res.Infcode != -1 {
  31641. var res2 ResultSix
  31642. var resSix10265 ResultSix10265
  31643. if miConfig.MdtrtareaAdmvs == "421300" {
  31644. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31645. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31646. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31647. resp3, requestErr3 := http.Get(api3)
  31648. if requestErr3 != nil {
  31649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31650. return
  31651. }
  31652. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31653. if ioErr3 != nil {
  31654. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31656. return
  31657. }
  31658. var respJSON3 map[string]interface{}
  31659. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31660. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31662. return
  31663. }
  31664. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31665. userJSONBytes3, _ := json.Marshal(respJSON3)
  31666. fmt.Println("log")
  31667. fmt.Println(string(userJSONBytes3))
  31668. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31669. utils.ErrorLog("解析失败:%v", err)
  31670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31671. return
  31672. }
  31673. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31674. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  31675. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31676. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31677. resp3, requestErr3 := http.Get(api3)
  31678. if requestErr3 != nil {
  31679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31680. return
  31681. }
  31682. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31683. if ioErr3 != nil {
  31684. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31686. return
  31687. }
  31688. var respJSON3 map[string]interface{}
  31689. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31690. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31692. return
  31693. }
  31694. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31695. userJSONBytes3, _ := json.Marshal(respJSON3)
  31696. fmt.Println("log")
  31697. fmt.Println(string(userJSONBytes3))
  31698. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31699. utils.ErrorLog("解析失败:%v", err)
  31700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31701. return
  31702. }
  31703. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31704. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31705. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31706. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31707. resp3, requestErr3 := http.Get(api3)
  31708. if requestErr3 != nil {
  31709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31710. return
  31711. }
  31712. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31713. if ioErr3 != nil {
  31714. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31716. return
  31717. }
  31718. var respJSON3 map[string]interface{}
  31719. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31722. return
  31723. }
  31724. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31725. userJSONBytes3, _ := json.Marshal(respJSON3)
  31726. fmt.Println("log")
  31727. fmt.Println(string(userJSONBytes3))
  31728. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31729. utils.ErrorLog("解析失败:%v", err)
  31730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31731. return
  31732. }
  31733. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31734. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  31735. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31736. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31737. resp3, requestErr3 := http.Get(api3)
  31738. if requestErr3 != nil {
  31739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31740. return
  31741. }
  31742. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31743. if ioErr3 != nil {
  31744. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31746. return
  31747. }
  31748. var respJSON3 map[string]interface{}
  31749. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31750. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31752. return
  31753. }
  31754. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31755. userJSONBytes3, _ := json.Marshal(respJSON3)
  31756. fmt.Println("log")
  31757. fmt.Println(string(userJSONBytes3))
  31758. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31759. utils.ErrorLog("解析失败:%v", err)
  31760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31761. return
  31762. }
  31763. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31764. var api3 string
  31765. if miConfig.MdtrtareaAdmvs == "320921" {
  31766. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31767. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31768. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31769. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31770. } else {
  31771. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31772. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  31773. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31774. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31775. }
  31776. resp3, requestErr3 := http.Get(api3)
  31777. if requestErr3 != nil {
  31778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31779. return
  31780. }
  31781. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31782. if ioErr3 != nil {
  31783. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31785. return
  31786. }
  31787. var respJSON3 map[string]interface{}
  31788. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31789. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31791. return
  31792. }
  31793. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31794. userJSONBytes3, _ := json.Marshal(respJSON3)
  31795. fmt.Println("log")
  31796. fmt.Println(string(userJSONBytes3))
  31797. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31798. utils.ErrorLog("解析失败:%v", err)
  31799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31800. return
  31801. }
  31802. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31803. res2.Output = resSix10265.Output
  31804. res2.ErrMsg = resSix10265.ErrMsg
  31805. res2.Cainfo = resSix10265.Cainfo
  31806. res2.WarnMsg = resSix10265.WarnMsg
  31807. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31808. res2.Infcode = infocode
  31809. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31810. var api3 string
  31811. new_chrg_bchno := order.Number
  31812. if adminUser.CurrentOrgId == 10265 {
  31813. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  31814. new_chrg_bchno = "0000"
  31815. }
  31816. }
  31817. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  31818. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31819. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31820. resp3, requestErr3 := http.Get(api3)
  31821. if requestErr3 != nil {
  31822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31823. return
  31824. }
  31825. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31826. if ioErr3 != nil {
  31827. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31829. return
  31830. }
  31831. var respJSON3 map[string]interface{}
  31832. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31835. return
  31836. }
  31837. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31838. userJSONBytes3, _ := json.Marshal(respJSON3)
  31839. fmt.Println("log")
  31840. fmt.Println(string(userJSONBytes3))
  31841. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  31842. utils.ErrorLog("解析失败:%v", err)
  31843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31844. return
  31845. }
  31846. res2.InfRefmsgid = resSix10265.InfRefmsgid
  31847. res2.Output = resSix10265.Output
  31848. res2.ErrMsg = resSix10265.ErrMsg
  31849. res2.Cainfo = resSix10265.Cainfo
  31850. res2.WarnMsg = resSix10265.WarnMsg
  31851. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31852. res2.Infcode = infocode
  31853. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31854. 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)
  31855. var dat map[string]interface{}
  31856. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31857. fmt.Println(dat)
  31858. } else {
  31859. fmt.Println(err)
  31860. }
  31861. saveLog(result2, src_request, "2205", "撤销明细")
  31862. userJSONBytes, _ := json.Marshal(dat)
  31863. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31864. utils.ErrorLog("解析失败:%v", err)
  31865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31866. return
  31867. }
  31868. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31869. 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, "")
  31870. var dat map[string]interface{}
  31871. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31872. fmt.Println(dat)
  31873. } else {
  31874. fmt.Println(err)
  31875. }
  31876. saveLog(result2, src_request, "2205", "撤销明细")
  31877. userJSONBytes, _ := json.Marshal(dat)
  31878. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31879. utils.ErrorLog("解析失败:%v", err)
  31880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31881. return
  31882. }
  31883. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31884. 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, "")
  31885. var dat map[string]interface{}
  31886. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31887. fmt.Println(dat)
  31888. } else {
  31889. fmt.Println(err)
  31890. }
  31891. saveLog(result2, src_request, "2205", "撤销明细")
  31892. userJSONBytes, _ := json.Marshal(dat)
  31893. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31894. utils.ErrorLog("解析失败:%v", err)
  31895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31896. return
  31897. }
  31898. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31899. var api3 string
  31900. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31901. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31902. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31903. resp3, requestErr3 := http.Get(api3)
  31904. if requestErr3 != nil {
  31905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31906. return
  31907. }
  31908. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31909. if ioErr3 != nil {
  31910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31912. return
  31913. }
  31914. var respJSON3 map[string]interface{}
  31915. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31918. return
  31919. }
  31920. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31921. if status == "0" {
  31922. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31923. c.ServeSuccessJSON(map[string]interface{}{
  31924. "failed_code": -10,
  31925. "msg": err_msg,
  31926. })
  31927. return
  31928. }
  31929. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31930. userJSONBytes3, _ := json.Marshal(respJSON3)
  31931. fmt.Println("log")
  31932. fmt.Println(string(userJSONBytes3))
  31933. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  31934. utils.ErrorLog("解析失败:%v", err)
  31935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31936. return
  31937. }
  31938. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31939. 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, "")
  31940. var dat map[string]interface{}
  31941. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31942. fmt.Println(dat)
  31943. } else {
  31944. fmt.Println(err)
  31945. }
  31946. saveLog(result2, src_request, "2205", "撤销明细")
  31947. userJSONBytes, _ := json.Marshal(dat)
  31948. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31949. utils.ErrorLog("解析失败:%v", err)
  31950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31951. return
  31952. }
  31953. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31954. 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, "")
  31955. var dat map[string]interface{}
  31956. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  31957. fmt.Println(dat)
  31958. } else {
  31959. fmt.Println(err)
  31960. }
  31961. saveLog(result2, src_request, "2205", "撤销明细")
  31962. userJSONBytes, _ := json.Marshal(dat)
  31963. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  31964. utils.ErrorLog("解析失败:%v", err)
  31965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31966. return
  31967. }
  31968. } else if miConfig.MdtrtareaAdmvs == "340699" {
  31969. var api3 string
  31970. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  31971. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  31972. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31973. resp3, requestErr3 := http.Get(api3)
  31974. if requestErr3 != nil {
  31975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31976. return
  31977. }
  31978. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  31979. if ioErr3 != nil {
  31980. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  31981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31982. return
  31983. }
  31984. var respJSON3 map[string]interface{}
  31985. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  31986. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31988. return
  31989. }
  31990. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  31991. if status == "0" {
  31992. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  31993. c.ServeSuccessJSON(map[string]interface{}{
  31994. "failed_code": -10,
  31995. "msg": err_msg,
  31996. })
  31997. return
  31998. }
  31999. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32000. userJSONBytes3, _ := json.Marshal(respJSON3)
  32001. fmt.Println("log")
  32002. fmt.Println(string(userJSONBytes3))
  32003. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32004. utils.ErrorLog("解析失败:%v", err)
  32005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32006. return
  32007. }
  32008. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32009. 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, "")
  32010. var dat map[string]interface{}
  32011. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32012. fmt.Println(dat)
  32013. } else {
  32014. fmt.Println(err)
  32015. }
  32016. saveLog(result2, src_request, "2205", "撤销明细")
  32017. userJSONBytes, _ := json.Marshal(dat)
  32018. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32019. utils.ErrorLog("解析失败:%v", err)
  32020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32021. return
  32022. }
  32023. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32024. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  32025. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32026. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32027. resp3, requestErr3 := http.Get(api3)
  32028. if requestErr3 != nil {
  32029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32030. return
  32031. }
  32032. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32033. if ioErr3 != nil {
  32034. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32036. return
  32037. }
  32038. var respJSON3 map[string]interface{}
  32039. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32040. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32042. return
  32043. }
  32044. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32045. userJSONBytes3, _ := json.Marshal(respJSON3)
  32046. fmt.Println("log")
  32047. fmt.Println(string(userJSONBytes3))
  32048. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32049. utils.ErrorLog("解析失败:%v", err)
  32050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32051. return
  32052. }
  32053. } else {
  32054. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32055. res2.Infcode = 0
  32056. } else {
  32057. 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)
  32058. var dat map[string]interface{}
  32059. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  32060. fmt.Println(dat)
  32061. } else {
  32062. fmt.Println(err)
  32063. }
  32064. saveLog(result2, src_request, "2205", "撤销明细")
  32065. userJSONBytes, _ := json.Marshal(dat)
  32066. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32067. utils.ErrorLog("解析失败:%v", err)
  32068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32069. return
  32070. }
  32071. }
  32072. }
  32073. if res2.Infcode == -1 {
  32074. c.ServeSuccessJSON(map[string]interface{}{
  32075. "failed_code": -10,
  32076. "msg": res2.ErrMsg,
  32077. })
  32078. return
  32079. }
  32080. if res2.Infcode == 0 {
  32081. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  32082. if err == nil {
  32083. //当押金不为零时产生退费记录
  32084. if order.Decimal != 0 {
  32085. tmp := strconv.FormatInt(order.ID, 10)
  32086. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  32087. if err != nil {
  32088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32089. return
  32090. }
  32091. }
  32092. c.ServeSuccessJSON(map[string]interface{}{
  32093. "msg": "退费成功",
  32094. })
  32095. } else {
  32096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32097. return
  32098. }
  32099. } else {
  32100. c.ServeSuccessJSON(map[string]interface{}{
  32101. "failed_code": -10,
  32102. "msg": res2.ErrMsg,
  32103. })
  32104. }
  32105. } else {
  32106. c.ServeSuccessJSON(map[string]interface{}{
  32107. "failed_code": -10,
  32108. "msg": res.ErrMsg,
  32109. })
  32110. }
  32111. }
  32112. }
  32113. func (c *HisApiController) RefundNumber() {
  32114. record_time := c.GetString("record_time")
  32115. //patient_id, _ := c.GetInt64("patient_id")
  32116. admin_user_id, _ := c.GetInt64("admin_user_id")
  32117. his_patient_id, _ := c.GetInt64("id")
  32118. timeLayout := "2006-01-02"
  32119. loc, _ := time.LoadLocation("Local")
  32120. adminUser := c.GetAdminUserInfo()
  32121. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32122. fmt.Println(err)
  32123. if err != nil {
  32124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32125. return
  32126. }
  32127. recordDateTime := theTime.Unix()
  32128. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32129. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  32130. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32131. //order, _ := service.GetHisOrderByID(order_id)
  32132. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32133. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32134. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32135. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  32136. if count > 0 {
  32137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  32138. return
  32139. }
  32140. if config.IsOpen == 1 { //对接了医保,走医保流程
  32141. var res2 ResultSix
  32142. var res3 GZResultSix
  32143. var resSix10265 ResultSix10265
  32144. if miConfig.MdtrtareaAdmvs == "421300" {
  32145. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32146. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32147. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32148. resp3, requestErr3 := http.Get(api3)
  32149. if requestErr3 != nil {
  32150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32151. return
  32152. }
  32153. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32154. if ioErr3 != nil {
  32155. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32157. return
  32158. }
  32159. var respJSON3 map[string]interface{}
  32160. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32161. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32163. return
  32164. }
  32165. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32166. userJSONBytes3, _ := json.Marshal(respJSON3)
  32167. fmt.Println("log")
  32168. fmt.Println(string(userJSONBytes3))
  32169. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32170. utils.ErrorLog("解析失败:%v", err)
  32171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32172. return
  32173. }
  32174. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32175. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  32176. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32177. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32178. resp3, requestErr3 := http.Get(api3)
  32179. if requestErr3 != nil {
  32180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32181. return
  32182. }
  32183. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32184. if ioErr3 != nil {
  32185. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32187. return
  32188. }
  32189. var respJSON3 map[string]interface{}
  32190. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32191. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32193. return
  32194. }
  32195. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32196. userJSONBytes3, _ := json.Marshal(respJSON3)
  32197. fmt.Println("log")
  32198. fmt.Println(string(userJSONBytes3))
  32199. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32200. utils.ErrorLog("解析失败:%v", err)
  32201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32202. return
  32203. }
  32204. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32205. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32206. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32207. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32208. resp3, requestErr3 := http.Get(api3)
  32209. if requestErr3 != nil {
  32210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32211. return
  32212. }
  32213. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32214. if ioErr3 != nil {
  32215. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32217. return
  32218. }
  32219. var respJSON3 map[string]interface{}
  32220. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32221. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32223. return
  32224. }
  32225. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32226. userJSONBytes3, _ := json.Marshal(respJSON3)
  32227. fmt.Println("log")
  32228. fmt.Println(string(userJSONBytes3))
  32229. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32230. utils.ErrorLog("解析失败:%v", err)
  32231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32232. return
  32233. }
  32234. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32235. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  32236. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32237. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32238. resp3, requestErr3 := http.Get(api3)
  32239. if requestErr3 != nil {
  32240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32241. return
  32242. }
  32243. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32244. if ioErr3 != nil {
  32245. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32247. return
  32248. }
  32249. var respJSON3 map[string]interface{}
  32250. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32251. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32253. return
  32254. }
  32255. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32256. userJSONBytes3, _ := json.Marshal(respJSON3)
  32257. fmt.Println("log")
  32258. fmt.Println(string(userJSONBytes3))
  32259. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32260. utils.ErrorLog("解析失败:%v", err)
  32261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32262. return
  32263. }
  32264. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32265. var api3 string
  32266. if miConfig.MdtrtareaAdmvs == "320921" {
  32267. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32268. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32269. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32270. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32271. } else {
  32272. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32273. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  32274. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32275. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32276. }
  32277. resp3, requestErr3 := http.Get(api3)
  32278. if requestErr3 != nil {
  32279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32280. return
  32281. }
  32282. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32283. if ioErr3 != nil {
  32284. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32286. return
  32287. }
  32288. var respJSON3 map[string]interface{}
  32289. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32290. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32292. return
  32293. }
  32294. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32295. userJSONBytes3, _ := json.Marshal(respJSON3)
  32296. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32297. utils.ErrorLog("解析失败:%v", err)
  32298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32299. return
  32300. }
  32301. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32302. res2.Output = resSix10265.Output
  32303. res2.ErrMsg = resSix10265.ErrMsg
  32304. res2.Cainfo = resSix10265.Cainfo
  32305. res2.WarnMsg = resSix10265.WarnMsg
  32306. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32307. res2.Infcode = infocode
  32308. } else if miConfig.MdtrtareaAdmvs == "150499" {
  32309. var api3 string
  32310. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  32311. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32312. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32313. resp3, requestErr3 := http.Get(api3)
  32314. if requestErr3 != nil {
  32315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32316. return
  32317. }
  32318. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32319. if ioErr3 != nil {
  32320. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32322. return
  32323. }
  32324. var respJSON3 map[string]interface{}
  32325. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32326. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32328. return
  32329. }
  32330. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32331. userJSONBytes3, _ := json.Marshal(respJSON3)
  32332. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32333. utils.ErrorLog("解析失败:%v", err)
  32334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32335. return
  32336. }
  32337. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32338. res2.Output = resSix10265.Output
  32339. res2.ErrMsg = resSix10265.ErrMsg
  32340. res2.Cainfo = resSix10265.Cainfo
  32341. res2.WarnMsg = resSix10265.WarnMsg
  32342. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32343. res2.Infcode = infocode
  32344. } else if miConfig.MdtrtareaAdmvs == "350500" {
  32345. 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)
  32346. var dat map[string]interface{}
  32347. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32348. fmt.Println(dat)
  32349. } else {
  32350. fmt.Println(err)
  32351. }
  32352. saveLog(result, request, "2202", "退号")
  32353. userJSONBytes, _ := json.Marshal(dat)
  32354. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32355. utils.ErrorLog("解析失败:%v", err)
  32356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32357. return
  32358. }
  32359. } else if miConfig.MdtrtareaAdmvs == "360302" {
  32360. 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, "")
  32361. var dat map[string]interface{}
  32362. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32363. fmt.Println(dat)
  32364. } else {
  32365. fmt.Println(err)
  32366. }
  32367. saveLog(result, request, "2202", "退号")
  32368. userJSONBytes, _ := json.Marshal(dat)
  32369. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32370. utils.ErrorLog("解析失败:%v", err)
  32371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32372. return
  32373. }
  32374. } else if miConfig.MdtrtareaAdmvs == "361025" {
  32375. 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, "")
  32376. var dat map[string]interface{}
  32377. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32378. fmt.Println(dat)
  32379. } else {
  32380. fmt.Println(err)
  32381. }
  32382. saveLog(result, request, "2202", "退号")
  32383. userJSONBytes, _ := json.Marshal(dat)
  32384. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32385. utils.ErrorLog("解析失败:%v", err)
  32386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32387. return
  32388. }
  32389. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32390. var api3 string
  32391. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  32392. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32393. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32394. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32395. resp3, requestErr3 := http.Get(api3)
  32396. if requestErr3 != nil {
  32397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32398. return
  32399. }
  32400. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32401. if ioErr3 != nil {
  32402. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32404. return
  32405. }
  32406. var respJSON3 map[string]interface{}
  32407. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32408. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32410. return
  32411. }
  32412. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32413. if status == "0" {
  32414. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32415. c.ServeSuccessJSON(map[string]interface{}{
  32416. "failed_code": -10,
  32417. "msg": err_msg,
  32418. })
  32419. return
  32420. }
  32421. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32422. userJSONBytes3, _ := json.Marshal(respJSON3)
  32423. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32424. utils.ErrorLog("解析失败:%v", err)
  32425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32426. return
  32427. }
  32428. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32429. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32430. var api3 string
  32431. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  32432. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32433. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32434. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32435. resp3, requestErr3 := http.Get(api3)
  32436. if requestErr3 != nil {
  32437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32438. return
  32439. }
  32440. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32441. if ioErr3 != nil {
  32442. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32444. return
  32445. }
  32446. var respJSON3 map[string]interface{}
  32447. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32448. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32450. return
  32451. }
  32452. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32453. if status == "0" {
  32454. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32455. c.ServeSuccessJSON(map[string]interface{}{
  32456. "failed_code": -10,
  32457. "msg": err_msg,
  32458. })
  32459. return
  32460. }
  32461. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32462. userJSONBytes3, _ := json.Marshal(respJSON3)
  32463. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32464. utils.ErrorLog("解析失败:%v", err)
  32465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32466. return
  32467. }
  32468. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  32469. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32470. 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, "")
  32471. var dat map[string]interface{}
  32472. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32473. fmt.Println(dat)
  32474. } else {
  32475. fmt.Println(err)
  32476. }
  32477. saveLog(result, request, "2202", "退号")
  32478. userJSONBytes, _ := json.Marshal(dat)
  32479. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32480. utils.ErrorLog("解析失败:%v", err)
  32481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32482. return
  32483. }
  32484. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32485. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  32486. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32487. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32488. resp3, requestErr3 := http.Get(api3)
  32489. if requestErr3 != nil {
  32490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32491. return
  32492. }
  32493. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32494. if ioErr3 != nil {
  32495. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32497. return
  32498. }
  32499. var respJSON3 map[string]interface{}
  32500. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32501. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32503. return
  32504. }
  32505. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32506. userJSONBytes3, _ := json.Marshal(respJSON3)
  32507. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32508. utils.ErrorLog("解析失败:%v", err)
  32509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32510. return
  32511. }
  32512. } else {
  32513. var api3 string
  32514. if miConfig.Code == "H15049901371" {
  32515. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  32516. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32517. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32518. } else {
  32519. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  32520. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32521. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  32522. }
  32523. resp3, requestErr3 := http.Get(api3)
  32524. if requestErr3 != nil {
  32525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32526. return
  32527. }
  32528. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32529. if ioErr3 != nil {
  32530. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32532. return
  32533. }
  32534. var respJSON3 map[string]interface{}
  32535. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32536. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32538. return
  32539. }
  32540. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32541. userJSONBytes3, _ := json.Marshal(respJSON3)
  32542. if miConfig.Code == "H15049901371" {
  32543. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32544. utils.ErrorLog("解析失败:%v", err)
  32545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32546. return
  32547. }
  32548. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32549. res2.Output = resSix10265.Output
  32550. res2.ErrMsg = resSix10265.ErrMsg
  32551. res2.Cainfo = resSix10265.Cainfo
  32552. res2.WarnMsg = resSix10265.WarnMsg
  32553. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32554. res2.Infcode = infocode
  32555. } else {
  32556. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32557. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  32558. utils.ErrorLog("解析失败:%v", err)
  32559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32560. return
  32561. }
  32562. res2.Infcode = res3.Infcode
  32563. } else {
  32564. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32565. utils.ErrorLog("解析失败:%v", err)
  32566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32567. return
  32568. }
  32569. }
  32570. }
  32571. }
  32572. if res2.Infcode == -1 {
  32573. c.ServeSuccessJSON(map[string]interface{}{
  32574. "failed_code": -10,
  32575. "msg": res2.ErrMsg,
  32576. })
  32577. return
  32578. }
  32579. if res2.Infcode == 0 {
  32580. if err == nil {
  32581. c.ServeSuccessJSON(map[string]interface{}{
  32582. "msg": "退号成功",
  32583. })
  32584. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  32585. } else {
  32586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32587. return
  32588. }
  32589. }
  32590. } else {
  32591. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  32592. //if err == nil {
  32593. // c.ServeSuccessJSON(map[string]interface{}{
  32594. // "msg": "退费成功",
  32595. // })
  32596. //} else {
  32597. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32598. // return
  32599. //}
  32600. }
  32601. }
  32602. func (c *HisApiController) RefundDetail() {
  32603. order_id, _ := c.GetInt64("order_id")
  32604. admin_user_id, _ := c.GetInt64("admin_user_id")
  32605. //his_patient_id, _ := c.GetInt64("his_patient_id")
  32606. number := c.GetString("number")
  32607. record_time := c.GetString("record_time")
  32608. patient_id, _ := c.GetInt64("patient_id")
  32609. //med_type, _ := c.GetInt64("med_type")
  32610. timeLayout := "2006-01-02"
  32611. loc, _ := time.LoadLocation("Local")
  32612. adminUser := c.GetAdminUserInfo()
  32613. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32614. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32615. fmt.Println(err)
  32616. if err != nil {
  32617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32618. return
  32619. }
  32620. recordDateTime := theTime.Unix()
  32621. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  32622. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  32623. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32624. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32625. var order models.HisOrder
  32626. order, _ = service.GetHisOrderByID(order_id)
  32627. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  32628. if config.IsOpen == 1 { //对接了医保,走医保流程
  32629. var res2 ResultSix
  32630. if miConfig.MdtrtareaAdmvs == "421300" {
  32631. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32632. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32633. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32634. resp3, requestErr3 := http.Get(api3)
  32635. if requestErr3 != nil {
  32636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32637. return
  32638. }
  32639. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32640. if ioErr3 != nil {
  32641. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32643. return
  32644. }
  32645. var respJSON3 map[string]interface{}
  32646. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32647. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32649. return
  32650. }
  32651. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32652. userJSONBytes3, _ := json.Marshal(respJSON3)
  32653. fmt.Println("log")
  32654. fmt.Println(string(userJSONBytes3))
  32655. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32656. utils.ErrorLog("解析失败:%v", err)
  32657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32658. return
  32659. }
  32660. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32661. if err == nil {
  32662. c.ServeSuccessJSON(map[string]interface{}{
  32663. "msg": "撤销明细成功",
  32664. })
  32665. return
  32666. } else {
  32667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32668. return
  32669. }
  32670. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32671. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  32672. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32673. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32674. resp3, requestErr3 := http.Get(api3)
  32675. if requestErr3 != nil {
  32676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32677. return
  32678. }
  32679. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32680. if ioErr3 != nil {
  32681. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32683. return
  32684. }
  32685. var respJSON3 map[string]interface{}
  32686. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32687. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32689. return
  32690. }
  32691. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32692. userJSONBytes3, _ := json.Marshal(respJSON3)
  32693. fmt.Println("log")
  32694. fmt.Println(string(userJSONBytes3))
  32695. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32696. utils.ErrorLog("解析失败:%v", err)
  32697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32698. return
  32699. }
  32700. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32701. if err == nil {
  32702. c.ServeSuccessJSON(map[string]interface{}{
  32703. "msg": "撤销明细成功",
  32704. })
  32705. return
  32706. } else {
  32707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32708. return
  32709. }
  32710. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32711. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32712. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32713. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32714. resp3, requestErr3 := http.Get(api3)
  32715. if requestErr3 != nil {
  32716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32717. return
  32718. }
  32719. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32720. if ioErr3 != nil {
  32721. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32723. return
  32724. }
  32725. var respJSON3 map[string]interface{}
  32726. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32727. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32729. return
  32730. }
  32731. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32732. userJSONBytes3, _ := json.Marshal(respJSON3)
  32733. fmt.Println("log")
  32734. fmt.Println(string(userJSONBytes3))
  32735. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32736. utils.ErrorLog("解析失败:%v", err)
  32737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32738. return
  32739. }
  32740. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32741. if err == nil {
  32742. c.ServeSuccessJSON(map[string]interface{}{
  32743. "msg": "撤销明细成功",
  32744. })
  32745. return
  32746. } else {
  32747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32748. return
  32749. }
  32750. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32751. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  32752. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32753. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32754. resp3, requestErr3 := http.Get(api3)
  32755. if requestErr3 != nil {
  32756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32757. return
  32758. }
  32759. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32760. if ioErr3 != nil {
  32761. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32763. return
  32764. }
  32765. var respJSON3 map[string]interface{}
  32766. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32767. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32769. return
  32770. }
  32771. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32772. userJSONBytes3, _ := json.Marshal(respJSON3)
  32773. fmt.Println("log")
  32774. fmt.Println(string(userJSONBytes3))
  32775. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32776. utils.ErrorLog("解析失败:%v", err)
  32777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32778. return
  32779. }
  32780. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32781. if err == nil {
  32782. c.ServeSuccessJSON(map[string]interface{}{
  32783. "msg": "撤销明细成功",
  32784. })
  32785. return
  32786. } else {
  32787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32788. return
  32789. }
  32790. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  32791. var resSix10265 ResultSix10265
  32792. var api3 string
  32793. if miConfig.MdtrtareaAdmvs == "320921" {
  32794. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32795. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32796. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32797. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32798. } else {
  32799. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32800. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  32801. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32802. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32803. }
  32804. resp3, requestErr3 := http.Get(api3)
  32805. utils.ErrorLog("接口: %v", requestErr3)
  32806. if requestErr3 != nil {
  32807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32808. return
  32809. }
  32810. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32811. if ioErr3 != nil {
  32812. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32814. return
  32815. }
  32816. var respJSON3 map[string]interface{}
  32817. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32818. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32820. return
  32821. }
  32822. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32823. userJSONBytes3, _ := json.Marshal(respJSON3)
  32824. fmt.Println("log")
  32825. fmt.Println(string(userJSONBytes3))
  32826. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  32827. utils.ErrorLog("解析失败:%v", err)
  32828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32829. return
  32830. }
  32831. res2.InfRefmsgid = resSix10265.InfRefmsgid
  32832. res2.Output = resSix10265.Output
  32833. res2.ErrMsg = resSix10265.ErrMsg
  32834. res2.Cainfo = resSix10265.Cainfo
  32835. res2.WarnMsg = resSix10265.WarnMsg
  32836. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  32837. res2.Infcode = infocode
  32838. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32839. if err == nil {
  32840. c.ServeSuccessJSON(map[string]interface{}{
  32841. "msg": "撤销明细成功",
  32842. })
  32843. return
  32844. } else {
  32845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32846. return
  32847. }
  32848. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32849. var api3 string
  32850. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32851. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&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. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  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. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32873. if status == "0" {
  32874. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32875. c.ServeSuccessJSON(map[string]interface{}{
  32876. "failed_code": -10,
  32877. "msg": err_msg,
  32878. })
  32879. return
  32880. }
  32881. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32882. userJSONBytes3, _ := json.Marshal(respJSON3)
  32883. fmt.Println("log")
  32884. fmt.Println(string(userJSONBytes3))
  32885. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32886. utils.ErrorLog("解析失败:%v", err)
  32887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32888. return
  32889. }
  32890. fmt.Println(res2.Infcode)
  32891. if res2.Infcode == -1 {
  32892. c.ServeSuccessJSON(map[string]interface{}{
  32893. "failed_code": -10,
  32894. "msg": res2.ErrMsg,
  32895. })
  32896. return
  32897. }
  32898. if res2.Infcode == 0 {
  32899. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32900. if err == nil {
  32901. c.ServeSuccessJSON(map[string]interface{}{
  32902. "msg": "撤销明细成功",
  32903. })
  32904. return
  32905. } else {
  32906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32907. return
  32908. }
  32909. } else {
  32910. c.ServeSuccessJSON(map[string]interface{}{
  32911. "failed_code": -10,
  32912. "msg": res2.ErrMsg,
  32913. })
  32914. }
  32915. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32916. if err == nil {
  32917. c.ServeSuccessJSON(map[string]interface{}{
  32918. "msg": "撤销明细成功",
  32919. })
  32920. return
  32921. } else {
  32922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32923. return
  32924. }
  32925. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32926. var api3 string
  32927. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  32928. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32929. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32930. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32931. resp3, requestErr3 := http.Get(api3)
  32932. utils.ErrorLog("接口: %v", requestErr3)
  32933. if requestErr3 != nil {
  32934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32935. return
  32936. }
  32937. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32938. if ioErr3 != nil {
  32939. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32941. return
  32942. }
  32943. var respJSON3 map[string]interface{}
  32944. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32945. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32947. return
  32948. }
  32949. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  32950. if status == "0" {
  32951. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  32952. c.ServeSuccessJSON(map[string]interface{}{
  32953. "failed_code": -10,
  32954. "msg": err_msg,
  32955. })
  32956. return
  32957. }
  32958. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32959. userJSONBytes3, _ := json.Marshal(respJSON3)
  32960. fmt.Println("log")
  32961. fmt.Println(string(userJSONBytes3))
  32962. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  32963. utils.ErrorLog("解析失败:%v", err)
  32964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32965. return
  32966. }
  32967. fmt.Println(res2.Infcode)
  32968. if res2.Infcode == -1 {
  32969. c.ServeSuccessJSON(map[string]interface{}{
  32970. "failed_code": -10,
  32971. "msg": res2.ErrMsg,
  32972. })
  32973. return
  32974. }
  32975. if res2.Infcode == 0 {
  32976. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32977. if err == nil {
  32978. c.ServeSuccessJSON(map[string]interface{}{
  32979. "msg": "撤销明细成功",
  32980. })
  32981. return
  32982. } else {
  32983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32984. return
  32985. }
  32986. } else {
  32987. c.ServeSuccessJSON(map[string]interface{}{
  32988. "failed_code": -10,
  32989. "msg": res2.ErrMsg,
  32990. })
  32991. }
  32992. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  32993. if err == nil {
  32994. c.ServeSuccessJSON(map[string]interface{}{
  32995. "msg": "撤销明细成功",
  32996. })
  32997. return
  32998. } else {
  32999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33000. return
  33001. }
  33002. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33003. var resSix10265 ResultSix10265
  33004. new_chrg_bchno := order.Number
  33005. if adminUser.CurrentOrgId == 10265 {
  33006. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  33007. new_chrg_bchno = "0000"
  33008. }
  33009. }
  33010. var api3 string
  33011. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  33012. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33013. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33014. resp3, requestErr3 := http.Get(api3)
  33015. if requestErr3 != nil {
  33016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33017. return
  33018. }
  33019. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33020. if ioErr3 != nil {
  33021. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33023. return
  33024. }
  33025. var respJSON3 map[string]interface{}
  33026. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33027. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33029. return
  33030. }
  33031. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33032. userJSONBytes3, _ := json.Marshal(respJSON3)
  33033. fmt.Println("log")
  33034. fmt.Println(string(userJSONBytes3))
  33035. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33036. utils.ErrorLog("解析失败:%v", err)
  33037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33038. return
  33039. }
  33040. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33041. res2.Output = resSix10265.Output
  33042. res2.ErrMsg = resSix10265.ErrMsg
  33043. res2.Cainfo = resSix10265.Cainfo
  33044. res2.WarnMsg = resSix10265.WarnMsg
  33045. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33046. res2.Infcode = infocode
  33047. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33048. if err == nil {
  33049. c.ServeSuccessJSON(map[string]interface{}{
  33050. "msg": "撤销明细成功",
  33051. })
  33052. return
  33053. } else {
  33054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33055. return
  33056. }
  33057. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33058. 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)
  33059. var dat map[string]interface{}
  33060. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33061. fmt.Println(dat)
  33062. } else {
  33063. fmt.Println(err)
  33064. }
  33065. saveLog(result2, src_request, "2205", "撤销明细")
  33066. userJSONBytes, _ := json.Marshal(dat)
  33067. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33068. utils.ErrorLog("解析失败:%v", err)
  33069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33070. return
  33071. }
  33072. if res2.Infcode == 0 {
  33073. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33074. if err == nil {
  33075. c.ServeSuccessJSON(map[string]interface{}{
  33076. "msg": "撤销明细成功",
  33077. })
  33078. return
  33079. } else {
  33080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33081. return
  33082. }
  33083. } else {
  33084. c.ServeSuccessJSON(map[string]interface{}{
  33085. "failed_code": -10,
  33086. "msg": res2.ErrMsg,
  33087. })
  33088. }
  33089. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33090. 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, "")
  33091. var dat map[string]interface{}
  33092. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33093. fmt.Println(dat)
  33094. } else {
  33095. fmt.Println(err)
  33096. }
  33097. saveLog(result2, src_request, "2205", "撤销明细")
  33098. userJSONBytes, _ := json.Marshal(dat)
  33099. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33100. utils.ErrorLog("解析失败:%v", err)
  33101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33102. return
  33103. }
  33104. if res2.Infcode == 0 {
  33105. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33106. if err == nil {
  33107. c.ServeSuccessJSON(map[string]interface{}{
  33108. "msg": "撤销明细成功",
  33109. })
  33110. return
  33111. } else {
  33112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33113. return
  33114. }
  33115. } else {
  33116. c.ServeSuccessJSON(map[string]interface{}{
  33117. "failed_code": -10,
  33118. "msg": res2.ErrMsg,
  33119. })
  33120. }
  33121. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33122. 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, "")
  33123. var dat map[string]interface{}
  33124. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33125. fmt.Println(dat)
  33126. } else {
  33127. fmt.Println(err)
  33128. }
  33129. saveLog(result2, src_request, "2205", "撤销明细")
  33130. userJSONBytes, _ := json.Marshal(dat)
  33131. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33132. utils.ErrorLog("解析失败:%v", err)
  33133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33134. return
  33135. }
  33136. if res2.Infcode == 0 {
  33137. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33138. if err == nil {
  33139. c.ServeSuccessJSON(map[string]interface{}{
  33140. "msg": "撤销明细成功",
  33141. })
  33142. return
  33143. } else {
  33144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33145. return
  33146. }
  33147. } else {
  33148. c.ServeSuccessJSON(map[string]interface{}{
  33149. "failed_code": -10,
  33150. "msg": res2.ErrMsg,
  33151. })
  33152. }
  33153. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33154. 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, "")
  33155. var dat map[string]interface{}
  33156. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33157. fmt.Println(dat)
  33158. } else {
  33159. fmt.Println(err)
  33160. }
  33161. saveLog(result2, src_request, "2205", "撤销明细")
  33162. userJSONBytes, _ := json.Marshal(dat)
  33163. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33164. utils.ErrorLog("解析失败:%v", err)
  33165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33166. return
  33167. }
  33168. if res2.Infcode == 0 {
  33169. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33170. if err == nil {
  33171. c.ServeSuccessJSON(map[string]interface{}{
  33172. "msg": "撤销明细成功",
  33173. })
  33174. return
  33175. } else {
  33176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33177. return
  33178. }
  33179. } else {
  33180. c.ServeSuccessJSON(map[string]interface{}{
  33181. "failed_code": -10,
  33182. "msg": res2.ErrMsg,
  33183. })
  33184. }
  33185. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33186. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  33187. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33188. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33189. resp2, requestErr2 := http.Get(api2)
  33190. if requestErr2 != nil {
  33191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33192. return
  33193. }
  33194. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33195. if ioErr2 != nil {
  33196. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33198. return
  33199. }
  33200. var respJSON2 map[string]interface{}
  33201. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33202. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33204. return
  33205. }
  33206. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33207. userJSONBytes3, _ := json.Marshal(respJSON2)
  33208. fmt.Println("log")
  33209. fmt.Println(string(userJSONBytes3))
  33210. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33211. utils.ErrorLog("解析失败:%v", err)
  33212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33213. return
  33214. }
  33215. if res2.Infcode == 0 {
  33216. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33217. if err == nil {
  33218. c.ServeSuccessJSON(map[string]interface{}{
  33219. "msg": "撤销明细成功",
  33220. })
  33221. return
  33222. } else {
  33223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33224. return
  33225. }
  33226. } else {
  33227. c.ServeSuccessJSON(map[string]interface{}{
  33228. "failed_code": -10,
  33229. "msg": res2.ErrMsg,
  33230. })
  33231. }
  33232. } else {
  33233. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  33234. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33235. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33236. resp2, requestErr2 := http.Get(api2)
  33237. if requestErr2 != nil {
  33238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33239. return
  33240. }
  33241. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  33242. if ioErr2 != nil {
  33243. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  33244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33245. return
  33246. }
  33247. var respJSON2 map[string]interface{}
  33248. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  33249. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33251. return
  33252. }
  33253. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33254. userJSONBytes3, _ := json.Marshal(respJSON2)
  33255. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33256. utils.ErrorLog("解析失败:%v", err)
  33257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33258. return
  33259. }
  33260. if res2.Infcode == -1 {
  33261. c.ServeSuccessJSON(map[string]interface{}{
  33262. "failed_code": -10,
  33263. "msg": res2.ErrMsg,
  33264. })
  33265. return
  33266. } else {
  33267. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33268. if err == nil {
  33269. c.ServeSuccessJSON(map[string]interface{}{
  33270. "msg": "撤销明细成功",
  33271. })
  33272. return
  33273. } else {
  33274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33275. return
  33276. }
  33277. }
  33278. }
  33279. } else {
  33280. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  33281. if err == nil {
  33282. c.ServeSuccessJSON(map[string]interface{}{
  33283. "msg": "退费成功",
  33284. })
  33285. } else {
  33286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33287. return
  33288. }
  33289. }
  33290. }
  33291. // 对账
  33292. func (c *HisApiController) GetCheckAccount() {
  33293. start_time := c.GetString("start_time")
  33294. end_time := c.GetString("end_time")
  33295. insutype := c.GetString("insutype")
  33296. clr_type := c.GetString("clr_type")
  33297. clr_org := c.GetString("clr_optins")
  33298. admin_user_id, _ := c.GetInt64("admin_user_id")
  33299. adminUser := c.GetAdminUserInfo()
  33300. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33301. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33302. if len(clr_org) == 0 {
  33303. clr_org = miConfig.InsuplcAdmdvs
  33304. }
  33305. timeLayout := "2006-01-02"
  33306. loc, _ := time.LoadLocation("Local")
  33307. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  33308. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  33309. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33310. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33311. fixmedins_setl_cnt := int64(len(orders))
  33312. var medfee_sumamt float64
  33313. var acct_pay float64
  33314. var fund_pay_sumamt float64
  33315. for _, item := range orders {
  33316. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33317. acct_pay = acct_pay + item.AcctPay
  33318. if miConfig.MdtrtareaAdmvs == "361025"{
  33319. fund_pay_sumamt = fund_pay_sumamt + item.HifpPay + item.HifmiPay + item.MafPay + item.HifobPay + item.HifesPay
  33320. }else{
  33321. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33322. }
  33323. }
  33324. var user_name string
  33325. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33326. if role.ID == 0 {
  33327. user_name = "xxx"
  33328. } else {
  33329. user_name = role.UserName
  33330. }
  33331. var res ResultEight
  33332. var res10188 ResultEightFor10188
  33333. if config.IsOpen == 1 {
  33334. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33335. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  33336. "insutype=" + insutype +
  33337. "&clr_type=" + clr_type +
  33338. "&setl_optins=" + clr_org +
  33339. "&stmt_begndate=" + start_time +
  33340. "&stm_enddate=" + end_time +
  33341. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33342. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33343. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33344. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33345. "&fixmedins_code=" + miConfig.Code +
  33346. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33347. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33348. "&secret_key=" + miConfig.SecretKey +
  33349. "&org_name=" + miConfig.OrgName +
  33350. "&doctor=" + user_name +
  33351. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33352. fmt.Println(api)
  33353. resp, requestErr := http.Get(api)
  33354. if requestErr != nil {
  33355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33356. return
  33357. }
  33358. body, ioErr := ioutil.ReadAll(resp.Body)
  33359. fmt.Println(body)
  33360. if ioErr != nil {
  33361. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33363. return
  33364. }
  33365. var respJSON map[string]interface{}
  33366. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33369. return
  33370. }
  33371. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33372. userJSONBytes, _ := json.Marshal(respJSON)
  33373. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33374. utils.ErrorLog("解析失败:%v", err)
  33375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33376. return
  33377. }
  33378. res.InfRefmsgid = res10188.InfRefmsgid
  33379. res.Output = res10188.Output
  33380. res.ErrMsg = res10188.ErrMsg
  33381. res.Cainfo = res10188.Cainfo
  33382. res.WarnMsg = res10188.WarnMsg
  33383. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  33384. res.Infcode = infocode
  33385. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33386. if clr_type != "9903" {
  33387. clr_type = "99" // 就诊 ID(来自2201接口返回)
  33388. }
  33389. if clr_type == "9903" {
  33390. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  33391. }
  33392. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  33393. "insutype=" + insutype +
  33394. "&clr_type=" + clr_type +
  33395. "&setl_optins=" + clr_org +
  33396. "&stmt_begndate=" + start_time +
  33397. "&stm_enddate=" + end_time +
  33398. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33399. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33400. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33401. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33402. "&fixmedins_code=" + miConfig.Code +
  33403. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33404. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33405. "&secret_key=" + miConfig.SecretKey +
  33406. "&org_name=" + miConfig.OrgName +
  33407. "&doctor=" + user_name
  33408. resp, requestErr := http.Get(api)
  33409. if requestErr != nil {
  33410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33411. return
  33412. }
  33413. body, ioErr := ioutil.ReadAll(resp.Body)
  33414. if ioErr != nil {
  33415. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33417. return
  33418. }
  33419. var respJSON map[string]interface{}
  33420. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33421. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33423. return
  33424. }
  33425. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33426. result, _ := json.Marshal(respJSON)
  33427. fmt.Println("log")
  33428. fmt.Println(string(result))
  33429. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  33430. utils.ErrorLog("解析失败:%v", err)
  33431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33432. return
  33433. }
  33434. res.InfRefmsgid = res10188.InfRefmsgid
  33435. res.Output = res10188.Output
  33436. res.ErrMsg = res10188.ErrMsg
  33437. res.Cainfo = res10188.Cainfo
  33438. res.WarnMsg = res10188.WarnMsg
  33439. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  33440. res.Infcode = infocode
  33441. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33442. var baseParams models.BaseParams
  33443. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33444. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33445. baseParams.SecretKey = miConfig.SecretKey
  33446. baseParams.OrgName = miConfig.OrgName
  33447. baseParams.FixmedinsCode = miConfig.Code
  33448. baseParams.EncKey = miConfig.EncKey
  33449. baseParams.AppSecret = miConfig.AppSecret
  33450. baseParams.SignKey = miConfig.SignKey
  33451. baseParams.AppID = miConfig.Code
  33452. baseParams.Doctor = role.UserName
  33453. baseParams.RequestUrl = miConfig.Url
  33454. businessParams := models.BusinessParams{
  33455. Insutype: insutype,
  33456. ClrType: clr_type,
  33457. SetlOptins: clr_org,
  33458. StmtBegndate: start_time,
  33459. StmtEnddate: end_time,
  33460. MedfeeSumamt: medfee_sumamt,
  33461. FundPaySumamt: fund_pay_sumamt,
  33462. AcctPay: acct_pay,
  33463. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33464. }
  33465. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33466. fmt.Println(requestLog)
  33467. fmt.Println(result)
  33468. fmt.Println(err_msg)
  33469. var dat map[string]interface{}
  33470. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33471. fmt.Println(dat)
  33472. } else {
  33473. fmt.Println(err)
  33474. }
  33475. userJSONBytes, _ := json.Marshal(dat)
  33476. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33477. utils.ErrorLog("解析失败:%v", err)
  33478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33479. return
  33480. }
  33481. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33482. var baseParams models.BaseParams
  33483. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33484. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33485. baseParams.SecretKey = miConfig.SecretKey
  33486. baseParams.OrgName = miConfig.OrgName
  33487. baseParams.FixmedinsCode = miConfig.Code
  33488. baseParams.EncKey = miConfig.EncKey
  33489. baseParams.AppSecret = miConfig.AppSecret
  33490. baseParams.SignKey = miConfig.SignKey
  33491. baseParams.AppID = miConfig.Code
  33492. baseParams.Doctor = role.UserName
  33493. baseParams.RequestUrl = miConfig.Url
  33494. baseParams.AccessKey = miConfig.AccessKey
  33495. businessParams := models.BusinessParams{
  33496. Insutype: insutype,
  33497. ClrType: clr_type,
  33498. SetlOptins: "430822",
  33499. StmtBegndate: start_time,
  33500. StmtEnddate: end_time,
  33501. MedfeeSumamt: medfee_sumamt,
  33502. FundPaySumamt: fund_pay_sumamt,
  33503. AcctPay: acct_pay,
  33504. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33505. }
  33506. 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)
  33507. fmt.Println(requestLog)
  33508. fmt.Println(result)
  33509. var dat map[string]interface{}
  33510. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33511. fmt.Println(dat)
  33512. } else {
  33513. fmt.Println(err)
  33514. }
  33515. userJSONBytes, _ := json.Marshal(dat)
  33516. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33517. utils.ErrorLog("解析失败:%v", err)
  33518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33519. return
  33520. }
  33521. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33522. var baseParams models.BaseParams
  33523. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33524. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33525. baseParams.SecretKey = miConfig.SecretKey
  33526. baseParams.OrgName = miConfig.OrgName
  33527. baseParams.FixmedinsCode = miConfig.Code
  33528. baseParams.EncKey = miConfig.EncKey
  33529. baseParams.AppSecret = miConfig.AppSecret
  33530. baseParams.SignKey = miConfig.SignKey
  33531. baseParams.AppID = miConfig.Code
  33532. baseParams.Doctor = role.UserName
  33533. baseParams.RequestUrl = miConfig.Url
  33534. businessParams := models.BusinessParams{
  33535. Insutype: insutype,
  33536. ClrType: clr_type,
  33537. SetlOptins: clr_org,
  33538. StmtBegndate: start_time,
  33539. StmtEnddate: end_time,
  33540. MedfeeSumamt: medfee_sumamt,
  33541. FundPaySumamt: fund_pay_sumamt,
  33542. AcctPay: acct_pay,
  33543. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33544. }
  33545. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  33546. fmt.Println(requestLog)
  33547. fmt.Println(result)
  33548. fmt.Println(err_msg)
  33549. var dat map[string]interface{}
  33550. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33551. fmt.Println(dat)
  33552. } else {
  33553. fmt.Println(err)
  33554. }
  33555. userJSONBytes, _ := json.Marshal(dat)
  33556. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33557. utils.ErrorLog("解析失败:%v", err)
  33558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33559. return
  33560. }
  33561. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33562. if len(clr_type) == 0 {
  33563. clr_type = "11"
  33564. }
  33565. api := miConfig.Url + "gdyb/ten?" +
  33566. "insutype=" + insutype +
  33567. "&clr_type=" + clr_type +
  33568. "&setl_optins=" + clr_org +
  33569. "&stmt_begndate=" + start_time +
  33570. "&stm_enddate=" + end_time +
  33571. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33572. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33573. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33574. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33575. "&fixmedins_code=" + miConfig.Code +
  33576. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33577. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33578. "&secret_key=" + miConfig.SecretKey +
  33579. "&org_name=" + miConfig.OrgName +
  33580. "&doctor=" + user_name
  33581. fmt.Println(api)
  33582. resp, requestErr := http.Get(api)
  33583. if requestErr != nil {
  33584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33585. return
  33586. }
  33587. body, ioErr := ioutil.ReadAll(resp.Body)
  33588. fmt.Println(body)
  33589. if ioErr != nil {
  33590. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33592. return
  33593. }
  33594. var respJSON map[string]interface{}
  33595. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33596. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33598. return
  33599. }
  33600. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33601. userJSONBytes, _ := json.Marshal(respJSON)
  33602. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33603. utils.ErrorLog("解析失败:%v", err)
  33604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33605. return
  33606. }
  33607. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33608. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33609. //fixmedins_setl_cnt := int64(len(orders_two))
  33610. //var medfee_sumamt float64
  33611. //var acct_pay float64
  33612. //var fund_pay_sumamt float64
  33613. //for _, item := range orders_two {
  33614. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33615. // acct_pay = acct_pay + item.AcctPay
  33616. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33617. //}
  33618. var baseParams models.BaseParams
  33619. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33620. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33621. baseParams.SecretKey = miConfig.SecretKey
  33622. baseParams.OrgName = miConfig.OrgName
  33623. baseParams.FixmedinsCode = miConfig.Code
  33624. baseParams.EncKey = miConfig.EncKey
  33625. baseParams.AppSecret = miConfig.AppSecret
  33626. baseParams.SignKey = miConfig.SignKey
  33627. baseParams.AppID = miConfig.Code
  33628. baseParams.Doctor = role.UserName
  33629. baseParams.RequestUrl = miConfig.Url
  33630. if clr_type == "9903" {
  33631. clr_type = "9994"
  33632. }
  33633. businessParams := models.BusinessParams{
  33634. Insutype: insutype,
  33635. ClrType: clr_type,
  33636. SetlOptins: "360302",
  33637. StmtBegndate: start_time,
  33638. StmtEnddate: end_time,
  33639. MedfeeSumamt: 0,
  33640. FundPaySumamt: 0,
  33641. AcctPay: 0,
  33642. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33643. }
  33644. 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))
  33645. fmt.Println(requestLog)
  33646. fmt.Println(result)
  33647. var dat map[string]interface{}
  33648. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33649. fmt.Println(dat)
  33650. } else {
  33651. fmt.Println(err)
  33652. }
  33653. userJSONBytes, _ := json.Marshal(dat)
  33654. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33655. utils.ErrorLog("解析失败:%v", err)
  33656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33657. return
  33658. }
  33659. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33660. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  33661. //fixmedins_setl_cnt := int64(len(orders_two))
  33662. //var medfee_sumamt float64
  33663. //var acct_pay float64
  33664. //var fund_pay_sumamt float64
  33665. //for _, item := range orders_two {
  33666. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  33667. // acct_pay = acct_pay + item.AcctPay
  33668. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  33669. //}
  33670. var baseParams models.BaseParams
  33671. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  33672. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  33673. baseParams.SecretKey = miConfig.SecretKey
  33674. baseParams.OrgName = miConfig.OrgName
  33675. baseParams.FixmedinsCode = miConfig.Code
  33676. baseParams.EncKey = miConfig.EncKey
  33677. baseParams.AppSecret = miConfig.AppSecret
  33678. baseParams.SignKey = miConfig.SignKey
  33679. baseParams.AppID = miConfig.Code
  33680. baseParams.Doctor = role.UserName
  33681. baseParams.RequestUrl = miConfig.Url
  33682. if clr_type == "9903" {
  33683. clr_type = "9994"
  33684. }
  33685. businessParams := models.BusinessParams{
  33686. Insutype: insutype,
  33687. ClrType: clr_type,
  33688. SetlOptins: "361025",
  33689. StmtBegndate: start_time,
  33690. StmtEnddate: end_time,
  33691. MedfeeSumamt: 0,
  33692. FundPaySumamt: 0,
  33693. AcctPay: 0,
  33694. FixmedinsSetlCnt: fixmedins_setl_cnt,
  33695. }
  33696. 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))
  33697. fmt.Println(requestLog)
  33698. fmt.Println(result)
  33699. var dat map[string]interface{}
  33700. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33701. fmt.Println(dat)
  33702. } else {
  33703. fmt.Println(err)
  33704. }
  33705. userJSONBytes, _ := json.Marshal(dat)
  33706. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33707. utils.ErrorLog("解析失败:%v", err)
  33708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33709. return
  33710. }
  33711. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33712. var api string
  33713. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33714. "&clr_type=" + clr_type +
  33715. "&setl_optins=" + clr_org +
  33716. "&stmt_begndate=" + start_time +
  33717. "&stm_enddate=" + end_time +
  33718. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33719. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33720. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33721. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33722. "&fixmedins_code=" + miConfig.Code +
  33723. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33724. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33725. "&secret_key=" + miConfig.SecretKey +
  33726. "&org_name=" + miConfig.OrgName +
  33727. "&doctor=" + user_name + "&url=" + miConfig.Url
  33728. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33729. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33730. resp, requestErr := http.Get(api)
  33731. if requestErr != nil {
  33732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33733. return
  33734. }
  33735. body, ioErr := ioutil.ReadAll(resp.Body)
  33736. if ioErr != nil {
  33737. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33739. return
  33740. }
  33741. var respJSON map[string]interface{}
  33742. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33743. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33745. return
  33746. }
  33747. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33748. if status == "0" {
  33749. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33750. c.ServeSuccessJSON(map[string]interface{}{
  33751. "failed_code": -10,
  33752. "msg": err_msg,
  33753. })
  33754. return
  33755. }
  33756. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33757. userJSONBytes, _ := json.Marshal(respJSON)
  33758. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33759. utils.ErrorLog("解析失败:%v", err)
  33760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33761. return
  33762. }
  33763. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33764. var api string
  33765. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  33766. "&clr_type=" + clr_type +
  33767. "&setl_optins=" + clr_org +
  33768. "&stmt_begndate=" + start_time +
  33769. "&stm_enddate=" + end_time +
  33770. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33771. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33772. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33773. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  33774. "&fixmedins_code=" + miConfig.Code +
  33775. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33776. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33777. "&secret_key=" + miConfig.SecretKey +
  33778. "&org_name=" + miConfig.OrgName +
  33779. "&doctor=" + user_name + "&url=" + miConfig.Url
  33780. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33781. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33782. resp, requestErr := http.Get(api)
  33783. if requestErr != nil {
  33784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33785. return
  33786. }
  33787. body, ioErr := ioutil.ReadAll(resp.Body)
  33788. if ioErr != nil {
  33789. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33791. return
  33792. }
  33793. var respJSON map[string]interface{}
  33794. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33795. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33797. return
  33798. }
  33799. status := respJSON["data"].(map[string]interface{})["status"].(string)
  33800. if status == "0" {
  33801. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  33802. c.ServeSuccessJSON(map[string]interface{}{
  33803. "failed_code": -10,
  33804. "msg": err_msg,
  33805. })
  33806. return
  33807. }
  33808. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33809. userJSONBytes, _ := json.Marshal(respJSON)
  33810. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33811. utils.ErrorLog("解析失败:%v", err)
  33812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33813. return
  33814. }
  33815. } else {
  33816. if len(clr_type) == 0 {
  33817. clr_type = "11"
  33818. }
  33819. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33820. "insutype=" + insutype +
  33821. "&clr_type=" + clr_type +
  33822. "&setl_optins=" + clr_org +
  33823. "&stmt_begndate=" + start_time +
  33824. "&stm_enddate=" + end_time +
  33825. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  33826. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  33827. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  33828. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  33829. "&fixmedins_code=" + miConfig.Code +
  33830. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33831. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33832. "&secret_key=" + miConfig.SecretKey +
  33833. "&org_name=" + miConfig.OrgName +
  33834. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  33835. fmt.Println(api)
  33836. resp, requestErr := http.Get(api)
  33837. if requestErr != nil {
  33838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33839. return
  33840. }
  33841. body, ioErr := ioutil.ReadAll(resp.Body)
  33842. fmt.Println(body)
  33843. if ioErr != nil {
  33844. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33846. return
  33847. }
  33848. var respJSON map[string]interface{}
  33849. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33850. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33852. return
  33853. }
  33854. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33855. userJSONBytes, _ := json.Marshal(respJSON)
  33856. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33857. utils.ErrorLog("解析失败:%v", err)
  33858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33859. return
  33860. }
  33861. }
  33862. if res.Infcode == 0 {
  33863. if res.Output.Stmtinfo.StmtRslt == "0" {
  33864. micc := &models.MedicalInsuranceCostCompare{
  33865. StartTime: startime.Unix(),
  33866. EndTime: endtime.Unix(),
  33867. Insutype: insutype,
  33868. CheckType: 1,
  33869. Num: fixmedins_setl_cnt,
  33870. Mtime: time.Now().Unix(),
  33871. Status: 1,
  33872. UserOrgId: adminUser.CurrentOrgId,
  33873. CostTotal: medfee_sumamt,
  33874. FuncTotal: fund_pay_sumamt,
  33875. PsnPay: acct_pay,
  33876. Creator: admin_user_id,
  33877. Ctime: time.Now().Unix(),
  33878. ClrType: clr_type,
  33879. }
  33880. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  33881. if err == nil {
  33882. c.ServeSuccessJSON(map[string]interface{}{
  33883. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33884. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33885. })
  33886. } else {
  33887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33888. }
  33889. } else {
  33890. c.ServeSuccessJSON(map[string]interface{}{
  33891. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  33892. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  33893. })
  33894. }
  33895. } else {
  33896. c.ServeSuccessJSON(map[string]interface{}{
  33897. "failed_code": -10,
  33898. "msg": res.ErrMsg,
  33899. })
  33900. }
  33901. }
  33902. }
  33903. func (c *HisApiController) Check310() {
  33904. adminUser := c.GetAdminUserInfo()
  33905. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33906. var user_name string
  33907. user_name = "高慧裕"
  33908. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33909. "insutype=" + "310" +
  33910. "&clr_type=" + "" +
  33911. "&setl_optins=" + "441202" +
  33912. "&stmt_begndate=" + "2022-03-01" +
  33913. "&stm_enddate=" + "2022-03-31" +
  33914. "&medfee_sumamt=" + "194930.12" +
  33915. "&fund_pay_sumamt=" + "188741.46" +
  33916. "&acct_pay=" + "0" +
  33917. "&fixmedins_setl_cnt=" + "452" +
  33918. "&fixmedins_code=" + miConfig.Code +
  33919. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33920. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33921. "&secret_key=" + miConfig.SecretKey +
  33922. "&org_name=" + miConfig.OrgName +
  33923. "&doctor=" + user_name
  33924. fmt.Println(api)
  33925. resp, requestErr := http.Get(api)
  33926. if requestErr != nil {
  33927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33928. return
  33929. }
  33930. body, ioErr := ioutil.ReadAll(resp.Body)
  33931. fmt.Println(body)
  33932. if ioErr != nil {
  33933. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33935. return
  33936. }
  33937. var respJSON map[string]interface{}
  33938. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33939. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33941. return
  33942. }
  33943. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33944. userJSONBytes, _ := json.Marshal(respJSON)
  33945. var res ResultEight
  33946. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33947. utils.ErrorLog("解析失败:%v", err)
  33948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33949. return
  33950. }
  33951. }
  33952. func (c *HisApiController) Check390() {
  33953. adminUser := c.GetAdminUserInfo()
  33954. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33955. var user_name string
  33956. user_name = "高慧裕"
  33957. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  33958. "insutype=" + "390" +
  33959. "&clr_type=" + "" +
  33960. "&setl_optins=" + "441202" +
  33961. "&stmt_begndate=" + "2022-03-01" +
  33962. "&stm_enddate=" + "2022-03-31" +
  33963. "&medfee_sumamt=" + "1068448.89" +
  33964. "&fund_pay_sumamt=" + "1014677.62" +
  33965. "&acct_pay=" + "0" +
  33966. "&fixmedins_setl_cnt=" + "1950" +
  33967. "&fixmedins_code=" + miConfig.Code +
  33968. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  33969. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  33970. "&secret_key=" + miConfig.SecretKey +
  33971. "&org_name=" + miConfig.OrgName +
  33972. "&doctor=" + user_name
  33973. fmt.Println(api)
  33974. resp, requestErr := http.Get(api)
  33975. if requestErr != nil {
  33976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33977. return
  33978. }
  33979. body, ioErr := ioutil.ReadAll(resp.Body)
  33980. fmt.Println(body)
  33981. if ioErr != nil {
  33982. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33984. return
  33985. }
  33986. var respJSON map[string]interface{}
  33987. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33990. return
  33991. }
  33992. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33993. userJSONBytes, _ := json.Marshal(respJSON)
  33994. var res ResultEight
  33995. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33996. utils.ErrorLog("解析失败:%v", err)
  33997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33998. return
  33999. }
  34000. }
  34001. // 对账明细
  34002. func (c *HisApiController) GetCheckDetailAccount() {
  34003. start_time := c.GetString("start_time")
  34004. end_time := c.GetString("end_time")
  34005. admin_user_id, _ := c.GetInt64("admin_user_id")
  34006. adminUser := c.GetAdminUserInfo()
  34007. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34008. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34009. timeLayout := "2006-01-02"
  34010. loc, _ := time.LoadLocation("Local")
  34011. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  34012. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  34013. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34014. rand.Seed(time.Now().UnixNano())
  34015. num := rand.Intn(30000)
  34016. Mkdir(miConfig.OrgName)
  34017. file := strconv.FormatInt(int64(num), 10)
  34018. file_name := file + ".txt"
  34019. zip_name := file + ".zip"
  34020. zip_path := miConfig.OrgName + "/" + zip_name
  34021. file_path := miConfig.OrgName + "/" + file_name
  34022. decimal.DivisionPrecision = 2
  34023. var medfee_sumamt float64
  34024. var psn_cash_pay float64
  34025. var fund_pay_sumamt float64
  34026. fixmedins_setl_cnt := int64(len(orders))
  34027. for _, item := range orders {
  34028. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34029. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  34030. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34031. }
  34032. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  34033. defer f.Close()
  34034. if err != nil {
  34035. fmt.Println(err.Error())
  34036. } else {
  34037. for _, item := range orders {
  34038. var refd_setl_flag string
  34039. if item.OrderStatus == 2 {
  34040. refd_setl_flag = "0"
  34041. var str string
  34042. str = item.SetlId + " " +
  34043. item.MdtrtId + " " +
  34044. item.PsnNo + " " +
  34045. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  34046. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  34047. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  34048. _, err = f.Write([]byte(str))
  34049. }
  34050. if item.OrderStatus == 3 {
  34051. var str string
  34052. str = item.SetlId + " " +
  34053. item.MdtrtId + " " +
  34054. item.PsnNo + " " +
  34055. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  34056. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  34057. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  34058. _, err = f.Write([]byte(str))
  34059. var str2 string
  34060. str2 = item.SetlId + " " +
  34061. item.MdtrtId + " " +
  34062. item.PsnNo + " " +
  34063. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  34064. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  34065. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  34066. _, err = f.Write([]byte(str2))
  34067. }
  34068. }
  34069. }
  34070. Zip(file_path, zip_path)
  34071. fmt.Println(ReadFile(zip_path))
  34072. fmt.Println(string(ReadFile(zip_path)))
  34073. if config.IsOpen == 1 {
  34074. var user_name string
  34075. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34076. if role.ID == 0 {
  34077. user_name = "管理员"
  34078. } else {
  34079. user_name = role.UserName
  34080. }
  34081. baseParams := models.BaseParams{
  34082. SecretKey: miConfig.SecretKey,
  34083. FixmedinsCode: miConfig.Code,
  34084. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34085. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34086. OrgName: miConfig.OrgName,
  34087. Doctor: user_name,
  34088. }
  34089. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  34090. var dat map[string]interface{}
  34091. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34092. fmt.Println(dat)
  34093. } else {
  34094. fmt.Println(err)
  34095. }
  34096. userJSONBytes, _ := json.Marshal(dat)
  34097. var res ResultNine
  34098. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34099. utils.ErrorLog("解析失败:%v", err)
  34100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34101. return
  34102. }
  34103. if res.Infcode == 0 {
  34104. fileNo := res.Output.FileQuryNo
  34105. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  34106. "file_qury_no=" + fileNo +
  34107. "&setl_optins=" + "定点医保中心" +
  34108. "&stmt_begndate=" + start_time +
  34109. "&stm_enddate=" + end_time +
  34110. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  34111. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  34112. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  34113. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  34114. "&fixmedins_code=" + miConfig.Code +
  34115. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  34116. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  34117. "&secret_key=" + miConfig.SecretKey +
  34118. "&org_name=" + miConfig.OrgName +
  34119. "&doctor=" + user_name
  34120. resp, requestErr := http.Get(api)
  34121. if requestErr != nil {
  34122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34123. return
  34124. }
  34125. body, ioErr := ioutil.ReadAll(resp.Body)
  34126. if ioErr != nil {
  34127. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34129. return
  34130. }
  34131. var respJSON map[string]interface{}
  34132. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34133. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34135. return
  34136. }
  34137. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34138. userJSONBytes, _ := json.Marshal(respJSON)
  34139. var res ResultTen
  34140. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34141. utils.ErrorLog("解析失败:%v", err)
  34142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34143. return
  34144. }
  34145. if res.Infcode == 0 {
  34146. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  34147. micc := &models.MedicalInsuranceCostCompare{
  34148. StartTime: startime.Unix(),
  34149. EndTime: endtime.Unix(),
  34150. Insutype: "0",
  34151. CheckType: 2,
  34152. Num: fixmedins_setl_cnt,
  34153. Mtime: time.Now().Unix(),
  34154. Status: 1,
  34155. UserOrgId: adminUser.CurrentOrgId,
  34156. CostTotal: medfee_sumamt,
  34157. FuncTotal: fund_pay_sumamt,
  34158. PsnPay: psn_cash_pay,
  34159. Creator: admin_user_id,
  34160. Ctime: time.Now().Unix(),
  34161. }
  34162. service.CreateMedicalInsuranceCostCompareRecord(micc)
  34163. c.ServeSuccessJSON(map[string]interface{}{
  34164. "msg": "明细对账成功",
  34165. })
  34166. }
  34167. } else {
  34168. }
  34169. }
  34170. }
  34171. type CustomOrderInfo struct {
  34172. Name string
  34173. Spec string
  34174. Unit string
  34175. Count float64
  34176. Price float64
  34177. Total float64
  34178. }
  34179. func (c *HisApiController) GetBatchSettleAccounts() {
  34180. admin_user_id, _ := c.GetInt64("admin_user_id")
  34181. order_ids := c.GetString("order_ids")
  34182. order_ids_arr := strings.Split(order_ids, ",")
  34183. data3 := []map[string]interface{}{}
  34184. for _, item := range order_ids_arr {
  34185. id, _ := strconv.ParseInt(item, 10, 64)
  34186. order_id := id
  34187. adminUser := c.GetAdminUserInfo()
  34188. order, _ := service.GetHisOrderByID(order_id)
  34189. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34190. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34191. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34192. orderInfos = append(orderInfos, orderInfos_two...)
  34193. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34194. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34195. var diagnosis_ids []string
  34196. if his.ID > 0 {
  34197. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34198. } else {
  34199. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34200. }
  34201. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34202. var dia_config []*models.HisXtDiagnoseConfig
  34203. var name string
  34204. for _, item := range diagnosis_ids {
  34205. id, _ := strconv.ParseInt(item, 10, 64)
  34206. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34207. dia_config = append(dia_config, &diagnosisConfig)
  34208. if len(name) == 0 {
  34209. name = diagnosisConfig.ClassName
  34210. }
  34211. //} else {
  34212. // name = name + "," + diagnosisConfig.ClassName
  34213. //}
  34214. }
  34215. var bedCostTotal float64 = 0 //床位总费
  34216. var bedCostSelfTotal float64 = 0 //床位自费
  34217. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34218. var bedSelfTotal float64 = 0 //床位部分项目自费
  34219. var bedInscpTotal float64 = 0 //床位部分项目自费
  34220. var operationCostTotal float64 = 0 //手术费
  34221. var operationCostSelfTotal float64 = 0 //手术费
  34222. var operationCostPartSelfTotal float64 = 0 //手术费
  34223. var operationSelfTotal float64 = 0 //床位部分项目自费
  34224. var operationInscpTotal float64 = 0 //床位部分项目自费
  34225. var otherCostTotal float64 = 0 //其他费用
  34226. var otherCostSelfTotal float64 = 0 //其他费用
  34227. var otherCostPartSelfTotal float64 = 0 //其他费用
  34228. var otherSelfTotal float64 = 0 //床位部分项目自费
  34229. var otherInscpTotal float64 = 0 //床位部分项目自费
  34230. var materialCostTotal float64 = 0 //材料费
  34231. var materialCostSelfTotal float64 = 0 //材料费
  34232. var materialCostPartSelfTotal float64 = 0 //材料费
  34233. var materialSelfTotal float64 = 0 //床位部分项目自费
  34234. var materialInscpTotal float64 = 0 //床位部分项目自费
  34235. var westernMedicineCostTotal float64 = 0 //西药费
  34236. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34237. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34238. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34239. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34240. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34241. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34242. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34243. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34244. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34245. var checkCostTotal float64 = 0 //检查费
  34246. var checkCostSelfTotal float64 = 0 //检查费
  34247. var checkCostPartSelfTotal float64 = 0 //检查费
  34248. var checkSelfTotal float64 = 0 //床位部分项目自费
  34249. var checkInscpTotal float64 = 0 //床位部分项目自费
  34250. var laboratoryCostTotal float64 = 0 //化验费
  34251. var laboratoryCostSelfTotal float64 = 0 //化验费
  34252. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34253. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34254. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34255. var treatCostTotal float64 = 0 //治疗费用
  34256. var treatCostSelfTotal float64 = 0 //治疗费用
  34257. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34258. var treatSelfTotal float64 = 0 //床位部分项目自费
  34259. var treatInscpTotal float64 = 0 //床位部分项目自费
  34260. decimal.DivisionPrecision = 2
  34261. for _, item := range orderInfos {
  34262. if item.MedChrgitmType == "01" { //床位费
  34263. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34264. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34265. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34266. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34267. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34268. }
  34269. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34270. if item.MedChrgitmType == "03" { //检查费
  34271. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34272. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34273. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34274. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34275. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34276. }
  34277. } else {
  34278. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34279. fmt.Println("------------")
  34280. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34281. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34282. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34283. }
  34284. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34285. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34286. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34287. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34288. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34289. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34290. }
  34291. }
  34292. if item.MedChrgitmType == "04" { //化验费
  34293. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34294. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34295. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34296. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34297. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34298. }
  34299. if item.MedChrgitmType == "05" { //治疗费
  34300. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34301. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34302. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34303. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34304. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34305. }
  34306. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34307. fmt.Println("------------")
  34308. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34309. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34310. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34311. }
  34312. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34313. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34314. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34315. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34316. }
  34317. //if item.MedChrgitmType == "06" { //手术费
  34318. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34319. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34320. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34321. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34322. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34323. //
  34324. //}
  34325. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34326. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34327. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34328. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34329. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34330. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34331. }
  34332. if item.MedChrgitmType == "09" { //西药费
  34333. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34334. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34335. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34336. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34337. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34338. }
  34339. if item.MedChrgitmType == "11" { //中成费
  34340. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34341. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34342. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34343. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34344. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34345. }
  34346. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  34347. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34348. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34349. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34350. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34351. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34352. }
  34353. }
  34354. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34355. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34356. var user_name string
  34357. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34358. if role.ID == 0 {
  34359. user_name = "管理员"
  34360. } else {
  34361. user_name = role.UserName
  34362. }
  34363. baseParams := models.BaseParams{
  34364. SecretKey: miConfig.SecretKey,
  34365. FixmedinsCode: miConfig.Code,
  34366. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34367. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34368. OrgName: miConfig.OrgName,
  34369. Doctor: user_name,
  34370. RequestUrl: miConfig.Url,
  34371. AccessKey: miConfig.AccessKey,
  34372. }
  34373. businessParams := models.BusinessParams{
  34374. PsnNo: order.PsnNo,
  34375. MdtrtId: order.MdtrtId,
  34376. SetlId: order.SetlId,
  34377. }
  34378. var res ResultEleven
  34379. var resEleven10265 ResultEleven10265
  34380. if config.IsOpen == 1 {
  34381. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34382. result := service.Gdyb5203(baseParams, businessParams)
  34383. service.Gdyb5204(baseParams, businessParams)
  34384. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  34385. var dat map[string]interface{}
  34386. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34387. fmt.Println(dat)
  34388. } else {
  34389. fmt.Println(err)
  34390. }
  34391. userJSONBytes, _ := json.Marshal(dat)
  34392. if miConfig.Code == "H15049901371" {
  34393. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  34394. utils.ErrorLog("解析失败:%v", err)
  34395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34396. return
  34397. }
  34398. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34399. res.Output = resEleven10265.Output
  34400. res.ErrMsg = resEleven10265.ErrMsg
  34401. res.Cainfo = resEleven10265.Cainfo
  34402. res.WarnMsg = resEleven10265.WarnMsg
  34403. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34404. res.Infcode = infocode
  34405. } else {
  34406. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34407. utils.ErrorLog("解析失败:%v", err)
  34408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34409. return
  34410. }
  34411. }
  34412. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34413. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  34414. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  34415. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  34416. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  34417. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34418. var doctor_name string
  34419. if roles.ID == 0 {
  34420. doctor_name = "管理员"
  34421. } else {
  34422. doctor_name = roles.UserName
  34423. }
  34424. yiliao_leibie := ""
  34425. switch order.MedType {
  34426. case "11":
  34427. yiliao_leibie = "普通门诊"
  34428. break
  34429. case "12":
  34430. yiliao_leibie = "门诊挂号"
  34431. break
  34432. case "13":
  34433. yiliao_leibie = "急诊"
  34434. break
  34435. case "14":
  34436. yiliao_leibie = "门诊特殊病"
  34437. break
  34438. case "15":
  34439. yiliao_leibie = "门诊统筹"
  34440. break
  34441. case "16":
  34442. yiliao_leibie = "门诊慢性病"
  34443. break
  34444. case "21":
  34445. yiliao_leibie = "普通住院"
  34446. break
  34447. }
  34448. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  34449. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  34450. if res.Infcode == 0 {
  34451. data2 := map[string]interface{}{
  34452. "diagnosis": name,
  34453. "order_infos": orderInfos,
  34454. "number": order.MdtrtId,
  34455. "date": order.SettleAccountsDate,
  34456. "charge_admin": charge_admin,
  34457. "printor_admin": printor_admin,
  34458. "info": res.Output.Setlinfo,
  34459. "order": order,
  34460. "bedCostTotal": bedCostTotal,
  34461. "bedCostSelfTotal": bedCostSelfTotal,
  34462. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  34463. "bedSelfTotal": bedSelfTotal,
  34464. "bedInscpTotal": bedInscpTotal,
  34465. "operationCostTotal": operationCostTotal,
  34466. "operationCostSelfTotal": operationCostSelfTotal,
  34467. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  34468. "operationSelfTotal": operationSelfTotal,
  34469. "operationInscpTotal": operationInscpTotal,
  34470. "otherCostTotal": otherCostTotal,
  34471. "otherCostSelfTotal": otherCostSelfTotal,
  34472. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  34473. "otherSelfTotal": otherSelfTotal,
  34474. "otherInscpTotal": otherInscpTotal,
  34475. "materialCostTotal": materialCostTotal,
  34476. "materialCostSelfTotal": materialCostSelfTotal,
  34477. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  34478. "materialSelfTotal": materialSelfTotal,
  34479. "materialInscpTotal": materialInscpTotal,
  34480. "westernMedicineCostTotal": westernMedicineCostTotal,
  34481. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  34482. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  34483. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  34484. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  34485. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  34486. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  34487. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  34488. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  34489. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  34490. "checkCostTotal": checkCostTotal,
  34491. "checkCostSelfTotal": checkCostSelfTotal,
  34492. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  34493. "checkSelfTotal": checkSelfTotal,
  34494. "checkInscpTotal": checkInscpTotal,
  34495. "laboratoryCostTotal": laboratoryCostTotal,
  34496. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  34497. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  34498. "laboratorySelfTotal": laboratorySelfTotal,
  34499. "laboratoryInscpTotal": laboratoryInscpTotal,
  34500. "treatCostTotal": treatCostTotal,
  34501. "treatCostSelfTotal": treatCostSelfTotal,
  34502. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  34503. "treatSelfTotal": treatSelfTotal,
  34504. "treatInscpTotal": treatInscpTotal,
  34505. "doctor_info": doctor_info,
  34506. "doctor_code": adminRole_two.DoctorCode,
  34507. "doctor_name": doctor_name,
  34508. "health_card_no": order.PsnNo,
  34509. "department": departments.Name,
  34510. "yiliao_leibie": yiliao_leibie,
  34511. "after_money": order.AccountPrice,
  34512. "patient": patient,
  34513. "org_name": miConfig.OrgName,
  34514. "org_code": miConfig.Code,
  34515. "order_number": order.Number,
  34516. "his_hospital": his_hospital,
  34517. "his": his,
  34518. "dia_config": dia_config,
  34519. "psn_cash_pay": order.PsnCashPay,
  34520. //"check_order_info": cus_slice,
  34521. }
  34522. data3 = append(data3, data2)
  34523. }
  34524. }
  34525. }
  34526. c.ServeSuccessJSON(map[string]interface{}{
  34527. "infos": data3,
  34528. })
  34529. }
  34530. func (c *HisApiController) GetSettleAccounts() {
  34531. //id, _ := c.GetInt64("id")
  34532. //record_time := c.GetString("record_time")
  34533. order_id, _ := c.GetInt64("order_id")
  34534. admin_user_id, _ := c.GetInt64("admin_user_id")
  34535. //timeLayout := "2006-01-02"
  34536. //loc, _ := time.LoadLocation("Local")
  34537. //
  34538. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34539. //if err != nil {
  34540. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34541. // return
  34542. //}Hbyb5203
  34543. //recordDateTime := theTime.Unix()
  34544. adminUser := c.GetAdminUserInfo()
  34545. order, _ := service.GetHisOrderByID(order_id)
  34546. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34547. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  34548. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  34549. orderInfos = append(orderInfos, orderInfos_two...)
  34550. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  34551. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  34552. var diagnosis_ids []string
  34553. if his.ID > 0 {
  34554. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  34555. } else {
  34556. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  34557. }
  34558. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  34559. var dia_config []*models.HisXtDiagnoseConfig
  34560. var name string
  34561. for _, item := range diagnosis_ids {
  34562. id, _ := strconv.ParseInt(item, 10, 64)
  34563. diagnosisConfig, _ := service.FindDiagnoseById(id)
  34564. dia_config = append(dia_config, &diagnosisConfig)
  34565. if len(name) == 0 {
  34566. name = diagnosisConfig.ClassName
  34567. } else {
  34568. name = name + "," + diagnosisConfig.ClassName
  34569. }
  34570. }
  34571. if patient.UserOrgId == 10215 {
  34572. name = "慢性肾功能不全(血透治疗)"
  34573. }
  34574. var bedCostTotal float64 = 0 //床位总费
  34575. var bedCostSelfTotal float64 = 0 //床位自费
  34576. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  34577. var bedSelfTotal float64 = 0 //床位部分项目自费
  34578. var bedInscpTotal float64 = 0 //床位部分项目自费
  34579. var operationCostTotal float64 = 0 //手术费
  34580. var operationCostSelfTotal float64 = 0 //手术费
  34581. var operationCostPartSelfTotal float64 = 0 //手术费
  34582. var operationSelfTotal float64 = 0 //床位部分项目自费
  34583. var operationInscpTotal float64 = 0 //床位部分项目自费
  34584. var otherCostTotal float64 = 0 //其他费用
  34585. var otherCostSelfTotal float64 = 0 //其他费用
  34586. var otherCostPartSelfTotal float64 = 0 //其他费用
  34587. var otherSelfTotal float64 = 0 //床位部分项目自费
  34588. var otherInscpTotal float64 = 0 //床位部分项目自费
  34589. var materialCostTotal float64 = 0 //材料费
  34590. var materialCostSelfTotal float64 = 0 //材料费
  34591. var materialCostPartSelfTotal float64 = 0 //材料费
  34592. var materialSelfTotal float64 = 0 //床位部分项目自费
  34593. var materialInscpTotal float64 = 0 //床位部分项目自费
  34594. var westernMedicineCostTotal float64 = 0 //西药费
  34595. var westernMedicineCostSelfTotal float64 = 0 //西药费
  34596. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  34597. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  34598. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  34599. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  34600. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  34601. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  34602. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  34603. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  34604. var checkCostTotal float64 = 0 //检查费
  34605. var checkCostSelfTotal float64 = 0 //检查费
  34606. var checkCostPartSelfTotal float64 = 0 //检查费
  34607. var checkSelfTotal float64 = 0 //床位部分项目自费
  34608. var checkInscpTotal float64 = 0 //床位部分项目自费
  34609. var laboratoryCostTotal float64 = 0 //化验费
  34610. var laboratoryCostSelfTotal float64 = 0 //化验费
  34611. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  34612. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  34613. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  34614. var treatCostTotal float64 = 0 //治疗费用
  34615. var treatCostSelfTotal float64 = 0 //治疗费用
  34616. var treatCostPartSelfTotal float64 = 0 //治疗费用
  34617. var treatSelfTotal float64 = 0 //床位部分项目自费
  34618. var treatInscpTotal float64 = 0 //床位部分项目自费
  34619. var zcCostTotal float64 = 0 //治疗费用
  34620. var zcCostSelfTotal float64 = 0 //治疗费用
  34621. var zcCostPartSelfTotal float64 = 0 //治疗费用
  34622. var zcSelfTotal float64 = 0 //床位部分项目自费
  34623. var zcInscpTotal float64 = 0 //床位部分项目自费
  34624. var huliCostTotal float64 = 0 //治疗费用
  34625. var huliCostSelfTotal float64 = 0 //治疗费用
  34626. var huliCostPartSelfTotal float64 = 0 //治疗费用
  34627. var huliSelfTotal float64 = 0 //床位部分项目自费
  34628. var huliInscpTotal float64 = 0 //床位部分项目自费
  34629. decimal.DivisionPrecision = 2
  34630. for _, item := range orderInfos {
  34631. if item.MedChrgitmType == "01" { //床位费
  34632. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34633. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34634. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34635. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34636. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34637. }
  34638. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  34639. if item.MedChrgitmType == "03" { //检查费
  34640. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34641. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34642. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34643. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34644. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34645. }
  34646. } else {
  34647. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  34648. fmt.Println("------------")
  34649. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34650. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34651. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34652. }
  34653. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  34654. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34655. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34656. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34657. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34658. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34659. }
  34660. }
  34661. if item.MedChrgitmType == "04" { //化验费
  34662. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34663. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34664. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34665. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34666. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34667. }
  34668. if item.MedChrgitmType == "05" { //治疗费
  34669. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34670. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34671. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34672. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34673. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34674. }
  34675. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  34676. fmt.Println("------------")
  34677. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34678. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34679. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34680. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34681. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34682. }
  34683. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  34684. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34685. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34686. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34687. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34688. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34689. }
  34690. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  34691. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34692. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34693. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34694. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34695. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34696. }
  34697. if item.MedChrgitmType == "09" { //西药费
  34698. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34699. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34700. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34701. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34702. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34703. }
  34704. if item.MedChrgitmType == "11" { //中成费
  34705. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34706. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34707. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34708. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34709. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34710. }
  34711. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  34712. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34713. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34714. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34715. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34716. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34717. }
  34718. if item.MedChrgitmType == "02" { //其他费
  34719. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34720. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34721. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34722. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34723. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34724. }
  34725. if item.MedChrgitmType == "07" { //其他费
  34726. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  34727. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  34728. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  34729. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  34730. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  34731. }
  34732. }
  34733. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34734. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34735. var user_name string
  34736. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34737. if role.ID == 0 {
  34738. user_name = "管理员"
  34739. } else {
  34740. user_name = role.UserName
  34741. }
  34742. baseParams := models.BaseParams{
  34743. SecretKey: miConfig.SecretKey,
  34744. FixmedinsCode: miConfig.Code,
  34745. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  34746. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  34747. OrgName: miConfig.OrgName,
  34748. Doctor: user_name,
  34749. RequestUrl: miConfig.Url,
  34750. AccessKey: miConfig.AccessKey,
  34751. }
  34752. businessParams := models.BusinessParams{
  34753. PsnNo: order.PsnNo,
  34754. MdtrtId: order.MdtrtId,
  34755. SetlId: order.SetlId,
  34756. }
  34757. var res ResultEleven
  34758. var resah ResultElevenah
  34759. var resEleven10265 ResultEleven10265
  34760. if config.IsOpen == 1 {
  34761. if miConfig.MdtrtareaAdmvs == "421300" {
  34762. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34763. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34764. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34765. resp, requestErr := http.Get(api)
  34766. if requestErr != nil {
  34767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34768. return
  34769. }
  34770. body, ioErr := ioutil.ReadAll(resp.Body)
  34771. if ioErr != nil {
  34772. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34774. return
  34775. }
  34776. var respJSON map[string]interface{}
  34777. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34778. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34780. return
  34781. }
  34782. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34783. result, _ := json.Marshal(respJSON)
  34784. fmt.Println("log")
  34785. fmt.Println(string(result))
  34786. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34787. utils.ErrorLog("解析失败:%v", err)
  34788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34789. return
  34790. }
  34791. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34792. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34793. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34794. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34795. resp, requestErr := http.Get(api)
  34796. if requestErr != nil {
  34797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34798. return
  34799. }
  34800. body, ioErr := ioutil.ReadAll(resp.Body)
  34801. if ioErr != nil {
  34802. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34804. return
  34805. }
  34806. var respJSON map[string]interface{}
  34807. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34810. return
  34811. }
  34812. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34813. result, _ := json.Marshal(respJSON)
  34814. fmt.Println("log")
  34815. fmt.Println(string(result))
  34816. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34817. utils.ErrorLog("解析失败:%v", err)
  34818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34819. return
  34820. }
  34821. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34822. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34823. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34824. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34825. resp, requestErr := http.Get(api)
  34826. if requestErr != nil {
  34827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34828. return
  34829. }
  34830. body, ioErr := ioutil.ReadAll(resp.Body)
  34831. if ioErr != nil {
  34832. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34834. return
  34835. }
  34836. var respJSON map[string]interface{}
  34837. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34838. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34840. return
  34841. }
  34842. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34843. result, _ := json.Marshal(respJSON)
  34844. fmt.Println("log")
  34845. fmt.Println(string(result))
  34846. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34847. utils.ErrorLog("解析失败:%v", err)
  34848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34849. return
  34850. }
  34851. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34852. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34853. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34854. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  34855. resp, requestErr := http.Get(api)
  34856. if requestErr != nil {
  34857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34858. return
  34859. }
  34860. body, ioErr := ioutil.ReadAll(resp.Body)
  34861. if ioErr != nil {
  34862. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34864. return
  34865. }
  34866. var respJSON map[string]interface{}
  34867. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34868. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34870. return
  34871. }
  34872. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34873. result, _ := json.Marshal(respJSON)
  34874. fmt.Println("log")
  34875. fmt.Println(string(result))
  34876. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34877. utils.ErrorLog("解析失败:%v", err)
  34878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34879. return
  34880. }
  34881. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34882. var api string
  34883. if miConfig.MdtrtareaAdmvs == "320921" {
  34884. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34885. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34886. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34887. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34888. } else {
  34889. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34890. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34891. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34892. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34893. }
  34894. resp, requestErr := http.Get(api)
  34895. if requestErr != nil {
  34896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34897. return
  34898. }
  34899. body, ioErr := ioutil.ReadAll(resp.Body)
  34900. if ioErr != nil {
  34901. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34903. return
  34904. }
  34905. var respJSON map[string]interface{}
  34906. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34907. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34909. return
  34910. }
  34911. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34912. result, _ := json.Marshal(respJSON)
  34913. fmt.Println("log")
  34914. fmt.Println(string(result))
  34915. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  34916. utils.ErrorLog("解析失败:%v", err)
  34917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34918. return
  34919. }
  34920. res.InfRefmsgid = resEleven10265.InfRefmsgid
  34921. res.Output = resEleven10265.Output
  34922. res.ErrMsg = resEleven10265.ErrMsg
  34923. res.Cainfo = resEleven10265.Cainfo
  34924. res.WarnMsg = resEleven10265.WarnMsg
  34925. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  34926. res.Infcode = infocode
  34927. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34928. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  34929. saveLog(result, requestLog, "5203", "结算单")
  34930. var dat map[string]interface{}
  34931. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34932. fmt.Println(dat)
  34933. } else {
  34934. fmt.Println(err)
  34935. }
  34936. userJSONBytes, _ := json.Marshal(dat)
  34937. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34938. utils.ErrorLog("解析失败:%v", err)
  34939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34940. return
  34941. }
  34942. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34943. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34944. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34945. saveLog(result, requestLog, "5203", "结算单")
  34946. var dat map[string]interface{}
  34947. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34948. fmt.Println(dat)
  34949. } else {
  34950. fmt.Println(err)
  34951. }
  34952. userJSONBytes, _ := json.Marshal(dat)
  34953. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34954. utils.ErrorLog("解析失败:%v", err)
  34955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34956. return
  34957. }
  34958. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34959. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  34960. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  34961. saveLog(result, requestLog, "5203", "结算单")
  34962. var dat map[string]interface{}
  34963. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34964. fmt.Println(dat)
  34965. } else {
  34966. fmt.Println(err)
  34967. }
  34968. userJSONBytes, _ := json.Marshal(dat)
  34969. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34970. utils.ErrorLog("解析失败:%v", err)
  34971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34972. return
  34973. }
  34974. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34975. var api string
  34976. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  34977. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  34978. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34979. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34980. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34981. resp, requestErr := http.Get(api)
  34982. if requestErr != nil {
  34983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34984. return
  34985. }
  34986. body, ioErr := ioutil.ReadAll(resp.Body)
  34987. if ioErr != nil {
  34988. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34990. return
  34991. }
  34992. var respJSON map[string]interface{}
  34993. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34994. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34996. return
  34997. }
  34998. status := respJSON["data"].(map[string]interface{})["status"].(string)
  34999. if status == "0" {
  35000. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35001. c.ServeSuccessJSON(map[string]interface{}{
  35002. "failed_code": -10,
  35003. "msg": err_msg,
  35004. })
  35005. return
  35006. }
  35007. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35008. result, _ := json.Marshal(respJSON)
  35009. fmt.Println("log")
  35010. fmt.Println(string(result))
  35011. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  35012. utils.ErrorLog("解析失败:%v", err)
  35013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35014. return
  35015. }
  35016. res.InfRefmsgid = resah.InfRefmsgid
  35017. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35018. // 创建对应的Time类型
  35019. t := time.UnixMilli(timestamp)
  35020. // 格式化成指定的日期字符串
  35021. str := t.Format("2006-01-02 15:04:05")
  35022. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35023. // 创建对应的Time类型
  35024. t3 := time.UnixMilli(timestamp2)
  35025. // 格式化成指定的日期字符串
  35026. str2 := t3.Format("2006-01-02 15:04:05")
  35027. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  35028. // 创建对应的Time类型
  35029. t4 := time.UnixMilli(timestamp3)
  35030. // 格式化成指定的日期字符串
  35031. str3 := t4.Format("2006-01-02 15:04:05")
  35032. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  35033. // 创建对应的Time类型
  35034. t5 := time.UnixMilli(timestamp4)
  35035. // 格式化成指定的日期字符串
  35036. str5 := t5.Format("2006-01-02 15:04:05")
  35037. res.Output.Setlinfo.Brdy = str2
  35038. res.Output.Setlinfo.SetlTime = str
  35039. res.Output.Setlinfo.Begndate = str3
  35040. res.Output.Setlinfo.Enddate = str5
  35041. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  35042. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  35043. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  35044. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  35045. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35046. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35047. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  35048. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  35049. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35050. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  35051. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  35052. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  35053. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  35054. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  35055. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  35056. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  35057. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  35058. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  35059. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35060. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  35061. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  35062. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35063. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  35064. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  35065. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  35066. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  35067. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  35068. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  35069. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  35070. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  35071. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  35072. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  35073. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35074. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  35075. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  35076. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  35077. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  35078. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  35079. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  35080. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  35081. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  35082. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  35083. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  35084. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  35085. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  35086. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  35087. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35088. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35089. //res.Output.Setldetail = resah.Output.Setldetail
  35090. res.ErrMsg = resah.ErrMsg
  35091. res.Cainfo = resah.Cainfo
  35092. res.WarnMsg = resah.WarnMsg
  35093. } else if miConfig.MdtrtareaAdmvs == "340699" {
  35094. var api string
  35095. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35096. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35097. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35098. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35099. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35100. resp, requestErr := http.Get(api)
  35101. if requestErr != nil {
  35102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35103. return
  35104. }
  35105. body, ioErr := ioutil.ReadAll(resp.Body)
  35106. if ioErr != nil {
  35107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35109. return
  35110. }
  35111. var respJSON map[string]interface{}
  35112. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35115. return
  35116. }
  35117. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35118. if status == "0" {
  35119. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35120. c.ServeSuccessJSON(map[string]interface{}{
  35121. "failed_code": -10,
  35122. "msg": err_msg,
  35123. })
  35124. return
  35125. }
  35126. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35127. result, _ := json.Marshal(respJSON)
  35128. fmt.Println("log")
  35129. fmt.Println(string(result))
  35130. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  35131. utils.ErrorLog("解析失败:%v", err)
  35132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35133. return
  35134. }
  35135. res.InfRefmsgid = resah.InfRefmsgid
  35136. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35137. // 创建对应的Time类型
  35138. t := time.UnixMilli(timestamp)
  35139. // 格式化成指定的日期字符串
  35140. str := t.Format("2006-01-02 15:04:05")
  35141. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  35142. // 创建对应的Time类型
  35143. t3 := time.UnixMilli(timestamp2)
  35144. // 格式化成指定的日期字符串
  35145. str2 := t3.Format("2006-01-02 15:04:05")
  35146. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  35147. // 创建对应的Time类型
  35148. t4 := time.UnixMilli(timestamp3)
  35149. // 格式化成指定的日期字符串
  35150. str3 := t4.Format("2006-01-02 15:04:05")
  35151. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  35152. // 创建对应的Time类型
  35153. t5 := time.UnixMilli(timestamp4)
  35154. // 格式化成指定的日期字符串
  35155. str5 := t5.Format("2006-01-02 15:04:05")
  35156. res.Output.Setlinfo.Brdy = str2
  35157. res.Output.Setlinfo.SetlTime = str
  35158. res.Output.Setlinfo.Begndate = str3
  35159. res.Output.Setlinfo.Enddate = str5
  35160. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  35161. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  35162. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  35163. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  35164. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35165. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35166. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  35167. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  35168. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35169. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  35170. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  35171. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  35172. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  35173. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  35174. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  35175. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  35176. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  35177. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  35178. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  35179. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  35180. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  35181. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  35182. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  35183. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  35184. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  35185. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  35186. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  35187. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  35188. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  35189. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  35190. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  35191. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  35192. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  35193. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  35194. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  35195. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  35196. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  35197. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  35198. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  35199. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  35200. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  35201. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  35202. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  35203. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  35204. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  35205. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  35206. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  35207. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  35208. //res.Output.Setldetail = resah.Output.Setldetail
  35209. res.ErrMsg = resah.ErrMsg
  35210. res.Cainfo = resah.Cainfo
  35211. res.WarnMsg = resah.WarnMsg
  35212. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35213. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  35214. saveLog(result, requestLog, "5203", "结算单")
  35215. var dat map[string]interface{}
  35216. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35217. fmt.Println(dat)
  35218. } else {
  35219. fmt.Println(err)
  35220. }
  35221. userJSONBytes, _ := json.Marshal(dat)
  35222. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35223. utils.ErrorLog("解析失败:%v", err)
  35224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35225. return
  35226. }
  35227. } else if miConfig.MdtrtareaAdmvs == "150499" {
  35228. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35229. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35230. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35231. resp, requestErr := http.Get(api)
  35232. if requestErr != nil {
  35233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35234. return
  35235. }
  35236. body, ioErr := ioutil.ReadAll(resp.Body)
  35237. if ioErr != nil {
  35238. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35240. return
  35241. }
  35242. var respJSON map[string]interface{}
  35243. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35244. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35246. return
  35247. }
  35248. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35249. result, _ := json.Marshal(respJSON)
  35250. fmt.Println("log")
  35251. fmt.Println(string(result))
  35252. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  35253. utils.ErrorLog("解析失败:%v", err)
  35254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35255. return
  35256. }
  35257. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35258. res.Output = resEleven10265.Output
  35259. res.ErrMsg = resEleven10265.ErrMsg
  35260. res.Cainfo = resEleven10265.Cainfo
  35261. res.WarnMsg = resEleven10265.WarnMsg
  35262. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35263. res.Infcode = infocode
  35264. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35265. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  35266. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  35267. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35268. resp, requestErr := http.Get(api)
  35269. if requestErr != nil {
  35270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35271. return
  35272. }
  35273. body, ioErr := ioutil.ReadAll(resp.Body)
  35274. if ioErr != nil {
  35275. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35277. return
  35278. }
  35279. var respJSON map[string]interface{}
  35280. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35281. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35283. return
  35284. }
  35285. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35286. result, _ := json.Marshal(respJSON)
  35287. if err := json.Unmarshal([]byte(result), &res); err != nil {
  35288. utils.ErrorLog("解析失败:%v", err)
  35289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35290. return
  35291. }
  35292. } else if miConfig.MdtrtareaAdmvs == "450721" {
  35293. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  35294. //return
  35295. } else {
  35296. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  35297. if len(his.InsuplcAdmdvs) == 0 {
  35298. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35299. } else {
  35300. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  35301. }
  35302. result := service.Gdyb5203(baseParams, businessParams)
  35303. //service.Gdyb5204(baseParams, businessParams)
  35304. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  35305. var dat map[string]interface{}
  35306. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35307. fmt.Println(dat)
  35308. } else {
  35309. fmt.Println(err)
  35310. }
  35311. userJSONBytes, _ := json.Marshal(dat)
  35312. if miConfig.Code == "H15049901371" {
  35313. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  35314. utils.ErrorLog("解析失败:%v", err)
  35315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35316. return
  35317. }
  35318. res.InfRefmsgid = resEleven10265.InfRefmsgid
  35319. res.Output = resEleven10265.Output
  35320. res.ErrMsg = resEleven10265.ErrMsg
  35321. res.Cainfo = resEleven10265.Cainfo
  35322. res.WarnMsg = resEleven10265.WarnMsg
  35323. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  35324. res.Infcode = infocode
  35325. } else {
  35326. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35327. utils.ErrorLog("解析失败:%v", err)
  35328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35329. return
  35330. }
  35331. }
  35332. }
  35333. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35334. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  35335. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  35336. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  35337. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  35338. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35339. var doctor_name string
  35340. if roles.ID == 0 {
  35341. doctor_name = "管理员"
  35342. } else {
  35343. doctor_name = roles.UserName
  35344. }
  35345. yiliao_leibie := ""
  35346. switch order.MedType {
  35347. case "11":
  35348. yiliao_leibie = "普通门诊"
  35349. break
  35350. case "12":
  35351. yiliao_leibie = "门诊挂号"
  35352. break
  35353. case "13":
  35354. yiliao_leibie = "急诊"
  35355. break
  35356. case "14":
  35357. yiliao_leibie = "门诊特殊病"
  35358. break
  35359. case "15":
  35360. yiliao_leibie = "门诊统筹"
  35361. break
  35362. case "16":
  35363. yiliao_leibie = "门诊慢性病"
  35364. break
  35365. case "21":
  35366. yiliao_leibie = "普通住院"
  35367. break
  35368. }
  35369. //var rf []CustomFundPay
  35370. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  35371. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35372. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  35373. if res.Infcode == 0 {
  35374. 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 {
  35375. c.ServeSuccessJSON(map[string]interface{}{
  35376. "diagnosis": name,
  35377. "order_infos": orderInfos,
  35378. "number": order.MdtrtId,
  35379. "date": order.SettleAccountsDate,
  35380. "charge_admin": charge_admin,
  35381. "printor_admin": printor_admin,
  35382. "info": res.Output.Setlinfo,
  35383. "order": order,
  35384. "bedCostTotal": bedCostTotal,
  35385. "bedCostSelfTotal": bedCostSelfTotal,
  35386. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35387. "bedSelfTotal": bedSelfTotal,
  35388. "bedInscpTotal": bedInscpTotal,
  35389. "operationCostTotal": operationCostTotal,
  35390. "operationCostSelfTotal": operationCostSelfTotal,
  35391. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35392. "operationSelfTotal": operationSelfTotal,
  35393. "operationInscpTotal": operationInscpTotal,
  35394. "otherCostTotal": otherCostTotal,
  35395. "otherCostSelfTotal": otherCostSelfTotal,
  35396. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35397. "otherSelfTotal": otherSelfTotal,
  35398. "otherInscpTotal": otherInscpTotal,
  35399. "materialCostTotal": materialCostTotal,
  35400. "materialCostSelfTotal": materialCostSelfTotal,
  35401. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35402. "materialSelfTotal": materialSelfTotal,
  35403. "materialInscpTotal": materialInscpTotal,
  35404. "westernMedicineCostTotal": westernMedicineCostTotal,
  35405. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35406. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35407. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35408. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35409. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35410. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35411. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35412. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35413. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35414. "checkCostTotal": checkCostTotal,
  35415. "checkCostSelfTotal": checkCostSelfTotal,
  35416. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35417. "checkSelfTotal": checkSelfTotal,
  35418. "checkInscpTotal": checkInscpTotal,
  35419. "laboratoryCostTotal": laboratoryCostTotal,
  35420. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35421. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35422. "laboratorySelfTotal": laboratorySelfTotal,
  35423. "laboratoryInscpTotal": laboratoryInscpTotal,
  35424. "treatCostTotal": treatCostTotal,
  35425. "treatCostSelfTotal": treatCostSelfTotal,
  35426. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35427. "treatSelfTotal": treatSelfTotal,
  35428. "treatInscpTotal": treatInscpTotal,
  35429. "doctor_info": doctor_info,
  35430. "doctor_code": adminRole_two.DoctorCode,
  35431. "doctor_name": doctor_name,
  35432. "health_card_no": order.PsnNo,
  35433. "department": departments.Name,
  35434. "yiliao_leibie": yiliao_leibie,
  35435. "after_money": order.AccountPrice,
  35436. "patient": patient,
  35437. "org_name": miConfig.OrgName,
  35438. "org_code": miConfig.Code,
  35439. "order_number": order.Number,
  35440. "his_hospital": his_hospital,
  35441. "his": his,
  35442. "dia_config": dia_config,
  35443. "psn_cash_pay": order.PsnCashPay,
  35444. "zcCostTotal": zcCostTotal,
  35445. "zcCostSelfTotal": zcCostSelfTotal,
  35446. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35447. "zcSelfTotal": zcSelfTotal,
  35448. "zcInscpTotal": zcInscpTotal,
  35449. "huliCostTotal": huliCostTotal,
  35450. "huliCostSelfTotal": huliCostSelfTotal,
  35451. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35452. "huliSelfTotal": huliSelfTotal,
  35453. "huliInscpTotal": huliInscpTotal,
  35454. //"funds": rf,
  35455. //"check_order_info": cus_slice,
  35456. })
  35457. } else {
  35458. c.ServeSuccessJSON(map[string]interface{}{
  35459. "diagnosis": name,
  35460. "order_infos": orderInfos,
  35461. "number": order.MdtrtId,
  35462. "date": order.SettleAccountsDate,
  35463. "charge_admin": charge_admin,
  35464. "printor_admin": printor_admin,
  35465. "info": order,
  35466. "order": order,
  35467. "bedCostTotal": bedCostTotal,
  35468. "bedCostSelfTotal": bedCostSelfTotal,
  35469. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  35470. "bedSelfTotal": bedSelfTotal,
  35471. "bedInscpTotal": bedInscpTotal,
  35472. "operationCostTotal": operationCostTotal,
  35473. "operationCostSelfTotal": operationCostSelfTotal,
  35474. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  35475. "operationSelfTotal": operationSelfTotal,
  35476. "operationInscpTotal": operationInscpTotal,
  35477. "otherCostTotal": otherCostTotal,
  35478. "otherCostSelfTotal": otherCostSelfTotal,
  35479. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  35480. "otherSelfTotal": otherSelfTotal,
  35481. "otherInscpTotal": otherInscpTotal,
  35482. "materialCostTotal": materialCostTotal,
  35483. "materialCostSelfTotal": materialCostSelfTotal,
  35484. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  35485. "materialSelfTotal": materialSelfTotal,
  35486. "materialInscpTotal": materialInscpTotal,
  35487. "westernMedicineCostTotal": westernMedicineCostTotal,
  35488. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  35489. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  35490. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  35491. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  35492. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  35493. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  35494. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  35495. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  35496. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  35497. "checkCostTotal": checkCostTotal,
  35498. "checkCostSelfTotal": checkCostSelfTotal,
  35499. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  35500. "checkSelfTotal": checkSelfTotal,
  35501. "checkInscpTotal": checkInscpTotal,
  35502. "laboratoryCostTotal": laboratoryCostTotal,
  35503. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  35504. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  35505. "laboratorySelfTotal": laboratorySelfTotal,
  35506. "laboratoryInscpTotal": laboratoryInscpTotal,
  35507. "treatCostTotal": treatCostTotal,
  35508. "treatCostSelfTotal": treatCostSelfTotal,
  35509. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  35510. "treatSelfTotal": treatSelfTotal,
  35511. "treatInscpTotal": treatInscpTotal,
  35512. "doctor_info": doctor_info,
  35513. "doctor_code": adminRole_two.DoctorCode,
  35514. "doctor_name": doctor_name,
  35515. "health_card_no": order.PsnNo,
  35516. "department": departments.Name,
  35517. "yiliao_leibie": yiliao_leibie,
  35518. "after_money": order.AccountPrice,
  35519. "patient": patient,
  35520. "org_name": miConfig.OrgName,
  35521. "org_code": miConfig.Code,
  35522. "order_number": order.Number,
  35523. "his_hospital": his_hospital,
  35524. "his": his,
  35525. "dia_config": dia_config,
  35526. "psn_cash_pay": order.PsnCashPay,
  35527. "zcCostTotal": zcCostTotal,
  35528. "zcCostSelfTotal": zcCostSelfTotal,
  35529. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  35530. "zcSelfTotal": zcSelfTotal,
  35531. "zcInscpTotal": zcInscpTotal,
  35532. "huliCostTotal": huliCostTotal,
  35533. "huliCostSelfTotal": huliCostSelfTotal,
  35534. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  35535. "huliSelfTotal": huliSelfTotal,
  35536. "huliInscpTotal": huliInscpTotal,
  35537. //"funds": rf,
  35538. //"check_order_info": cus_slice,
  35539. })
  35540. }
  35541. }
  35542. }
  35543. }
  35544. //func (c *HisApiController) CheckTreatment() {
  35545. // patient_id, _ := c.GetInt64("patient_id")
  35546. // id_card_no := c.GetString("id_card_no")
  35547. // insutype := c.GetString("insutype")
  35548. // med_type := c.GetString("med_type")
  35549. // admin_user_id, _ := c.GetInt64("admin_user_id")
  35550. //
  35551. // adminUser := c.GetAdminUserInfo()
  35552. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  35553. //
  35554. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35555. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35556. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35557. //
  35558. // if miConfig.MdtrtareaAdmvs == "421300" {
  35559. // var res ResultTwo
  35560. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  35561. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35562. // "&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)
  35563. // resp, requestErr := http.Get(api)
  35564. // if requestErr != nil {
  35565. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35566. // return
  35567. // }
  35568. //
  35569. // body, ioErr := ioutil.ReadAll(resp.Body)
  35570. // if ioErr != nil {
  35571. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35572. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35573. // return
  35574. // }
  35575. // var respJSON map[string]interface{}
  35576. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35577. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35578. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35579. // return
  35580. // }
  35581. //
  35582. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35583. // result, _ := json.Marshal(respJSON)
  35584. //
  35585. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35586. // utils.ErrorLog("解析失败:%v", err)
  35587. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35588. // return
  35589. // }
  35590. //
  35591. // if res.Infcode == 0 {
  35592. //
  35593. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  35594. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  35595. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  35596. // resp, requestErr := http.Get(api)
  35597. // if requestErr != nil {
  35598. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35599. // return
  35600. // }
  35601. //
  35602. // body, ioErr := ioutil.ReadAll(resp.Body)
  35603. // if ioErr != nil {
  35604. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35605. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35606. // return
  35607. // }
  35608. // var respJSON map[string]interface{}
  35609. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35610. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35611. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35612. // return
  35613. // }
  35614. // var res Result2001
  35615. //
  35616. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35617. // result2, _ := json.Marshal(respJSON)
  35618. //
  35619. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  35620. // utils.ErrorLog("解析失败:%v", err)
  35621. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35622. // return
  35623. // }
  35624. //
  35625. // if res.Infcode == 0 {
  35626. // c.ServeSuccessJSON(map[string]interface{}{
  35627. // "msg": res.Output.Trtinfo,
  35628. // })
  35629. // }
  35630. //
  35631. // } else {
  35632. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  35633. // return
  35634. // }
  35635. //
  35636. // } else {
  35637. //
  35638. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  35639. // var dat map[string]interface{}
  35640. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35641. // fmt.Println(dat)
  35642. // } else {
  35643. // fmt.Println(err)
  35644. // }
  35645. // userJSONBytes, _ := json.Marshal(dat)
  35646. // var res ResultTwo
  35647. // var res10265 ResultTwo10265
  35648. // if miConfig.Code == "H15049901371" {
  35649. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  35650. // utils.ErrorLog("解析失败:%v", err)
  35651. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35652. // return
  35653. // }
  35654. // res.ErrMsg = res10265.ErrMsg
  35655. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35656. // res.Infcode = infocode
  35657. // res.Output = res10265.Output
  35658. // res.InfRefmsgid = res10265.InfRefmsgid
  35659. // } else {
  35660. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35661. // utils.ErrorLog("解析失败:%v", err)
  35662. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35663. // return
  35664. // }
  35665. // }
  35666. //
  35667. // var user_name string
  35668. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  35669. // if role.ID == 0 {
  35670. // user_name = "xxx"
  35671. // } else {
  35672. // user_name = role.UserName
  35673. // }
  35674. //
  35675. // baseParams := models.BaseParams{
  35676. // SecretKey: miConfig.SecretKey,
  35677. // FixmedinsCode: miConfig.Code,
  35678. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  35679. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  35680. // OrgName: miConfig.OrgName,
  35681. // Doctor: user_name,
  35682. // }
  35683. //
  35684. // if config.IsOpen == 1 {
  35685. // if miConfig.Code == "H15049901371" {
  35686. // if med_type == "14" {
  35687. // if insutype == "390" {
  35688. // med_type = "9933"
  35689. // } else if insutype == "310" {
  35690. // med_type = "990502"
  35691. // }
  35692. // } else if med_type == "11" {
  35693. // med_type = "11"
  35694. // }
  35695. // }
  35696. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  35697. // var dat map[string]interface{}
  35698. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35699. // fmt.Println(dat)
  35700. // } else {
  35701. // fmt.Println(err)
  35702. // }
  35703. // var res Result2001
  35704. // var res10265 Result2001Org10265
  35705. // if miConfig.Code == "H15049901371" {
  35706. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  35707. // utils.ErrorLog("解析失败:%v", err)
  35708. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35709. // return
  35710. // }
  35711. // res.ErrMsg = res10265.ErrMsg
  35712. // res.Output = res10265.Output
  35713. // res.InfRefmsgid = res10265.InfRefmsgid
  35714. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  35715. // res.Infcode = infocode
  35716. // } else {
  35717. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  35718. // utils.ErrorLog("解析失败:%v", err)
  35719. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35720. // return
  35721. // }
  35722. // }
  35723. // if res.Infcode == 0 {
  35724. // c.ServeSuccessJSON(map[string]interface{}{
  35725. // "msg": res.Output.Trtinfo,
  35726. // })
  35727. // }
  35728. // }
  35729. // }
  35730. //}
  35731. //func (c *HisApiController) PutRecord() {
  35732. // id, _ := c.GetInt64("id")
  35733. // record_time := c.GetString("record_time")
  35734. // timeLayout := "2006-01-02"
  35735. // loc, _ := time.LoadLocation("Local")
  35736. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35737. // if err != nil {
  35738. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35739. // return
  35740. // }
  35741. // recordDateTime := theTime.Unix()
  35742. //
  35743. // adminInfo := c.GetAdminUserInfo()
  35744. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  35745. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35746. //
  35747. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35748. //
  35749. // fmt.Println(miConfig.SecretKey)
  35750. //
  35751. // if patient == nil {
  35752. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  35753. // return
  35754. // }
  35755. // if len(patient.IdCardNo) == 0 {
  35756. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  35757. // return
  35758. // }
  35759. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  35760. // if config.IsOpen == 1 {
  35761. // 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
  35762. // resp, requestErr := http.Get(api)
  35763. // if requestErr != nil {
  35764. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35765. // return
  35766. // }
  35767. // defer resp.Body.Close()
  35768. // body, ioErr := ioutil.ReadAll(resp.Body)
  35769. // if ioErr != nil {
  35770. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35771. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35772. // return
  35773. // }
  35774. // var respJSON map[string]interface{}
  35775. //
  35776. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35777. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35778. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35779. // return
  35780. // }
  35781. //
  35782. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35783. // userJSONBytes, _ := json.Marshal(userJSON)
  35784. // var res ResultTwo
  35785. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35786. // utils.ErrorLog("解析失败:%v", err)
  35787. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35788. // return
  35789. // }
  35790. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  35791. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  35792. // infoStr := string(Iinfos)
  35793. // idetinfoStr := string(Idetinfos)
  35794. //
  35795. // if res.Infcode == 0 {
  35796. // his := models.VMHisPatient{
  35797. // Status: 1,
  35798. // Ctime: time.Now().Unix(),
  35799. // Mtime: time.Now().Unix(),
  35800. // PsnNo: res.Output.Baseinfo.PsnNo,
  35801. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  35802. // Certno: res.Output.Baseinfo.Certno,
  35803. // PsnName: res.Output.Baseinfo.PsnName,
  35804. // Gend: res.Output.Baseinfo.Gend,
  35805. // Naty: res.Output.Baseinfo.Naty,
  35806. // Brdy: res.Output.Baseinfo.Brdy,
  35807. // Age: res.Output.Baseinfo.Age,
  35808. // Iinfo: infoStr,
  35809. // Idetinfo: idetinfoStr,
  35810. // PatientId: patient.ID,
  35811. // RecordDate: theTime.Unix(),
  35812. // UserOrgId: adminInfo.CurrentOrgId,
  35813. // AdminUserId: adminInfo.AdminUser.Id,
  35814. // IsReturn: 1,
  35815. // }
  35816. //
  35817. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  35818. // //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")
  35819. // //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")
  35820. //
  35821. // //var dat map[string]interface{}
  35822. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35823. // // fmt.Println(dat)
  35824. // //} else {
  35825. // // fmt.Println(err)
  35826. // //}
  35827. //
  35828. // var dat2 map[string]interface{}
  35829. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  35830. // fmt.Println(dat2)
  35831. // } else {
  35832. // fmt.Println(err)
  35833. // }
  35834. //
  35835. // } else {
  35836. // adminUser := c.GetAdminUserInfo()
  35837. // errlog := &models.HisOrderError{
  35838. // UserOrgId: adminUser.CurrentOrgId,
  35839. // Ctime: time.Now().Unix(),
  35840. // Mtime: time.Now().Unix(),
  35841. // ErrMsg: res.ErrMsg,
  35842. // Status: 1,
  35843. // PatientId: id,
  35844. // RecordTime: recordDateTime,
  35845. // Stage: 1,
  35846. // }
  35847. // service.CreateErrMsgLog(errlog)
  35848. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  35849. // return
  35850. // }
  35851. // }
  35852. //
  35853. //}
  35854. //func (c *HisApiController) GetUploadDiag() {
  35855. // id, _ := c.GetInt64("id")
  35856. // record_time := c.GetString("record_time")
  35857. //
  35858. // diagnosis_id, _ := c.GetInt64("diagnosis")
  35859. // sick_type, _ := c.GetInt64("sick_type")
  35860. // reg_type, _ := c.GetInt64("reg_type")
  35861. //
  35862. // timeLayout := "2006-01-02"
  35863. // loc, _ := time.LoadLocation("Local")
  35864. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  35865. // if err != nil {
  35866. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  35867. // return
  35868. // }
  35869. //
  35870. // var patientPrescription models.HisPrescriptionInfo
  35871. // recordDateTime := theTime.Unix()
  35872. // adminInfo := c.GetAdminUserInfo()
  35873. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35874. //
  35875. // if patientPrescription.ID == 0 {
  35876. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35877. // }
  35878. //
  35879. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  35880. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  35881. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  35882. // sickConfig, _ := service.FindSickById(sick_type)
  35883. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  35884. //
  35885. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  35886. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  35887. // "&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 +
  35888. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  35889. // resp2, requestErr2 := http.Get(api2)
  35890. // if requestErr2 != nil {
  35891. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35892. // return
  35893. // }
  35894. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35895. // if ioErr2 != nil {
  35896. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35897. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35898. // return
  35899. // }
  35900. // var respJSON2 map[string]interface{}
  35901. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35902. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35903. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35904. // return
  35905. // }
  35906. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35907. // userJSONBytes2, _ := json.Marshal(respJSON2)
  35908. //
  35909. // var res2 ResultSix
  35910. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  35911. // utils.ErrorLog("解析失败:%v", err)
  35912. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35913. // return
  35914. // }
  35915. // if res2.Infcode != 0 {
  35916. // adminUser := c.GetAdminUserInfo()
  35917. // errlog := &models.HisOrderError{
  35918. // UserOrgId: adminUser.CurrentOrgId,
  35919. // Ctime: time.Now().Unix(),
  35920. // Mtime: time.Now().Unix(),
  35921. // ErrMsg: res2.ErrMsg,
  35922. // Status: 1,
  35923. // PatientId: id,
  35924. // RecordTime: recordDateTime,
  35925. // Stage: 3,
  35926. // }
  35927. // service.CreateErrMsgLog(errlog)
  35928. //
  35929. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  35930. // return
  35931. // }
  35932. //
  35933. // c.ServeSuccessJSON(map[string]interface{}{
  35934. // "msg": "上传成功",
  35935. // })
  35936. //
  35937. //}
  35938. type QueryResult struct {
  35939. ID int64
  35940. Name string
  35941. Code string
  35942. List_type_code string
  35943. }
  35944. func (c *HisApiController) GetCheckCode() {
  35945. ids_str := c.GetString("ids")
  35946. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  35947. ids_arr := strings.Split(ids_str, ",")
  35948. var queryResult []QueryResult
  35949. ids := make([]int64, 0)
  35950. for _, item := range ids_arr {
  35951. id, _ := strconv.ParseInt(item, 10, 64)
  35952. ids = append(ids, id)
  35953. }
  35954. if record_type == 1 {
  35955. drugs, _ := service.GetBatchDrugList(ids)
  35956. for _, item := range drugs {
  35957. result := QueryResult{
  35958. ID: item.ID,
  35959. Name: item.DrugName,
  35960. Code: item.MedicalInsuranceNumber,
  35961. List_type_code: "101",
  35962. }
  35963. queryResult = append(queryResult, result)
  35964. }
  35965. } else if record_type == 2 {
  35966. goods, _ := service.GetBatchGoodInformationList(ids)
  35967. fmt.Println(goods)
  35968. for _, item := range goods {
  35969. result := QueryResult{
  35970. ID: item.ID,
  35971. Name: item.GoodName,
  35972. Code: item.SocialSecurityDirectoryCode,
  35973. List_type_code: "301",
  35974. }
  35975. queryResult = append(queryResult, result)
  35976. }
  35977. } else if record_type == 3 {
  35978. projects, _ := service.GetBathchMyPorjecgList(ids)
  35979. for _, item := range projects {
  35980. result := QueryResult{
  35981. ID: item.ID,
  35982. Name: item.ProjectName,
  35983. Code: item.MedicalCode,
  35984. List_type_code: "201",
  35985. }
  35986. queryResult = append(queryResult, result)
  35987. }
  35988. }
  35989. admin_user_id, _ := c.GetInt64("admin_user_id")
  35990. adminUser := c.GetAdminUserInfo()
  35991. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35992. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35993. var user_name string
  35994. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35995. if role.ID == 0 {
  35996. user_name = "管理员"
  35997. } else {
  35998. user_name = role.UserName
  35999. }
  36000. baseParams := models.BaseParams{
  36001. SecretKey: miConfig.SecretKey,
  36002. FixmedinsCode: miConfig.Code,
  36003. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36004. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36005. OrgName: miConfig.OrgName,
  36006. Doctor: user_name,
  36007. }
  36008. var result string
  36009. if miConfig.MdtrtareaAdmvs == "430800" {
  36010. for _, item := range queryResult {
  36011. if record_type == 1 {
  36012. 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)
  36013. } else if record_type == 2 {
  36014. fmt.Println(item.Code)
  36015. 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)
  36016. } else if record_type == 3 {
  36017. 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)
  36018. }
  36019. var dat map[string]interface{}
  36020. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36021. fmt.Println(dat)
  36022. } else {
  36023. fmt.Println(err)
  36024. }
  36025. userJSONBytes, _ := json.Marshal(dat)
  36026. var res ResultSix
  36027. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36028. utils.ErrorLog("解析失败:%v", err)
  36029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36030. return
  36031. }
  36032. if res.Infcode == 0 {
  36033. if record_type == 1 {
  36034. service.UpdateBaseDrugById(item.ID)
  36035. } else if record_type == 2 {
  36036. service.UpdateGoodInformaitonByDetail(item.ID)
  36037. } else if record_type == 3 {
  36038. service.UpdateProjectById(item.ID)
  36039. }
  36040. c.ServeSuccessJSON(map[string]interface{}{
  36041. "failed_code": 0,
  36042. "msg": "目录对照成功",
  36043. })
  36044. } else {
  36045. c.ServeSuccessJSON(map[string]interface{}{
  36046. "failed_code": -10,
  36047. "msg": res.ErrMsg,
  36048. })
  36049. }
  36050. }
  36051. } else {
  36052. for _, item := range queryResult {
  36053. var result string
  36054. if record_type == 1 {
  36055. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36056. } else if record_type == 2 {
  36057. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36058. } else if record_type == 3 {
  36059. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  36060. }
  36061. var dat map[string]interface{}
  36062. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36063. fmt.Println(dat)
  36064. } else {
  36065. fmt.Println(err)
  36066. }
  36067. userJSONBytes, _ := json.Marshal(dat)
  36068. var res ResultSix
  36069. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36070. utils.ErrorLog("解析失败:%v", err)
  36071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36072. return
  36073. }
  36074. if res.Infcode == 0 {
  36075. if record_type == 1 {
  36076. service.UpdateBaseDrugById(item.ID)
  36077. } else if record_type == 2 {
  36078. service.UpdateGoodInformaitonByDetail(item.ID)
  36079. } else if record_type == 3 {
  36080. service.UpdateProjectById(item.ID)
  36081. }
  36082. c.ServeSuccessJSON(map[string]interface{}{
  36083. "failed_code": 0,
  36084. "msg": "目录对照成功",
  36085. })
  36086. } else {
  36087. c.ServeSuccessJSON(map[string]interface{}{
  36088. "failed_code": -10,
  36089. "msg": res.ErrMsg,
  36090. })
  36091. }
  36092. }
  36093. }
  36094. }
  36095. func (c *HisApiController) UnCheckCode() {
  36096. ids_str := c.GetString("ids")
  36097. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  36098. admin_user_id, _ := c.GetInt64("admin_user_id")
  36099. ids_arr := strings.Split(ids_str, ",")
  36100. var queryResult []QueryResult
  36101. ids := make([]int64, 0)
  36102. for _, item := range ids_arr {
  36103. id, _ := strconv.ParseInt(item, 10, 64)
  36104. ids = append(ids, id)
  36105. }
  36106. if record_type == 1 {
  36107. drugs, _ := service.GetBatchDrugList(ids)
  36108. for _, item := range drugs {
  36109. result := QueryResult{
  36110. ID: item.ID,
  36111. Name: item.DrugName,
  36112. Code: item.MedicalInsuranceNumber,
  36113. List_type_code: "101",
  36114. }
  36115. queryResult = append(queryResult, result)
  36116. }
  36117. } else if record_type == 2 {
  36118. goods, _ := service.GetBatchGoodInformationList(ids)
  36119. for _, item := range goods {
  36120. result := QueryResult{
  36121. ID: item.ID,
  36122. Name: item.GoodName,
  36123. Code: item.SocialSecurityDirectoryCode,
  36124. List_type_code: "301",
  36125. }
  36126. queryResult = append(queryResult, result)
  36127. }
  36128. } else if record_type == 3 {
  36129. projects, _ := service.GetBathchMyPorjecgList(ids)
  36130. for _, item := range projects {
  36131. result := QueryResult{
  36132. ID: item.ID,
  36133. Name: item.ProjectName,
  36134. Code: item.MedicalCode,
  36135. List_type_code: "201",
  36136. }
  36137. queryResult = append(queryResult, result)
  36138. }
  36139. }
  36140. adminUser := c.GetAdminUserInfo()
  36141. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36142. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36143. var user_name string
  36144. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36145. if role.ID == 0 {
  36146. user_name = "xxx"
  36147. } else {
  36148. user_name = role.UserName
  36149. }
  36150. baseParams := &models.BaseParams{
  36151. SecretKey: miConfig.SecretKey,
  36152. FixmedinsCode: miConfig.Code,
  36153. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36154. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36155. OrgName: miConfig.OrgName,
  36156. Doctor: user_name,
  36157. }
  36158. if config.IsOpen == 1 {
  36159. if miConfig.MdtrtareaAdmvs == "430800" {
  36160. for _, item := range queryResult {
  36161. var result string
  36162. if record_type == 1 {
  36163. 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)
  36164. } else if record_type == 2 {
  36165. fmt.Println(item.Code)
  36166. 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)
  36167. } else if record_type == 3 {
  36168. 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)
  36169. }
  36170. var dat map[string]interface{}
  36171. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36172. fmt.Println(dat)
  36173. } else {
  36174. fmt.Println(err)
  36175. }
  36176. userJSONBytes, _ := json.Marshal(dat)
  36177. var res ResultSix
  36178. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36179. utils.ErrorLog("解析失败:%v", err)
  36180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36181. return
  36182. }
  36183. if res.Infcode == 0 {
  36184. if record_type == 1 {
  36185. service.UpdateBaseDrugById(item.ID)
  36186. } else if record_type == 2 {
  36187. service.UpdateGoodInformaitonByDetail(item.ID)
  36188. } else if record_type == 3 {
  36189. service.UpdateProjectById(item.ID)
  36190. }
  36191. c.ServeSuccessJSON(map[string]interface{}{
  36192. "failed_code": 0,
  36193. "msg": "目录对照成功",
  36194. })
  36195. } else {
  36196. c.ServeSuccessJSON(map[string]interface{}{
  36197. "failed_code": -10,
  36198. "msg": res.ErrMsg,
  36199. })
  36200. }
  36201. }
  36202. } else {
  36203. for _, item := range queryResult {
  36204. var result string
  36205. if record_type == 1 {
  36206. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36207. } else if record_type == 2 {
  36208. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36209. } else if record_type == 3 {
  36210. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  36211. }
  36212. var dat2 map[string]interface{}
  36213. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  36214. fmt.Println(dat2)
  36215. } else {
  36216. fmt.Println(err)
  36217. }
  36218. userJSONBytes, _ := json.Marshal(dat2)
  36219. var res ResultSix
  36220. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36221. utils.ErrorLog("解析失败:%v", err)
  36222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36223. return
  36224. }
  36225. if res.Infcode == 0 {
  36226. if record_type == 1 {
  36227. service.UpdateDrugByIdDetail(item.ID)
  36228. } else if record_type == 2 {
  36229. service.UpdateGoodInfoById(item.ID)
  36230. } else if record_type == 3 {
  36231. service.UpdateMyProjectById(item.ID)
  36232. }
  36233. c.ServeSuccessJSON(map[string]interface{}{
  36234. "failed_code": 0,
  36235. "msg": "撤销目录对照成功",
  36236. })
  36237. } else {
  36238. c.ServeSuccessJSON(map[string]interface{}{
  36239. "failed_code": -10,
  36240. "msg": res.ErrMsg,
  36241. })
  36242. }
  36243. }
  36244. }
  36245. }
  36246. }
  36247. func (c *HisApiController) GetPatientInfo() {
  36248. id_card_no := c.GetString("id_card_no")
  36249. admin_user_id, _ := c.GetInt64("admin_user_id")
  36250. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  36251. if patient.ID == 0 {
  36252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  36253. return
  36254. }
  36255. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  36256. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  36257. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  36258. var res ResultTwo
  36259. var res10265 ResultTwo10265
  36260. if config.IsOpen == 1 {
  36261. if miConfig.MdtrtareaAdmvs == "150499" {
  36262. //请求内网数据
  36263. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  36264. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36265. "&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
  36266. resp, requestErr := http.Get(api)
  36267. if requestErr != nil {
  36268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36269. return
  36270. }
  36271. body, ioErr := ioutil.ReadAll(resp.Body)
  36272. if ioErr != nil {
  36273. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36275. return
  36276. }
  36277. var respJSON map[string]interface{}
  36278. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36281. return
  36282. }
  36283. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36284. result_byte, _ := json.Marshal(respJSON)
  36285. result := string(result_byte)
  36286. var dat map[string]interface{}
  36287. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36288. fmt.Println(dat)
  36289. } else {
  36290. fmt.Println(err)
  36291. }
  36292. userJSONBytes, _ := json.Marshal(dat)
  36293. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36294. utils.ErrorLog("解析失败:%v", err)
  36295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36296. return
  36297. }
  36298. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36299. res.Infcode = Infcode
  36300. res.ErrMsg = res10265.ErrMsg
  36301. res.Output = res10265.Output
  36302. res.InfRefmsgid = res10265.InfRefmsgid
  36303. res.RespondTime = res10265.RespondTime
  36304. res.WarnInfo = res10265.WarnInfo
  36305. } else {
  36306. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  36307. var dat map[string]interface{}
  36308. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36309. fmt.Println(dat)
  36310. } else {
  36311. fmt.Println(err)
  36312. }
  36313. userJSONBytes, _ := json.Marshal(dat)
  36314. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36315. utils.ErrorLog("解析失败:%v", err)
  36316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36317. return
  36318. }
  36319. }
  36320. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36321. // utils.ErrorLog("解析失败:%v", err)
  36322. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36323. // return
  36324. //}
  36325. for index, item := range res.Output.Iinfo {
  36326. if item.PsnInsuStas == "2" {
  36327. fmt.Println("--------")
  36328. res.Output.Iinfo[index].Insutype = "300"
  36329. res.Output.Iinfo[index].PsnInsuStas = "1"
  36330. }
  36331. }
  36332. fmt.Println(res.Output.Iinfo)
  36333. if res.Infcode != 0 {
  36334. c.ServeSuccessJSON(map[string]interface{}{
  36335. "failed_code": -10,
  36336. "msg": res.ErrMsg,
  36337. })
  36338. } else {
  36339. c.ServeSuccessJSON(map[string]interface{}{
  36340. "failed_code": 0,
  36341. "info": res,
  36342. })
  36343. }
  36344. }
  36345. }
  36346. func (c *HisApiController) PsnPutOnRecord() {
  36347. record_type, _ := c.GetInt64("type")
  36348. patient_id, _ := c.GetInt64("patient_id")
  36349. admin_user_id, _ := c.GetInt64("admin_user_id")
  36350. start_time := c.GetString("start_time")
  36351. end_time := c.GetString("end_time")
  36352. adminUser := c.GetAdminUserInfo()
  36353. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36354. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36355. var patients []*models.Patients
  36356. if record_type == 1 { //全部备案
  36357. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  36358. patients = append(patients, patient...)
  36359. } else { //单个备案
  36360. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36361. patients = append(patients, patient)
  36362. }
  36363. var user_name string
  36364. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36365. if role.ID == 0 {
  36366. user_name = "xxx"
  36367. } else {
  36368. user_name = role.UserName
  36369. }
  36370. if config.IsOpen == 1 {
  36371. for _, item := range patients {
  36372. 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
  36373. resp, requestErr := http.Get(api)
  36374. if requestErr != nil {
  36375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36376. return
  36377. }
  36378. defer resp.Body.Close()
  36379. body, ioErr := ioutil.ReadAll(resp.Body)
  36380. if ioErr != nil {
  36381. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36383. return
  36384. }
  36385. var respJSON map[string]interface{}
  36386. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36387. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36389. return
  36390. }
  36391. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36392. userJSONBytes, _ := json.Marshal(userJSON)
  36393. var res ResultTwo
  36394. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36395. utils.ErrorLog("解析失败:%v", err)
  36396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36397. return
  36398. }
  36399. if res.Infcode == 0 {
  36400. 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)
  36401. var dat map[string]interface{}
  36402. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36403. fmt.Println(dat)
  36404. } else {
  36405. fmt.Println(err)
  36406. }
  36407. userJSONBytes, _ := json.Marshal(dat)
  36408. var res2 ResultThirteen
  36409. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36410. utils.ErrorLog("解析失败:%v", err)
  36411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36412. return
  36413. }
  36414. if res2.Infcode == 0 {
  36415. psnResult := &models.GdybPsnRecord{
  36416. UserOrgId: adminUser.CurrentOrgId,
  36417. PatientId: item.ID,
  36418. PsnNo: res.Output.Baseinfo.PsnNo,
  36419. Ctime: time.Now().Unix(),
  36420. Mtime: time.Now().Unix(),
  36421. Status: 1,
  36422. IsCancel: 1,
  36423. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36424. }
  36425. service.CreatePsnRecord(psnResult)
  36426. } else {
  36427. c.ServeSuccessJSON(map[string]interface{}{
  36428. "failed_code": -10,
  36429. "msg": res2.ErrMsg,
  36430. })
  36431. return
  36432. }
  36433. }
  36434. }
  36435. }
  36436. }
  36437. func (c *HisApiController) PsnUnPutOnRecord() {
  36438. id, _ := c.GetInt64("id")
  36439. //record_type, _ := c.GetInt64("type")
  36440. admin_user_id, _ := c.GetInt64("admin_user_id")
  36441. adminUser := c.GetAdminUserInfo()
  36442. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36443. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36444. var user_name string
  36445. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36446. if role.ID == 0 {
  36447. user_name = "xxx"
  36448. } else {
  36449. user_name = role.UserName
  36450. }
  36451. psn_record, _ := service.GetPsnRecordById(id)
  36452. if psn_record.ID == 0 {
  36453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36454. return
  36455. }
  36456. if config.IsOpen == 1 {
  36457. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36458. var dat map[string]interface{}
  36459. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36460. fmt.Println(dat)
  36461. } else {
  36462. fmt.Println(err)
  36463. }
  36464. userJSONBytes, _ := json.Marshal(dat)
  36465. var res ResultFourteen
  36466. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36467. utils.ErrorLog("解析失败:%v", err)
  36468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36469. return
  36470. }
  36471. if res.Infcode == 0 {
  36472. psn_record.IsCancel = 2
  36473. service.CreatePsnRecord(&psn_record)
  36474. } else {
  36475. c.ServeSuccessJSON(map[string]interface{}{
  36476. "failed_code": -10,
  36477. "msg": res.ErrMsg,
  36478. })
  36479. return
  36480. }
  36481. }
  36482. }
  36483. func (c *HisApiController) PsnPutNCDSOnRecord() {
  36484. patient_id, _ := c.GetInt64("patient_id")
  36485. insutype_two := c.GetString("insutype")
  36486. psn_no := c.GetString("psn_no")
  36487. doctor_id, _ := c.GetInt64("doctor_id")
  36488. sick_id, _ := c.GetInt64("sick_id")
  36489. department_id, _ := c.GetInt64("department_id")
  36490. start_time := c.GetString("start_time")
  36491. end_time := c.GetString("end_time")
  36492. check_time := c.GetString("check_time")
  36493. hospital_code := c.GetString("hospital_code")
  36494. hospital_name := c.GetString("hospital_name")
  36495. adminUser := c.GetAdminUserInfo()
  36496. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  36497. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36498. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36499. sick, _ := service.FindSickById(sick_id)
  36500. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36501. if len(hospital_code) == 0 {
  36502. hospital_code = miConfig.Code
  36503. }
  36504. if len(hospital_name) == 0 {
  36505. hospital_name = miConfig.OrgName
  36506. }
  36507. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  36508. var res ResultTwo
  36509. var res10265 ResultTwo10265
  36510. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36511. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  36512. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  36513. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36514. "&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
  36515. resp, requestErr := http.Get(api)
  36516. if requestErr != nil {
  36517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36518. return
  36519. }
  36520. body, ioErr := ioutil.ReadAll(resp.Body)
  36521. if ioErr != nil {
  36522. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36524. return
  36525. }
  36526. var respJSON map[string]interface{}
  36527. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36528. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36530. return
  36531. }
  36532. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36533. result, _ := json.Marshal(respJSON)
  36534. fmt.Println("log")
  36535. fmt.Println(string(result))
  36536. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36537. utils.ErrorLog("解析失败:%v", err)
  36538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36539. return
  36540. }
  36541. res.ErrMsg = res10265.ErrMsg
  36542. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36543. res.Infcode = infocode
  36544. res.Output = res10265.Output
  36545. res.InfRefmsgid = res10265.InfRefmsgid
  36546. } else {
  36547. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36548. if miConfig.Code == "H15049901371" {
  36549. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36550. utils.ErrorLog("解析失败:%v", err)
  36551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36552. return
  36553. }
  36554. res.ErrMsg = res10265.ErrMsg
  36555. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36556. res.Infcode = infocode
  36557. res.Output = res10265.Output
  36558. res.InfRefmsgid = res10265.InfRefmsgid
  36559. } else {
  36560. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36561. utils.ErrorLog("解析失败:%v", err)
  36562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36563. return
  36564. }
  36565. }
  36566. }
  36567. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36568. infoStr := string(Iinfos)
  36569. var rf []*ResultFive
  36570. json.Unmarshal([]byte(infoStr), &rf)
  36571. var insuplc_admdvs string
  36572. var insutype string
  36573. var is390 int = 0
  36574. var is310 int = 0
  36575. var insutypes []*ResultFive
  36576. for _, item := range rf {
  36577. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36578. insutypes = append(insutypes, item)
  36579. }
  36580. }
  36581. if len(insutypes) == 1 {
  36582. insutype = insutypes[0].Insutype
  36583. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36584. } else {
  36585. for _, i := range insutypes {
  36586. if i.Insutype == "390" {
  36587. is390 = 1
  36588. }
  36589. if i.Insutype == "310" {
  36590. is310 = 1
  36591. }
  36592. }
  36593. }
  36594. if is390 == 1 {
  36595. insutype = "390"
  36596. }
  36597. if is310 == 1 {
  36598. insutype = "310"
  36599. }
  36600. if len(insutypes) == 2 {
  36601. insutype = insutype_two
  36602. }
  36603. if len(insutypes) == 0 {
  36604. insutype = "310"
  36605. }
  36606. insutype = insutype_two
  36607. fmt.Println(insutype)
  36608. for _, item := range rf {
  36609. fmt.Println(item.Insutype)
  36610. fmt.Println(insutype)
  36611. if item.Insutype == insutype {
  36612. fmt.Println(item.Insutype)
  36613. fmt.Println(insutype)
  36614. insuplc_admdvs = item.InsuplcAdmdvs
  36615. }
  36616. }
  36617. fmt.Println(insuplc_admdvs)
  36618. var res2 ResultThirteen
  36619. var res10265_2 ResultThirteen10265
  36620. if config.IsOpen == 1 {
  36621. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  36622. } else {
  36623. if miConfig.MdtrtareaAdmvs == "150499" {
  36624. //
  36625. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  36626. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  36627. // "&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
  36628. //resp, requestErr := http.Get(api)
  36629. //if requestErr != nil {
  36630. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36631. // return
  36632. //}
  36633. //
  36634. //body, ioErr := ioutil.ReadAll(resp.Body)
  36635. //if ioErr != nil {
  36636. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36637. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36638. // return
  36639. //}
  36640. //var respJSON map[string]interface{}
  36641. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36642. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36643. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36644. // return
  36645. //}
  36646. //
  36647. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36648. //result, _ := json.Marshal(respJSON)
  36649. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  36650. // utils.ErrorLog("解析失败:%v", err)
  36651. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36652. // return
  36653. //}
  36654. //infocode = resThree.Infcode
  36655. //result, _ := json.Marshal(respJSON)
  36656. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  36657. // utils.ErrorLog("解析失败:%v", err)
  36658. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36659. // return
  36660. //}
  36661. //
  36662. //resThree.ErrMsg = resThree10265.ErrMsg
  36663. //
  36664. //resThree.Output = resThree10265.Output
  36665. //
  36666. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  36667. //
  36668. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  36669. //
  36670. } else {
  36671. 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)
  36672. var dat map[string]interface{}
  36673. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36674. fmt.Println(dat)
  36675. } else {
  36676. fmt.Println(err)
  36677. }
  36678. userJSONBytes, _ := json.Marshal(dat)
  36679. if miConfig.Code == "H15049901371" {
  36680. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  36681. utils.ErrorLog("解析失败:%v", err)
  36682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36683. return
  36684. }
  36685. res2.ErrMsg = res10265_2.ErrMsg
  36686. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  36687. res2.Infcode = infocode
  36688. res2.Output = res10265_2.Output
  36689. res2.InfRefmsgid = res10265_2.InfRefmsgid
  36690. } else {
  36691. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  36692. utils.ErrorLog("解析失败:%v", err)
  36693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36694. return
  36695. }
  36696. }
  36697. }
  36698. }
  36699. if res2.Infcode == 0 {
  36700. psnResult := &models.GdybPsnNcdsRecord{
  36701. UserOrgId: adminUser.CurrentOrgId,
  36702. PatientId: patient.ID,
  36703. PsnNo: psn_no,
  36704. DoctorId: doctor.AdminUserId,
  36705. DepartmentId: department_id,
  36706. SickType: sick_id,
  36707. Insutype: insutype,
  36708. Ctime: time.Now().Unix(),
  36709. Mtime: time.Now().Unix(),
  36710. Status: 1,
  36711. IsCancel: 1,
  36712. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  36713. }
  36714. service.CreatePsnNCDSRecord(psnResult)
  36715. c.ServeSuccessJSON(map[string]interface{}{
  36716. "failed_code": 0,
  36717. "msg": "备案成功",
  36718. "result": psnResult,
  36719. })
  36720. } else {
  36721. c.ServeSuccessJSON(map[string]interface{}{
  36722. "failed_code": -10,
  36723. "msg": res2.ErrMsg,
  36724. })
  36725. return
  36726. }
  36727. }
  36728. }
  36729. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  36730. id, _ := c.GetInt64("id")
  36731. admin_user_id, _ := c.GetInt64("admin_user_id")
  36732. adminUser := c.GetAdminUserInfo()
  36733. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36734. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36735. //config, _ := service.Ge(adminUser.CurrentOrgId)
  36736. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  36737. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36738. //var user_name string
  36739. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36740. //if role.ID == 0 {
  36741. // user_name = "xxx"
  36742. //} else {
  36743. // user_name = role.UserName
  36744. //}
  36745. psn_record, _ := service.GetPsnNCDSRecordById(id)
  36746. if psn_record.ID == 0 {
  36747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  36748. return
  36749. }
  36750. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  36751. var res ResultTwo
  36752. var res10265 ResultTwo10265
  36753. if miConfig.Code == "H15049901371" {
  36754. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  36755. utils.ErrorLog("解析失败:%v", err)
  36756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36757. return
  36758. }
  36759. res.ErrMsg = res10265.ErrMsg
  36760. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36761. res.Infcode = infocode
  36762. res.Output = res10265.Output
  36763. res.InfRefmsgid = res10265.InfRefmsgid
  36764. } else {
  36765. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36766. utils.ErrorLog("解析失败:%v", err)
  36767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36768. return
  36769. }
  36770. }
  36771. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  36772. infoStr := string(Iinfos)
  36773. var rf []*ResultFive
  36774. json.Unmarshal([]byte(infoStr), &rf)
  36775. var insuplc_admdvs string
  36776. var insutype string
  36777. var is390 int = 0
  36778. var is310 int = 0
  36779. var insutypes []*ResultFive
  36780. for _, item := range rf {
  36781. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  36782. insutypes = append(insutypes, item)
  36783. }
  36784. }
  36785. if len(insutypes) == 1 {
  36786. insutype = insutypes[0].Insutype
  36787. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  36788. } else {
  36789. for _, i := range insutypes {
  36790. if i.Insutype == "390" {
  36791. is390 = 1
  36792. }
  36793. if i.Insutype == "310" {
  36794. is310 = 1
  36795. }
  36796. }
  36797. }
  36798. if is390 == 1 {
  36799. insutype = "390"
  36800. }
  36801. if is310 == 1 {
  36802. insutype = "310"
  36803. }
  36804. if len(insutypes) == 0 {
  36805. insutype = "310"
  36806. }
  36807. insutype = psn_record.Insutype
  36808. for _, item := range rf {
  36809. if item.Insutype == insutype {
  36810. insuplc_admdvs = item.InsuplcAdmdvs
  36811. }
  36812. }
  36813. if config.IsOpen == 1 {
  36814. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  36815. var dat map[string]interface{}
  36816. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36817. fmt.Println(dat)
  36818. } else {
  36819. fmt.Println(err)
  36820. }
  36821. userJSONBytes, _ := json.Marshal(dat)
  36822. var res ResultFourteen
  36823. var res10265 ResultFourteen10265
  36824. if miConfig.Code == "H15049901371" {
  36825. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  36826. utils.ErrorLog("解析失败:%v", err)
  36827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36828. return
  36829. }
  36830. res.ErrMsg = res10265.ErrMsg
  36831. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  36832. res.Infcode = infocode
  36833. res.Output = res10265.Output
  36834. res.InfRefmsgid = res10265.InfRefmsgid
  36835. } else {
  36836. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36837. utils.ErrorLog("解析失败:%v", err)
  36838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36839. return
  36840. }
  36841. }
  36842. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36843. // utils.ErrorLog("解析失败:%v", err)
  36844. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36845. // return
  36846. //}
  36847. if res.Infcode == 0 {
  36848. psn_record.IsCancel = 2
  36849. service.CreatePsnNCDSRecord(&psn_record)
  36850. c.ServeSuccessJSON(map[string]interface{}{
  36851. "failed_code": 0,
  36852. "msg": "撤销备案成功",
  36853. })
  36854. } else {
  36855. c.ServeSuccessJSON(map[string]interface{}{
  36856. "failed_code": -10,
  36857. "msg": res.ErrMsg,
  36858. })
  36859. return
  36860. }
  36861. }
  36862. }
  36863. func (c *HisApiController) TestTest() {
  36864. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  36865. fmt.Println(patient.Iinfo)
  36866. }
  36867. type CustomData struct {
  36868. MsgId string
  36869. PsnNo string
  36870. Info string
  36871. }
  36872. func (c *HisApiController) ReversalData() {
  36873. var customData []*CustomData
  36874. custom := &CustomData{
  36875. MsgId: "H44022900158202103301714472004",
  36876. PsnNo: "44020000001101329945",
  36877. Info: "2207",
  36878. }
  36879. customData = append(customData, custom)
  36880. custom1 := &CustomData{
  36881. MsgId: "H4402290015820210330172057803",
  36882. PsnNo: "44020000001101161813",
  36883. Info: "2207",
  36884. }
  36885. customData = append(customData, custom1)
  36886. custom2 := &CustomData{
  36887. MsgId: "H44022900158202103301705198813",
  36888. PsnNo: "44190000133097375417",
  36889. Info: "2207",
  36890. }
  36891. customData = append(customData, custom2)
  36892. custom3 := &CustomData{
  36893. MsgId: "H44022900158202103301715524756",
  36894. PsnNo: "44020000001100187221",
  36895. Info: "2207",
  36896. }
  36897. customData = append(customData, custom3)
  36898. custom4 := &CustomData{
  36899. MsgId: "H44022900158202103301730376224",
  36900. PsnNo: "44020000001101959155",
  36901. Info: "2207",
  36902. }
  36903. customData = append(customData, custom4)
  36904. custom5 := &CustomData{
  36905. MsgId: "H44022900158202103301748008725",
  36906. PsnNo: "44020000001104246641",
  36907. Info: "2207",
  36908. }
  36909. customData = append(customData, custom5)
  36910. custom6 := &CustomData{
  36911. MsgId: "H44022900158202103301718096755",
  36912. PsnNo: "44020000001102211860",
  36913. Info: "2207",
  36914. }
  36915. customData = append(customData, custom6)
  36916. custom7 := &CustomData{
  36917. MsgId: "H44022900158202103301736551640",
  36918. PsnNo: "44020000001102687718",
  36919. Info: "2207",
  36920. }
  36921. customData = append(customData, custom7)
  36922. custom8 := &CustomData{
  36923. MsgId: "H44022900158202103301743097676",
  36924. PsnNo: "44020000001102127785",
  36925. Info: "2207",
  36926. }
  36927. customData = append(customData, custom8)
  36928. custom9 := &CustomData{
  36929. MsgId: "H44022900158202103301712304203",
  36930. PsnNo: "44020000001101518097",
  36931. Info: "2207",
  36932. }
  36933. customData = append(customData, custom9)
  36934. custom10 := &CustomData{
  36935. MsgId: "H44022900158202103301738448785",
  36936. PsnNo: "44020000001100500813",
  36937. Info: "2207",
  36938. }
  36939. customData = append(customData, custom10)
  36940. custom11 := &CustomData{
  36941. MsgId: "H44022900158202103301732455843",
  36942. PsnNo: "44020000001102690557",
  36943. Info: "2207",
  36944. }
  36945. customData = append(customData, custom11)
  36946. custom12 := &CustomData{
  36947. MsgId: "H44022900158202103301745421708",
  36948. PsnNo: "44020000001102211928",
  36949. Info: "2207",
  36950. }
  36951. customData = append(customData, custom12)
  36952. custom1212 := &CustomData{
  36953. MsgId: "H440229001582021033017351627",
  36954. PsnNo: "44020000001102481733",
  36955. Info: "2207",
  36956. }
  36957. customData = append(customData, custom1212)
  36958. custom13 := &CustomData{
  36959. MsgId: "H44022900158202103301740327951",
  36960. PsnNo: "44020000001103174866",
  36961. Info: "2207",
  36962. }
  36963. customData = append(customData, custom13)
  36964. custom14 := &CustomData{
  36965. MsgId: "H4402290015820210330174922668",
  36966. PsnNo: "44020000001102927272",
  36967. Info: "2207",
  36968. }
  36969. customData = append(customData, custom14)
  36970. custom15 := &CustomData{
  36971. MsgId: "H44022900158202103301752362273",
  36972. PsnNo: "44020000001102942890",
  36973. Info: "2207",
  36974. }
  36975. customData = append(customData, custom15)
  36976. custom16 := &CustomData{
  36977. MsgId: "H44022900158202103301751082917",
  36978. PsnNo: "44020000001101662162",
  36979. Info: "2207",
  36980. }
  36981. customData = append(customData, custom16)
  36982. custom17 := &CustomData{
  36983. MsgId: "H44022900158202103301754147728",
  36984. PsnNo: "44020000000229014511",
  36985. Info: "2207",
  36986. }
  36987. customData = append(customData, custom17)
  36988. adminUser := c.GetAdminUserInfo()
  36989. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36990. for _, item := range customData {
  36991. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  36992. fmt.Println(result)
  36993. }
  36994. }
  36995. func (c *HisApiController) GetAllopatry() {
  36996. year := c.GetString("year")
  36997. month := c.GetString("month")
  36998. admin_user_id, _ := c.GetInt64("admin_user_id")
  36999. adminUser := c.GetAdminUserInfo()
  37000. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37001. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37002. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37003. var dat map[string]interface{}
  37004. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37005. fmt.Println(dat)
  37006. } else {
  37007. fmt.Println(err)
  37008. }
  37009. userJSONBytes, _ := json.Marshal(dat)
  37010. var res models.Result9001
  37011. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37012. utils.ErrorLog("解析失败:%v", err)
  37013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37014. return
  37015. }
  37016. fmt.Println(res.Output.Signinoutb)
  37017. fmt.Println(res.Output.Signinoutb.SignNo)
  37018. fmt.Println(string(userJSONBytes))
  37019. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  37020. var dat3 map[string]interface{}
  37021. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  37022. fmt.Println(dat3)
  37023. } else {
  37024. fmt.Println(err)
  37025. }
  37026. userJSONBytes3, _ := json.Marshal(dat3)
  37027. var res3 models.Result3260
  37028. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  37029. utils.ErrorLog("解析失败:%v", err)
  37030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37031. return
  37032. }
  37033. var curpage int
  37034. var pagesize int = 100
  37035. var start int = 1
  37036. //var stop int
  37037. //pagecount := 10
  37038. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  37039. var res22 []models.Result3260
  37040. for curpage = 1; curpage <= pagecount; curpage++ {
  37041. if curpage == 1 {
  37042. start = 0
  37043. } else {
  37044. start = (curpage-1)*pagesize + 1
  37045. }
  37046. fmt.Println(start)
  37047. //stop = curpage * pagesize
  37048. //if stop > int(res3.Output.Totalrow) {
  37049. // stop =int(res3.Output.Totalrow)
  37050. //}
  37051. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  37052. var dat2 map[string]interface{}
  37053. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37054. fmt.Println(dat)
  37055. } else {
  37056. fmt.Println(err)
  37057. }
  37058. userJSONBytes2, _ := json.Marshal(dat2)
  37059. var res2 models.Result3260
  37060. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37061. utils.ErrorLog("解析失败:%v", err)
  37062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37063. return
  37064. }
  37065. if res2.Infcode == 0 {
  37066. res22 = append(res22, res2)
  37067. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37068. //var dat2 map[string]interface{}
  37069. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  37070. // fmt.Println(dat)
  37071. //} else {
  37072. // fmt.Println(err)
  37073. //}
  37074. //c.ServeSuccessJSON(map[string]interface{}{
  37075. // "list": res2.Output.Data,
  37076. //})
  37077. //continue
  37078. }
  37079. }
  37080. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  37081. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  37082. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  37083. //var dat2 map[string]interface{}
  37084. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37085. // fmt.Println(dat)
  37086. //} else {
  37087. // fmt.Println(err)
  37088. //}
  37089. //userJSONBytes2, _ := json.Marshal(dat2)
  37090. //var res2 models.Result3260
  37091. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37092. // utils.ErrorLog("解析失败:%v", err)
  37093. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37094. // return
  37095. //}
  37096. //if res2.Infcode == 0 {
  37097. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37098. // var dat2 map[string]interface{}
  37099. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  37100. // fmt.Println(dat)
  37101. // } else {
  37102. // fmt.Println(err)
  37103. // }
  37104. // c.ServeSuccessJSON(map[string]interface{}{
  37105. // "list": res2.Output.Data,
  37106. // })
  37107. //}
  37108. }
  37109. func (c *HisApiController) ComfirmAllopatry() {
  37110. year := c.GetString("year")
  37111. month := c.GetString("month")
  37112. admin_user_id, _ := c.GetInt64("admin_user_id")
  37113. adminUser := c.GetAdminUserInfo()
  37114. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37115. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37116. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37117. var dat map[string]interface{}
  37118. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37119. fmt.Println(dat)
  37120. } else {
  37121. fmt.Println(err)
  37122. }
  37123. userJSONBytes, _ := json.Marshal(dat)
  37124. var res models.Result9001
  37125. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37126. utils.ErrorLog("解析失败:%v", err)
  37127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37128. return
  37129. }
  37130. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  37131. var dat2 map[string]interface{}
  37132. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37133. fmt.Println(dat)
  37134. } else {
  37135. fmt.Println(err)
  37136. }
  37137. userJSONBytes2, _ := json.Marshal(dat2)
  37138. var res2 models.Result3260
  37139. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37140. utils.ErrorLog("解析失败:%v", err)
  37141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37142. return
  37143. }
  37144. //if res2.Infcode == 0 {
  37145. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  37146. // var dat map[string]interface{}
  37147. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37148. // fmt.Println(dat)
  37149. // } else {
  37150. // fmt.Println(err)
  37151. // }
  37152. // userJSONBytes, _ := json.Marshal(dat)
  37153. // var res3 models.Result3261
  37154. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  37155. // utils.ErrorLog("解析失败:%v", err)
  37156. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37157. // return
  37158. // }
  37159. //
  37160. // if res3.Infcode == 0 {
  37161. // record := &models.HisYidiClearRecord{
  37162. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37163. // Ctime: time.Now().Unix(),
  37164. // Mtime: time.Now().Unix(),
  37165. // Status: 1,
  37166. // MsgId: msgId,
  37167. // }
  37168. // service.SaveClearRecord(record)
  37169. // c.ServeSuccessJSON(map[string]interface{}{
  37170. // "msg": "提取成功",
  37171. // })
  37172. // }
  37173. //}
  37174. }
  37175. func (c *HisApiController) RefundAllopatry() {
  37176. year := c.GetString("year")
  37177. month := c.GetString("month")
  37178. //id, _ := c.GetInt64("id")
  37179. admin_user_id, _ := c.GetInt64("admin_user_id")
  37180. adminUser := c.GetAdminUserInfo()
  37181. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37182. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37183. //record, _ := service.GetClearRecordById(id)
  37184. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  37185. var dat map[string]interface{}
  37186. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  37187. fmt.Println(dat)
  37188. } else {
  37189. fmt.Println(err)
  37190. }
  37191. userJSONBytes, _ := json.Marshal(dat)
  37192. var res models.Result9001
  37193. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37194. utils.ErrorLog("解析失败:%v", err)
  37195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37196. return
  37197. }
  37198. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  37199. var dat2 map[string]interface{}
  37200. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  37201. fmt.Println(dat)
  37202. } else {
  37203. fmt.Println(err)
  37204. }
  37205. userJSONBytes2, _ := json.Marshal(dat2)
  37206. var empty ResultFourteen
  37207. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  37208. utils.ErrorLog("解析失败:%v", err)
  37209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37210. return
  37211. }
  37212. if empty.Infcode == 0 {
  37213. c.ServeSuccessJSON(map[string]interface{}{
  37214. "msg": "撤销成功",
  37215. })
  37216. return
  37217. }
  37218. }
  37219. func (c *HisApiController) ReversalOtherData() {
  37220. var customData []*CustomData
  37221. custom := &CustomData{
  37222. MsgId: "H44022900158202103301714472004",
  37223. PsnNo: "44020000001101329945",
  37224. Info: "2208",
  37225. }
  37226. customData = append(customData, custom)
  37227. custom1 := &CustomData{
  37228. MsgId: "H4402290015820210330172057803",
  37229. PsnNo: "44020000001101161813",
  37230. Info: "2208",
  37231. }
  37232. customData = append(customData, custom1)
  37233. custom2 := &CustomData{
  37234. MsgId: "H44022900158202103301705198813",
  37235. PsnNo: "44190000133097375417",
  37236. Info: "2208",
  37237. }
  37238. customData = append(customData, custom2)
  37239. custom3 := &CustomData{
  37240. MsgId: "H44022900158202103301715524756",
  37241. PsnNo: "44020000001100187221",
  37242. Info: "2208",
  37243. }
  37244. customData = append(customData, custom3)
  37245. custom4 := &CustomData{
  37246. MsgId: "H44022900158202103301730376224",
  37247. PsnNo: "44020000001101959155",
  37248. Info: "2208",
  37249. }
  37250. customData = append(customData, custom4)
  37251. custom5 := &CustomData{
  37252. MsgId: "H44022900158202103301748008725",
  37253. PsnNo: "44020000001104246641",
  37254. Info: "2208",
  37255. }
  37256. customData = append(customData, custom5)
  37257. custom6 := &CustomData{
  37258. MsgId: "H44022900158202103301718096755",
  37259. PsnNo: "44020000001102211860",
  37260. Info: "2208",
  37261. }
  37262. customData = append(customData, custom6)
  37263. custom7 := &CustomData{
  37264. MsgId: "H44022900158202103301736551640",
  37265. PsnNo: "44020000001102687718",
  37266. Info: "2208",
  37267. }
  37268. customData = append(customData, custom7)
  37269. custom8 := &CustomData{
  37270. MsgId: "H44022900158202103301743097676",
  37271. PsnNo: "44020000001102127785",
  37272. Info: "2208",
  37273. }
  37274. customData = append(customData, custom8)
  37275. custom9 := &CustomData{
  37276. MsgId: "H44022900158202103301712304203",
  37277. PsnNo: "44020000001101518097",
  37278. Info: "2208",
  37279. }
  37280. customData = append(customData, custom9)
  37281. custom10 := &CustomData{
  37282. MsgId: "H44022900158202103301738448785",
  37283. PsnNo: "44020000001100500813",
  37284. Info: "2208",
  37285. }
  37286. customData = append(customData, custom10)
  37287. custom11 := &CustomData{
  37288. MsgId: "H44022900158202103301732455843",
  37289. PsnNo: "44020000001102690557",
  37290. Info: "2208",
  37291. }
  37292. customData = append(customData, custom11)
  37293. custom12 := &CustomData{
  37294. MsgId: "H44022900158202103301745421708",
  37295. PsnNo: "44020000001102211928",
  37296. Info: "2208",
  37297. }
  37298. customData = append(customData, custom12)
  37299. custom1212 := &CustomData{
  37300. MsgId: "H440229001582021033017351627",
  37301. PsnNo: "44020000001102481733",
  37302. Info: "2208",
  37303. }
  37304. customData = append(customData, custom1212)
  37305. custom13 := &CustomData{
  37306. MsgId: "H44022900158202103301740327951",
  37307. PsnNo: "44020000001103174866",
  37308. Info: "2208",
  37309. }
  37310. customData = append(customData, custom13)
  37311. custom14 := &CustomData{
  37312. MsgId: "H4402290015820210330174922668",
  37313. PsnNo: "44020000001102927272",
  37314. Info: "2208",
  37315. }
  37316. customData = append(customData, custom14)
  37317. custom15 := &CustomData{
  37318. MsgId: "H44022900158202103301752362273",
  37319. PsnNo: "44020000001102942890",
  37320. Info: "2208",
  37321. }
  37322. customData = append(customData, custom15)
  37323. custom16 := &CustomData{
  37324. MsgId: "H44022900158202103301751082917",
  37325. PsnNo: "44020000001101662162",
  37326. Info: "2208",
  37327. }
  37328. customData = append(customData, custom16)
  37329. custom17 := &CustomData{
  37330. MsgId: "H44022900158202103301754147728",
  37331. PsnNo: "44020000000229014511",
  37332. Info: "2208",
  37333. }
  37334. customData = append(customData, custom17)
  37335. adminUser := c.GetAdminUserInfo()
  37336. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37337. for _, item := range customData {
  37338. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  37339. fmt.Println(result)
  37340. }
  37341. }
  37342. func PathExists(path string) (bool, error) {
  37343. _, err := os.Stat(path)
  37344. if err == nil {
  37345. return true, nil
  37346. }
  37347. if os.IsNotExist(err) {
  37348. return false, nil
  37349. }
  37350. return false, err
  37351. }
  37352. // 创建文件夹
  37353. func Mkdir(dir string) {
  37354. // 创建文件夹
  37355. exist, err := PathExists(dir)
  37356. if err != nil {
  37357. fmt.Println(err.Error())
  37358. } else {
  37359. if exist {
  37360. fmt.Println(dir + "文件夹已存在!")
  37361. } else {
  37362. // 文件夹名称,权限
  37363. err := os.Mkdir(dir, os.ModePerm)
  37364. if err != nil {
  37365. fmt.Println(dir+"文件夹创建失败:", err.Error())
  37366. } else {
  37367. fmt.Println(dir + "文件夹创建成功!")
  37368. }
  37369. }
  37370. }
  37371. }
  37372. // 压缩文件
  37373. func Zip(srcFile string, destZip string) error {
  37374. zipfile, err := os.Create(destZip)
  37375. if err != nil {
  37376. return err
  37377. }
  37378. defer zipfile.Close()
  37379. archive := zip.NewWriter(zipfile)
  37380. defer archive.Close()
  37381. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  37382. if err != nil {
  37383. return err
  37384. }
  37385. header, err := zip.FileInfoHeader(info)
  37386. if err != nil {
  37387. return err
  37388. }
  37389. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  37390. // header.Name = path
  37391. if info.IsDir() {
  37392. header.Name += "/"
  37393. } else {
  37394. header.Method = zip.Deflate
  37395. }
  37396. writer, err := archive.CreateHeader(header)
  37397. if err != nil {
  37398. return err
  37399. }
  37400. if !info.IsDir() {
  37401. file, err := os.Open(path)
  37402. if err != nil {
  37403. return err
  37404. }
  37405. defer file.Close()
  37406. _, err = io.Copy(writer, file)
  37407. }
  37408. return err
  37409. })
  37410. return err
  37411. }
  37412. func ReadFile(filePath string) []byte {
  37413. f, err := os.Open(filePath)
  37414. if err != nil {
  37415. fmt.Println("read file fail", err)
  37416. return nil
  37417. }
  37418. defer f.Close()
  37419. fd, err := ioutil.ReadAll(f)
  37420. if err != nil {
  37421. fmt.Println("read to fd fail", err)
  37422. return nil
  37423. }
  37424. return fd
  37425. }
  37426. func saveLogq(result string, request string, infno string, desc string) {
  37427. dir := "日志"
  37428. utils.Mkdir(dir)
  37429. month := time.Unix(1557042972, 0).Format("1")
  37430. year := time.Now().Format("2006")
  37431. month = time.Now().Format("01")
  37432. day := time.Now().Format("02")
  37433. hour := time.Now().Format("15")
  37434. min := time.Now().Format("04")
  37435. sec := time.Now().Format("05")
  37436. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37437. file := year + month + day + "_log"
  37438. file_name := file + ".txt"
  37439. file_path := "日志" + "/" + file_name
  37440. exist, _ := utils.PathExists(file_path)
  37441. if exist { //存在
  37442. fmt.Println("存在")
  37443. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37444. if err != nil {
  37445. fmt.Println("read fail")
  37446. }
  37447. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37448. n, _ := f.Seek(0, 2)
  37449. _, err = f.WriteAt([]byte(content), n)
  37450. } else { //不存在
  37451. fmt.Println("文件不存在,创建文件")
  37452. f, err := os.Create("日志" + "/" + file_name)
  37453. defer f.Close()
  37454. if err != nil {
  37455. } else {
  37456. _, err = f.Write([]byte("记录日志"))
  37457. }
  37458. }
  37459. }
  37460. func saveLog(result string, request string, infno string, desc string) {
  37461. org_id, _ := beego.AppConfig.Int64("org_id")
  37462. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37463. dir := miConfig.OrgName + "日志"
  37464. utils.Mkdir(dir)
  37465. month := time.Unix(1557042972, 0).Format("1")
  37466. year := time.Now().Format("2006")
  37467. month = time.Now().Format("01")
  37468. day := time.Now().Format("02")
  37469. hour := time.Now().Format("15")
  37470. min := time.Now().Format("04")
  37471. sec := time.Now().Format("05")
  37472. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  37473. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  37474. file_name := file + ".txt"
  37475. file_path := miConfig.OrgName + "日志" + "/" + file_name
  37476. exist, _ := utils.PathExists(file_path)
  37477. if exist { //存在
  37478. fmt.Println("存在")
  37479. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  37480. if err != nil {
  37481. fmt.Println("read fail")
  37482. }
  37483. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  37484. n, _ := f.Seek(0, 2)
  37485. _, err = f.WriteAt([]byte(content), n)
  37486. } else { //不存在
  37487. fmt.Println("文件不存在,创建文件")
  37488. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  37489. defer f.Close()
  37490. if err != nil {
  37491. } else {
  37492. _, err = f.Write([]byte("记录日志"))
  37493. }
  37494. }
  37495. }
  37496. type Charset string
  37497. const (
  37498. UTF8 = Charset("UTF-8")
  37499. GB18030 = Charset("GB18030")
  37500. )
  37501. func ConvertToString(src string, srcCode string, tagCode string) string {
  37502. srcCoder := mahonia.NewDecoder(srcCode)
  37503. srcResult := srcCoder.ConvertString(src)
  37504. tagCoder := mahonia.NewDecoder(tagCode)
  37505. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  37506. result := string(cdata)
  37507. return result
  37508. }
  37509. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  37510. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37511. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37512. var token string
  37513. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37514. var api string
  37515. if miConfig.MdtrtareaAdmvs == "320921" {
  37516. 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 +
  37517. "&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
  37518. fmt.Println(api)
  37519. } else {
  37520. 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 +
  37521. "&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
  37522. }
  37523. resp, requestErr := http.Get(api)
  37524. if requestErr != nil {
  37525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37526. return ""
  37527. }
  37528. body, ioErr := ioutil.ReadAll(resp.Body)
  37529. if ioErr != nil {
  37530. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37532. return ""
  37533. }
  37534. var respJSON map[string]interface{}
  37535. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37536. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37538. return ""
  37539. }
  37540. var status string
  37541. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37542. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37543. var res ResultTwo //1101结果
  37544. var res10265 ResultTwo10265 //1101结果
  37545. if status == "0" { //读卡成功
  37546. var card_info string //卡信息
  37547. var busi_card_info string
  37548. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37549. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37550. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37551. fmt.Println(card_info)
  37552. fmt.Println(busi_card_info)
  37553. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37554. result, _ := json.Marshal(respJSON)
  37555. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37556. utils.ErrorLog("解析失败:%v", err)
  37557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37558. return ""
  37559. }
  37560. res.ErrMsg = res10265.ErrMsg
  37561. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37562. res.Infcode = infocode
  37563. res.Output = res10265.Output
  37564. res.InfRefmsgid = res10265.InfRefmsgid
  37565. if res.Infcode == 0 {
  37566. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37567. if err == gorm.ErrRecordNotFound {
  37568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37569. return ""
  37570. } else if err != nil {
  37571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37572. return ""
  37573. } else {
  37574. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37575. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37576. infoStr := string(Iinfos)
  37577. idetinfoStr := string(Idetinfos)
  37578. psn := &models.HisPsn{
  37579. PsnNo: res.Output.Baseinfo.PsnNo,
  37580. PatientId: patient.ID,
  37581. Certno: res.Output.Baseinfo.Certno,
  37582. Gend: res.Output.Baseinfo.Gend,
  37583. Naty: res.Output.Baseinfo.Naty,
  37584. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37585. PsnName: res.Output.Baseinfo.PsnName,
  37586. Idetinfo: idetinfoStr,
  37587. Insuinfo: infoStr,
  37588. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37589. CardInfo: card_info,
  37590. VerifyNumber: token,
  37591. }
  37592. service.CreateHisPsn(psn)
  37593. return token
  37594. }
  37595. }
  37596. } else {
  37597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37598. return ""
  37599. }
  37600. } else { //读卡失败
  37601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37602. return ""
  37603. }
  37604. return token
  37605. }
  37606. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  37607. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37608. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37609. var token string
  37610. var api string
  37611. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  37612. "&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
  37613. fmt.Println(api)
  37614. resp, requestErr := http.Get(api)
  37615. if requestErr != nil {
  37616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37617. return ""
  37618. }
  37619. body, ioErr := ioutil.ReadAll(resp.Body)
  37620. if ioErr != nil {
  37621. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37623. return ""
  37624. }
  37625. var respJSON map[string]interface{}
  37626. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37627. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37629. return ""
  37630. }
  37631. var status string
  37632. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37633. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37634. var res ResultTwo //1101结果
  37635. if status == "1" { //读卡成功
  37636. var card_info string //卡信息
  37637. var busi_card_info string
  37638. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37639. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37640. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37641. fmt.Println(card_info)
  37642. fmt.Println(busi_card_info)
  37643. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37644. result, _ := json.Marshal(respJSON)
  37645. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37646. utils.ErrorLog("解析失败:%v", err)
  37647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37648. return ""
  37649. }
  37650. if res.Infcode == 0 {
  37651. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37652. if err == gorm.ErrRecordNotFound {
  37653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37654. return ""
  37655. } else if err != nil {
  37656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37657. return ""
  37658. } else {
  37659. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37660. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37661. infoStr := string(Iinfos)
  37662. idetinfoStr := string(Idetinfos)
  37663. psn := &models.HisPsn{
  37664. PsnNo: res.Output.Baseinfo.PsnNo,
  37665. PatientId: patient.ID,
  37666. Certno: res.Output.Baseinfo.Certno,
  37667. Gend: res.Output.Baseinfo.Gend,
  37668. Naty: res.Output.Baseinfo.Naty,
  37669. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37670. PsnName: res.Output.Baseinfo.PsnName,
  37671. Idetinfo: idetinfoStr,
  37672. Insuinfo: infoStr,
  37673. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37674. CardInfo: card_info,
  37675. VerifyNumber: token,
  37676. }
  37677. service.CreateHisPsn(psn)
  37678. return token
  37679. }
  37680. }
  37681. } else {
  37682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37683. return ""
  37684. }
  37685. return token
  37686. }
  37687. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  37688. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  37689. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  37690. var token string
  37691. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  37692. var api string
  37693. if miConfig.MdtrtareaAdmvs == "320921" {
  37694. 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 +
  37695. "&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
  37696. fmt.Println(api)
  37697. } else {
  37698. 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 +
  37699. "&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
  37700. }
  37701. resp, requestErr := http.Get(api)
  37702. if requestErr != nil {
  37703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37704. return ""
  37705. }
  37706. body, ioErr := ioutil.ReadAll(resp.Body)
  37707. if ioErr != nil {
  37708. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37710. return ""
  37711. }
  37712. var respJSON map[string]interface{}
  37713. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37714. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37716. return ""
  37717. }
  37718. var status string
  37719. status = respJSON["data"].(map[string]interface{})["status"].(string)
  37720. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  37721. var res ResultTwo //1101结果
  37722. var res10265 ResultTwo10265 //1101结果
  37723. if status == "0" { //读卡成功
  37724. var card_info string //卡信息
  37725. var busi_card_info string
  37726. token = respJSON["data"].(map[string]interface{})["token"].(string)
  37727. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  37728. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  37729. fmt.Println(card_info)
  37730. fmt.Println(busi_card_info)
  37731. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  37732. result, _ := json.Marshal(respJSON)
  37733. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37734. utils.ErrorLog("解析失败:%v", err)
  37735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37736. return ""
  37737. }
  37738. res.ErrMsg = res10265.ErrMsg
  37739. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37740. res.Infcode = infocode
  37741. res.Output = res10265.Output
  37742. res.InfRefmsgid = res10265.InfRefmsgid
  37743. if res.Infcode == 0 {
  37744. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  37745. if err == gorm.ErrRecordNotFound {
  37746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  37747. return ""
  37748. } else if err != nil {
  37749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  37750. return ""
  37751. } else {
  37752. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37753. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37754. infoStr := string(Iinfos)
  37755. idetinfoStr := string(Idetinfos)
  37756. psn := &models.HisPsn{
  37757. PsnNo: res.Output.Baseinfo.PsnNo,
  37758. PatientId: patient.ID,
  37759. Certno: res.Output.Baseinfo.Certno,
  37760. Gend: res.Output.Baseinfo.Gend,
  37761. Naty: res.Output.Baseinfo.Naty,
  37762. PsnCertType: res.Output.Baseinfo.PsnCertType,
  37763. PsnName: res.Output.Baseinfo.PsnName,
  37764. Idetinfo: idetinfoStr,
  37765. Insuinfo: infoStr,
  37766. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  37767. CardInfo: card_info,
  37768. VerifyNumber: token,
  37769. }
  37770. service.CreateHisPsn(psn)
  37771. return token
  37772. }
  37773. }
  37774. } else {
  37775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37776. return ""
  37777. }
  37778. } else { //读卡失败
  37779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37780. return ""
  37781. }
  37782. return token
  37783. }
  37784. func DeleteExtraSpaceTwo(s string) string {
  37785. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37786. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37787. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37788. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37789. s2 := make([]byte, len(s1)) //定义字符数组切片
  37790. copy(s2, s1) //将字符串复制到切片
  37791. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37792. for len(spc_index) > 0 { //找到适配项
  37793. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37794. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37795. }
  37796. return string(s2)
  37797. }
  37798. func Remove0000(s string) string {
  37799. str := make([]rune, 0, len(s))
  37800. for _, v := range []rune(s) {
  37801. if v == 0 {
  37802. continue
  37803. }
  37804. str = append(str, v)
  37805. }
  37806. return string(str)
  37807. }
  37808. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  37809. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  37810. readCard := DllDef.MustFindProc("EcQuery")
  37811. pCardInfo := make([]byte, 8192)
  37812. pBusiCardInfo := make([]byte, 8192)
  37813. data := make(map[string]interface{})
  37814. //pData := make(map[string]interface{})
  37815. inputData := make(map[string]interface{})
  37816. inputData["orgId"] = code
  37817. inputData["businessType"] = "01101"
  37818. inputData["operatorId"] = operator_id
  37819. inputData["operatorName"] = operator_name
  37820. inputData["officeId"] = "001"
  37821. inputData["officeName"] = "血透室"
  37822. //
  37823. data["data"] = inputData
  37824. data["transType"] = "ec.query"
  37825. data["orgId"] = code
  37826. bytesData, _ := json.Marshal(data)
  37827. pCardInfo = bytesData
  37828. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  37829. fmt.Println(ret2)
  37830. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  37831. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  37832. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  37833. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  37834. if ret2 != 0 {
  37835. return "", ""
  37836. }
  37837. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  37838. }
  37839. func DeleteExtraSpace(s string) string {
  37840. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  37841. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  37842. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  37843. reg, _ := regexp.Compile(regstr) //编译正则表达式
  37844. s2 := make([]byte, len(s1)) //定义字符数组切片
  37845. copy(s2, s1) //将字符串复制到切片
  37846. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  37847. for len(spc_index) > 0 { //找到适配项
  37848. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  37849. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  37850. }
  37851. return string(s2)
  37852. }
  37853. // 对账
  37854. func (c *HisApiController) Post3202() {
  37855. start_time := c.GetString("start_time")
  37856. end_time := c.GetString("end_time")
  37857. //insutype := c.GetString("insutype")
  37858. clr_type := c.GetString("clr_type")
  37859. clr_org := c.GetString("clr_optins")
  37860. admin_user_id, _ := c.GetInt64("admin_user_id")
  37861. adminUser := c.GetAdminUserInfo()
  37862. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37863. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37864. if len(clr_org) == 0 {
  37865. clr_org = miConfig.MdtrtareaAdmvs
  37866. }
  37867. timeLayout := "2006-01-02"
  37868. loc, _ := time.LoadLocation("Local")
  37869. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  37870. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  37871. var orders []*models.HisOrder
  37872. if clr_org == "421300" {
  37873. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37874. } else if clr_org == "420902" {
  37875. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37876. } else {
  37877. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  37878. }
  37879. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  37880. //fixmedins_setl_cnt := int64(len(orders))
  37881. var medfee_sumamt float64
  37882. var acct_pay float64
  37883. var fund_pay_sumamt float64
  37884. for _, item := range orders {
  37885. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  37886. acct_pay = acct_pay + item.AcctPay
  37887. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  37888. }
  37889. //var medfee_sumamt_two float64
  37890. //var acct_pay_two float64
  37891. //var fund_pay_sumamt_two float64
  37892. //for _, item := range orders_two {
  37893. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  37894. // acct_pay_two = acct_pay_two + item.AcctPay
  37895. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  37896. //}
  37897. //var user_name string
  37898. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37899. //if role.ID == 0 {
  37900. // user_name = "xxx"
  37901. //} else {
  37902. // user_name = role.UserName
  37903. //}
  37904. var res ResultSix
  37905. if config.IsOpen == 1 {
  37906. var bps []*models.BusinessParamsTwo
  37907. var bp models.BusinessParamsTwo
  37908. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  37909. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  37910. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  37911. bp.MedfeeSumamt = medfee_sumamt_str
  37912. bp.AcctPay = acct_pay_str
  37913. bp.FundPaySumamt = fund_pay_sumamt_str
  37914. bp.Insutype = ""
  37915. bp.StmtBegndate = start_time
  37916. bp.ClrType = clr_type
  37917. bp.SetlOptins = clr_org
  37918. bp.StmtEnddate = end_time
  37919. bps = append(bps, &bp)
  37920. data := make(map[string]interface{})
  37921. data["bps"] = bps
  37922. data["org_name"] = miConfig.OrgName
  37923. data["doctor"] = role.UserName
  37924. data["fixmedins_code"] = miConfig.Code
  37925. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37926. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  37927. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  37928. if miConfig.MdtrtareaAdmvs == "421300" {
  37929. client := &http.Client{}
  37930. bytesData, _ := json.Marshal(data)
  37931. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37932. resp, _ := client.Do(req)
  37933. defer resp.Body.Close()
  37934. body, ioErr := ioutil.ReadAll(resp.Body)
  37935. if ioErr != nil {
  37936. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37938. return
  37939. }
  37940. var respJSON map[string]interface{}
  37941. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37942. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37944. return
  37945. }
  37946. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37947. userJSONBytes, _ := json.Marshal(respJSON)
  37948. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37949. utils.ErrorLog("解析失败:%v", err)
  37950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37951. return
  37952. }
  37953. }
  37954. if miConfig.MdtrtareaAdmvs == "420200" {
  37955. client := &http.Client{}
  37956. bytesData, _ := json.Marshal(data)
  37957. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  37958. resp, _ := client.Do(req)
  37959. defer resp.Body.Close()
  37960. body, ioErr := ioutil.ReadAll(resp.Body)
  37961. if ioErr != nil {
  37962. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37964. return
  37965. }
  37966. var respJSON map[string]interface{}
  37967. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37968. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37970. return
  37971. }
  37972. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37973. userJSONBytes, _ := json.Marshal(respJSON)
  37974. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37975. utils.ErrorLog("解析失败:%v", err)
  37976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37977. return
  37978. }
  37979. }
  37980. if miConfig.MdtrtareaAdmvs == "421182" {
  37981. client := &http.Client{}
  37982. bytesData, _ := json.Marshal(data)
  37983. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  37984. resp, _ := client.Do(req)
  37985. defer resp.Body.Close()
  37986. body, ioErr := ioutil.ReadAll(resp.Body)
  37987. if ioErr != nil {
  37988. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37990. return
  37991. }
  37992. var respJSON map[string]interface{}
  37993. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  37994. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37996. return
  37997. }
  37998. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37999. userJSONBytes, _ := json.Marshal(respJSON)
  38000. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38001. utils.ErrorLog("解析失败:%v", err)
  38002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38003. return
  38004. }
  38005. }
  38006. if miConfig.MdtrtareaAdmvs == "420902" {
  38007. client := &http.Client{}
  38008. bytesData, _ := json.Marshal(data)
  38009. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  38010. resp, _ := client.Do(req)
  38011. defer resp.Body.Close()
  38012. body, ioErr := ioutil.ReadAll(resp.Body)
  38013. if ioErr != nil {
  38014. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38016. return
  38017. }
  38018. var respJSON map[string]interface{}
  38019. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38020. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38022. return
  38023. }
  38024. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38025. userJSONBytes, _ := json.Marshal(respJSON)
  38026. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38027. utils.ErrorLog("解析失败:%v", err)
  38028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38029. return
  38030. }
  38031. }
  38032. if res.Infcode == 0 {
  38033. c.ServeSuccessJSON(map[string]interface{}{
  38034. "msg": "发起成功",
  38035. })
  38036. } else {
  38037. c.ServeSuccessJSON(map[string]interface{}{
  38038. "failed_code": -10,
  38039. "msg": res.ErrMsg,
  38040. })
  38041. }
  38042. }
  38043. }
  38044. func (c *HisApiController) Post3204a() {
  38045. start_time := c.GetString("start_time")
  38046. end_time := c.GetString("end_time")
  38047. //insutype := c.GetString("insutype")
  38048. clr_type := c.GetString("clr_type")
  38049. clr_org := c.GetString("clr_optins")
  38050. admin_user_id, _ := c.GetInt64("admin_user_id")
  38051. adminUser := c.GetAdminUserInfo()
  38052. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38053. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38054. if len(clr_org) == 0 {
  38055. clr_org = miConfig.MdtrtareaAdmvs
  38056. }
  38057. timeLayout := "2006-01-02"
  38058. loc, _ := time.LoadLocation("Local")
  38059. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38060. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38061. var orders []*models.HisOrder
  38062. if clr_org == "421300" {
  38063. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38064. } else if clr_org == "420902" {
  38065. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38066. } else {
  38067. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38068. }
  38069. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38070. //fixmedins_setl_cnt := int64(len(orders))
  38071. var medfee_sumamt float64
  38072. var acct_pay float64
  38073. var fund_pay_sumamt float64
  38074. for _, item := range orders {
  38075. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38076. acct_pay = acct_pay + item.AcctPay
  38077. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38078. }
  38079. //var medfee_sumamt_two float64
  38080. //var acct_pay_two float64
  38081. //var fund_pay_sumamt_two float64
  38082. //for _, item := range orders_two {
  38083. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38084. // acct_pay_two = acct_pay_two + item.AcctPay
  38085. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38086. //}
  38087. //var user_name string
  38088. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38089. //if role.ID == 0 {
  38090. // user_name = "xxx"
  38091. //} else {
  38092. // user_name = role.UserName
  38093. //}
  38094. var res ResultSix
  38095. if config.IsOpen == 1 {
  38096. var bps []*models.BusinessParamsTwo
  38097. var bp models.BusinessParamsTwo
  38098. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38099. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38100. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38101. bp.MedfeeSumamt = medfee_sumamt_str
  38102. bp.AcctPay = acct_pay_str
  38103. bp.FundPaySumamt = fund_pay_sumamt_str
  38104. bp.Insutype = ""
  38105. bp.StmtBegndate = start_time
  38106. bp.ClrType = clr_type
  38107. bp.SetlOptins = clr_org
  38108. bp.StmtEnddate = end_time
  38109. bps = append(bps, &bp)
  38110. data := make(map[string]interface{})
  38111. data["bps"] = bps
  38112. data["org_name"] = miConfig.OrgName
  38113. data["doctor"] = role.UserName
  38114. data["fixmedins_code"] = miConfig.Code
  38115. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38116. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38117. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38118. if miConfig.MdtrtareaAdmvs == "421300" {
  38119. client := &http.Client{}
  38120. bytesData, _ := json.Marshal(data)
  38121. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  38122. resp, _ := client.Do(req)
  38123. defer resp.Body.Close()
  38124. body, ioErr := ioutil.ReadAll(resp.Body)
  38125. if ioErr != nil {
  38126. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38128. return
  38129. }
  38130. var respJSON map[string]interface{}
  38131. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38134. return
  38135. }
  38136. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38137. userJSONBytes, _ := json.Marshal(respJSON)
  38138. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38139. utils.ErrorLog("解析失败:%v", err)
  38140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38141. return
  38142. }
  38143. }
  38144. if miConfig.MdtrtareaAdmvs == "420200" {
  38145. client := &http.Client{}
  38146. bytesData, _ := json.Marshal(data)
  38147. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  38148. resp, _ := client.Do(req)
  38149. defer resp.Body.Close()
  38150. body, ioErr := ioutil.ReadAll(resp.Body)
  38151. if ioErr != nil {
  38152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38154. return
  38155. }
  38156. var respJSON map[string]interface{}
  38157. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38160. return
  38161. }
  38162. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38163. userJSONBytes, _ := json.Marshal(respJSON)
  38164. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38165. utils.ErrorLog("解析失败:%v", err)
  38166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38167. return
  38168. }
  38169. }
  38170. if miConfig.MdtrtareaAdmvs == "421182" {
  38171. client := &http.Client{}
  38172. bytesData, _ := json.Marshal(data)
  38173. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38174. resp, _ := client.Do(req)
  38175. defer resp.Body.Close()
  38176. body, ioErr := ioutil.ReadAll(resp.Body)
  38177. if ioErr != nil {
  38178. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38180. return
  38181. }
  38182. var respJSON map[string]interface{}
  38183. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38184. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38186. return
  38187. }
  38188. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38189. userJSONBytes, _ := json.Marshal(respJSON)
  38190. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38191. utils.ErrorLog("解析失败:%v", err)
  38192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38193. return
  38194. }
  38195. }
  38196. if miConfig.MdtrtareaAdmvs == "420902" {
  38197. client := &http.Client{}
  38198. bytesData, _ := json.Marshal(data)
  38199. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  38200. resp, _ := client.Do(req)
  38201. defer resp.Body.Close()
  38202. body, ioErr := ioutil.ReadAll(resp.Body)
  38203. if ioErr != nil {
  38204. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38206. return
  38207. }
  38208. var respJSON map[string]interface{}
  38209. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38210. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38212. return
  38213. }
  38214. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38215. userJSONBytes, _ := json.Marshal(respJSON)
  38216. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38217. utils.ErrorLog("解析失败:%v", err)
  38218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38219. return
  38220. }
  38221. }
  38222. if res.Infcode == 0 {
  38223. c.ServeSuccessJSON(map[string]interface{}{
  38224. "msg": "撤销成功",
  38225. })
  38226. } else {
  38227. c.ServeSuccessJSON(map[string]interface{}{
  38228. "failed_code": -10,
  38229. "msg": res.ErrMsg,
  38230. })
  38231. }
  38232. }
  38233. }
  38234. func (c *HisApiController) Post3204() {
  38235. admin_user_id, _ := c.GetInt64("admin_user_id")
  38236. id := c.GetString("id")
  38237. adminUser := c.GetAdminUserInfo()
  38238. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38239. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38240. //clr_org := miConfig.MdtrtareaAdmvs
  38241. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38242. var res ResultSix
  38243. if config.IsOpen == 1 {
  38244. data := make(map[string]interface{})
  38245. data["id"] = id
  38246. data["org_name"] = miConfig.OrgName
  38247. data["doctor"] = role.UserName
  38248. data["fixmedins_code"] = miConfig.Code
  38249. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38250. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38251. client := &http.Client{}
  38252. bytesData, _ := json.Marshal(data)
  38253. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  38254. resp, _ := client.Do(req)
  38255. defer resp.Body.Close()
  38256. body, ioErr := ioutil.ReadAll(resp.Body)
  38257. if ioErr != nil {
  38258. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38260. return
  38261. }
  38262. var respJSON map[string]interface{}
  38263. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38264. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38266. return
  38267. }
  38268. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38269. userJSONBytes, _ := json.Marshal(respJSON)
  38270. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38271. utils.ErrorLog("解析失败:%v", err)
  38272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38273. return
  38274. }
  38275. if res.Infcode == 0 {
  38276. c.ServeSuccessJSON(map[string]interface{}{
  38277. "msg": "发起成功",
  38278. })
  38279. } else {
  38280. c.ServeSuccessJSON(map[string]interface{}{
  38281. "failed_code": -10,
  38282. "msg": res.ErrMsg,
  38283. })
  38284. }
  38285. }
  38286. }
  38287. func (c *HisApiController) Post8404() {
  38288. admin_user_id, _ := c.GetInt64("admin_user_id")
  38289. month := c.GetString("month")
  38290. adminUser := c.GetAdminUserInfo()
  38291. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38292. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38293. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38294. var res ResultSix
  38295. if config.IsOpen == 1 {
  38296. data := make(map[string]interface{})
  38297. data["month"] = month
  38298. data["org_name"] = miConfig.OrgName
  38299. data["doctor"] = role.UserName
  38300. data["fixmedins_code"] = miConfig.Code
  38301. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38302. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38303. client := &http.Client{}
  38304. bytesData, _ := json.Marshal(data)
  38305. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  38306. resp, _ := client.Do(req)
  38307. defer resp.Body.Close()
  38308. body, ioErr := ioutil.ReadAll(resp.Body)
  38309. if ioErr != nil {
  38310. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38312. return
  38313. }
  38314. var respJSON map[string]interface{}
  38315. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38316. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38318. return
  38319. }
  38320. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38321. userJSONBytes, _ := json.Marshal(respJSON)
  38322. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38323. utils.ErrorLog("解析失败:%v", err)
  38324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38325. return
  38326. }
  38327. if res.Infcode == 0 {
  38328. c.ServeSuccessJSON(map[string]interface{}{
  38329. "msg": "查询成功",
  38330. })
  38331. } else {
  38332. c.ServeSuccessJSON(map[string]interface{}{
  38333. "failed_code": -10,
  38334. "msg": res.ErrMsg,
  38335. })
  38336. }
  38337. }
  38338. }
  38339. func (c *HisApiController) Post3202b() {
  38340. start_time := c.GetString("start_time")
  38341. end_time := c.GetString("end_time")
  38342. //insutype := c.GetString("insutype")
  38343. clr_type := c.GetString("clr_type")
  38344. clr_org := c.GetString("clr_optins")
  38345. admin_user_id, _ := c.GetInt64("admin_user_id")
  38346. adminUser := c.GetAdminUserInfo()
  38347. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38348. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38349. if len(clr_org) == 0 {
  38350. clr_org = miConfig.MdtrtareaAdmvs
  38351. }
  38352. timeLayout := "2006-01-02"
  38353. loc, _ := time.LoadLocation("Local")
  38354. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38355. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38356. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38357. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38358. //fixmedins_setl_cnt := int64(len(orders))
  38359. var medfee_sumamt float64
  38360. var acct_pay float64
  38361. var fund_pay_sumamt float64
  38362. for _, item := range orders {
  38363. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38364. acct_pay = acct_pay + item.AcctPay
  38365. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  38366. }
  38367. //var medfee_sumamt_two float64
  38368. //var acct_pay_two float64
  38369. //var fund_pay_sumamt_two float64
  38370. //for _, item := range orders_two {
  38371. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  38372. // acct_pay_two = acct_pay_two + item.AcctPay
  38373. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  38374. //}
  38375. //var user_name string
  38376. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38377. //if role.ID == 0 {
  38378. // user_name = "xxx"
  38379. //} else {
  38380. // user_name = role.UserName
  38381. //}
  38382. var res ResultSix
  38383. if config.IsOpen == 1 {
  38384. var bps []*models.BusinessParamsTwo
  38385. var bp models.BusinessParamsTwo
  38386. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38387. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  38388. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  38389. bp.MedfeeSumamt = medfee_sumamt_str
  38390. bp.AcctPay = acct_pay_str
  38391. bp.FundPaySumamt = fund_pay_sumamt_str
  38392. bp.Insutype = "390"
  38393. bp.StmtBegndate = start_time
  38394. bp.ClrType = clr_type
  38395. bp.SetlOptins = clr_org
  38396. bp.StmtEnddate = end_time
  38397. bps = append(bps, &bp)
  38398. data := make(map[string]interface{})
  38399. data["bps"] = bps
  38400. data["org_name"] = miConfig.OrgName
  38401. data["doctor"] = role.UserName
  38402. data["fixmedins_code"] = miConfig.Code
  38403. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38404. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38405. if miConfig.MdtrtareaAdmvs == "421300" {
  38406. client := &http.Client{}
  38407. bytesData, _ := json.Marshal(data)
  38408. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38409. resp, _ := client.Do(req)
  38410. defer resp.Body.Close()
  38411. body, ioErr := ioutil.ReadAll(resp.Body)
  38412. if ioErr != nil {
  38413. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38415. return
  38416. }
  38417. var respJSON map[string]interface{}
  38418. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38419. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38421. return
  38422. }
  38423. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38424. userJSONBytes, _ := json.Marshal(respJSON)
  38425. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38426. utils.ErrorLog("解析失败:%v", err)
  38427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38428. return
  38429. }
  38430. }
  38431. if miConfig.MdtrtareaAdmvs == "420200" {
  38432. client := &http.Client{}
  38433. bytesData, _ := json.Marshal(data)
  38434. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  38435. resp, _ := client.Do(req)
  38436. defer resp.Body.Close()
  38437. body, ioErr := ioutil.ReadAll(resp.Body)
  38438. if ioErr != nil {
  38439. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38441. return
  38442. }
  38443. var respJSON map[string]interface{}
  38444. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38445. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38447. return
  38448. }
  38449. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38450. userJSONBytes, _ := json.Marshal(respJSON)
  38451. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38452. utils.ErrorLog("解析失败:%v", err)
  38453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38454. return
  38455. }
  38456. }
  38457. if miConfig.MdtrtareaAdmvs == "421182" {
  38458. client := &http.Client{}
  38459. bytesData, _ := json.Marshal(data)
  38460. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  38461. resp, _ := client.Do(req)
  38462. defer resp.Body.Close()
  38463. body, ioErr := ioutil.ReadAll(resp.Body)
  38464. if ioErr != nil {
  38465. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38467. return
  38468. }
  38469. var respJSON map[string]interface{}
  38470. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38471. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38473. return
  38474. }
  38475. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38476. userJSONBytes, _ := json.Marshal(respJSON)
  38477. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38478. utils.ErrorLog("解析失败:%v", err)
  38479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38480. return
  38481. }
  38482. }
  38483. if res.Infcode == 0 {
  38484. c.ServeSuccessJSON(map[string]interface{}{
  38485. "msg": "发起成功",
  38486. })
  38487. } else {
  38488. c.ServeSuccessJSON(map[string]interface{}{
  38489. "failed_code": -10,
  38490. "msg": res.ErrMsg,
  38491. })
  38492. }
  38493. }
  38494. }
  38495. func (c *HisApiController) Post1608() {
  38496. start_time := c.GetString("start_time")
  38497. end_time := c.GetString("end_time")
  38498. admin_user_id, _ := c.GetInt64("admin_user_id")
  38499. adminUser := c.GetAdminUserInfo()
  38500. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38501. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38502. timeLayout := "2006-01-02"
  38503. loc, _ := time.LoadLocation("Local")
  38504. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  38505. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  38506. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  38507. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  38508. fixmedins_setl_cnt := int64(len(orders))
  38509. var medfee_sumamt float64
  38510. var func_smamt float64
  38511. for _, item := range orders {
  38512. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  38513. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  38514. }
  38515. times := strings.Split(start_time, "-")
  38516. time_tows := strings.Split(end_time, "-")
  38517. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38518. var res ResultSix
  38519. if config.IsOpen == 1 {
  38520. //var bps []*models.BusinessParamsTwo
  38521. //var bp models.BusinessParamsTwo
  38522. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  38523. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  38524. data := make(map[string]interface{})
  38525. data["org_name"] = miConfig.OrgName
  38526. data["doctor"] = role.UserName
  38527. data["func_smamt"] = func_smamt_str
  38528. data["fixmedins_code"] = miConfig.Code
  38529. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38530. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38531. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  38532. data["medfee_sumamt"] = medfee_sumamt_str
  38533. data["start_time"] = times[0] + times[1] + times[2]
  38534. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  38535. if miConfig.MdtrtareaAdmvs == "421300" {
  38536. client := &http.Client{}
  38537. bytesData, _ := json.Marshal(data)
  38538. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38539. resp, _ := client.Do(req)
  38540. defer resp.Body.Close()
  38541. body, ioErr := ioutil.ReadAll(resp.Body)
  38542. if ioErr != nil {
  38543. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38545. return
  38546. }
  38547. var respJSON map[string]interface{}
  38548. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38549. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38551. return
  38552. }
  38553. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38554. userJSONBytes, _ := json.Marshal(respJSON)
  38555. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38556. utils.ErrorLog("解析失败:%v", err)
  38557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38558. return
  38559. }
  38560. }
  38561. if miConfig.MdtrtareaAdmvs == "420200" {
  38562. client := &http.Client{}
  38563. bytesData, _ := json.Marshal(data)
  38564. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  38565. resp, _ := client.Do(req)
  38566. defer resp.Body.Close()
  38567. body, ioErr := ioutil.ReadAll(resp.Body)
  38568. if ioErr != nil {
  38569. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38571. return
  38572. }
  38573. var respJSON map[string]interface{}
  38574. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38577. return
  38578. }
  38579. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38580. userJSONBytes, _ := json.Marshal(respJSON)
  38581. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38582. utils.ErrorLog("解析失败:%v", err)
  38583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38584. return
  38585. }
  38586. }
  38587. if miConfig.MdtrtareaAdmvs == "421182" {
  38588. client := &http.Client{}
  38589. bytesData, _ := json.Marshal(data)
  38590. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  38591. resp, _ := client.Do(req)
  38592. defer resp.Body.Close()
  38593. body, ioErr := ioutil.ReadAll(resp.Body)
  38594. if ioErr != nil {
  38595. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38597. return
  38598. }
  38599. var respJSON map[string]interface{}
  38600. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38601. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38603. return
  38604. }
  38605. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38606. userJSONBytes, _ := json.Marshal(respJSON)
  38607. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38608. utils.ErrorLog("解析失败:%v", err)
  38609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38610. return
  38611. }
  38612. }
  38613. if res.Infcode == 0 {
  38614. c.ServeSuccessJSON(map[string]interface{}{
  38615. "msg": "发起成功",
  38616. })
  38617. } else {
  38618. c.ServeSuccessJSON(map[string]interface{}{
  38619. "failed_code": -10,
  38620. "msg": res.ErrMsg,
  38621. })
  38622. }
  38623. }
  38624. }
  38625. // 5.11.1.1【5262】结算信息按时间段查询
  38626. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38627. admin_user_id, _ := c.GetInt64("admin_user_id")
  38628. adminUser := c.GetAdminUserInfo()
  38629. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38630. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38631. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38632. var res Result5262
  38633. if config.IsOpen == 1 {
  38634. if miConfig.MdtrtareaAdmvs == "421300" {
  38635. data := make(map[string]interface{})
  38636. data["bps"] = bp
  38637. data["org_name"] = miConfig.OrgName
  38638. data["doctor"] = role.UserName
  38639. data["fixmedins_code"] = miConfig.Code
  38640. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38641. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38642. data["page"] = strconv.FormatInt(page, 10)
  38643. data["limit"] = strconv.FormatInt(limit, 10)
  38644. fmt.Println(data)
  38645. client := &http.Client{}
  38646. bytesData, _ := json.Marshal(data)
  38647. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38648. resp, _ := client.Do(req)
  38649. defer resp.Body.Close()
  38650. body, ioErr := ioutil.ReadAll(resp.Body)
  38651. if ioErr != nil {
  38652. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38654. return
  38655. }
  38656. var respJSON map[string]interface{}
  38657. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38658. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38660. return
  38661. }
  38662. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38663. userJSONBytes, _ := json.Marshal(respJSON)
  38664. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38665. utils.ErrorLog("解析失败:%v", err)
  38666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38667. return
  38668. }
  38669. }
  38670. if miConfig.MdtrtareaAdmvs == "420200" {
  38671. data := make(map[string]interface{})
  38672. data["bps"] = bp
  38673. data["org_name"] = miConfig.OrgName
  38674. data["doctor"] = role.UserName
  38675. data["fixmedins_code"] = miConfig.Code
  38676. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38677. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38678. data["page"] = strconv.FormatInt(page, 10)
  38679. data["limit"] = strconv.FormatInt(limit, 10)
  38680. fmt.Println(data)
  38681. client := &http.Client{}
  38682. bytesData, _ := json.Marshal(data)
  38683. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  38684. resp, _ := client.Do(req)
  38685. defer resp.Body.Close()
  38686. body, ioErr := ioutil.ReadAll(resp.Body)
  38687. if ioErr != nil {
  38688. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38690. return
  38691. }
  38692. var respJSON map[string]interface{}
  38693. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38694. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38696. return
  38697. }
  38698. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38699. userJSONBytes, _ := json.Marshal(respJSON)
  38700. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38701. utils.ErrorLog("解析失败:%v", err)
  38702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38703. return
  38704. }
  38705. }
  38706. if miConfig.MdtrtareaAdmvs == "421182" {
  38707. data := make(map[string]interface{})
  38708. data["bps"] = bp
  38709. data["org_name"] = miConfig.OrgName
  38710. data["doctor"] = role.UserName
  38711. data["fixmedins_code"] = miConfig.Code
  38712. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38713. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38714. data["page"] = strconv.FormatInt(page, 10)
  38715. data["limit"] = strconv.FormatInt(limit, 10)
  38716. fmt.Println(data)
  38717. client := &http.Client{}
  38718. bytesData, _ := json.Marshal(data)
  38719. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38720. resp, _ := client.Do(req)
  38721. defer resp.Body.Close()
  38722. body, ioErr := ioutil.ReadAll(resp.Body)
  38723. if ioErr != nil {
  38724. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38726. return
  38727. }
  38728. var respJSON map[string]interface{}
  38729. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38732. return
  38733. }
  38734. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38735. userJSONBytes, _ := json.Marshal(respJSON)
  38736. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38737. utils.ErrorLog("解析失败:%v", err)
  38738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38739. return
  38740. }
  38741. }
  38742. if miConfig.MdtrtareaAdmvs == "420902" {
  38743. data := make(map[string]interface{})
  38744. data["bps"] = bp
  38745. data["org_name"] = miConfig.OrgName
  38746. data["doctor"] = role.UserName
  38747. data["fixmedins_code"] = miConfig.Code
  38748. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38749. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38750. data["page"] = strconv.FormatInt(page, 10)
  38751. data["limit"] = strconv.FormatInt(limit, 10)
  38752. fmt.Println(data)
  38753. client := &http.Client{}
  38754. bytesData, _ := json.Marshal(data)
  38755. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  38756. resp, _ := client.Do(req)
  38757. defer resp.Body.Close()
  38758. body, ioErr := ioutil.ReadAll(resp.Body)
  38759. if ioErr != nil {
  38760. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38762. return
  38763. }
  38764. var respJSON map[string]interface{}
  38765. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38766. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38768. return
  38769. }
  38770. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38771. userJSONBytes, _ := json.Marshal(respJSON)
  38772. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38773. utils.ErrorLog("解析失败:%v", err)
  38774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38775. return
  38776. }
  38777. }
  38778. if res.Infcode == 0 {
  38779. c.ServeSuccessJSON(map[string]interface{}{
  38780. "order": res.Output.Result,
  38781. "total": res.Output.PageInfo.RecordCounts,
  38782. })
  38783. } else {
  38784. c.ServeSuccessJSON(map[string]interface{}{
  38785. "failed_code": -10,
  38786. "msg": res.ErrMsg,
  38787. })
  38788. }
  38789. }
  38790. }
  38791. // 5.11.1.2【5267】异地结算信息时间段查询
  38792. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  38793. admin_user_id, _ := c.GetInt64("admin_user_id")
  38794. adminUser := c.GetAdminUserInfo()
  38795. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38796. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38797. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38798. var res Result5267
  38799. if config.IsOpen == 1 {
  38800. if miConfig.MdtrtareaAdmvs == "421300" {
  38801. data := make(map[string]interface{})
  38802. data["bps"] = bp
  38803. data["org_name"] = miConfig.OrgName
  38804. data["doctor"] = role.UserName
  38805. data["fixmedins_code"] = miConfig.Code
  38806. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38807. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38808. data["page"] = page
  38809. data["limit"] = limit
  38810. fmt.Println(data)
  38811. client := &http.Client{}
  38812. bytesData, _ := json.Marshal(data)
  38813. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38814. resp, _ := client.Do(req)
  38815. defer resp.Body.Close()
  38816. body, ioErr := ioutil.ReadAll(resp.Body)
  38817. if ioErr != nil {
  38818. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38820. return
  38821. }
  38822. var respJSON map[string]interface{}
  38823. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38826. return
  38827. }
  38828. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38829. userJSONBytes, _ := json.Marshal(respJSON)
  38830. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38831. utils.ErrorLog("解析失败:%v", err)
  38832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38833. return
  38834. }
  38835. }
  38836. if miConfig.MdtrtareaAdmvs == "420200" {
  38837. data := make(map[string]interface{})
  38838. data["bps"] = bp
  38839. data["org_name"] = miConfig.OrgName
  38840. data["doctor"] = role.UserName
  38841. data["fixmedins_code"] = miConfig.Code
  38842. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38843. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38844. data["page"] = page
  38845. data["limit"] = limit
  38846. fmt.Println(data)
  38847. client := &http.Client{}
  38848. bytesData, _ := json.Marshal(data)
  38849. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  38850. resp, _ := client.Do(req)
  38851. defer resp.Body.Close()
  38852. body, ioErr := ioutil.ReadAll(resp.Body)
  38853. if ioErr != nil {
  38854. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38856. return
  38857. }
  38858. var respJSON map[string]interface{}
  38859. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38862. return
  38863. }
  38864. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38865. userJSONBytes, _ := json.Marshal(respJSON)
  38866. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38867. utils.ErrorLog("解析失败:%v", err)
  38868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38869. return
  38870. }
  38871. }
  38872. if miConfig.MdtrtareaAdmvs == "421182" {
  38873. data := make(map[string]interface{})
  38874. data["bps"] = bp
  38875. data["org_name"] = miConfig.OrgName
  38876. data["doctor"] = role.UserName
  38877. data["fixmedins_code"] = miConfig.Code
  38878. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  38879. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  38880. data["page"] = page
  38881. data["limit"] = limit
  38882. fmt.Println(data)
  38883. client := &http.Client{}
  38884. bytesData, _ := json.Marshal(data)
  38885. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  38886. resp, _ := client.Do(req)
  38887. defer resp.Body.Close()
  38888. body, ioErr := ioutil.ReadAll(resp.Body)
  38889. if ioErr != nil {
  38890. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38892. return
  38893. }
  38894. var respJSON map[string]interface{}
  38895. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38896. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38898. return
  38899. }
  38900. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38901. userJSONBytes, _ := json.Marshal(respJSON)
  38902. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38903. utils.ErrorLog("解析失败:%v", err)
  38904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38905. return
  38906. }
  38907. }
  38908. if res.Infcode == 0 {
  38909. c.ServeSuccessJSON(map[string]interface{}{
  38910. "order": res.Output.Result,
  38911. "total": res.Output.PageInfo.RecordCounts,
  38912. })
  38913. } else {
  38914. c.ServeSuccessJSON(map[string]interface{}{
  38915. "failed_code": -10,
  38916. "msg": res.ErrMsg,
  38917. })
  38918. }
  38919. }
  38920. }
  38921. func (c *HisApiController) Post3501() {
  38922. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38923. data := make(map[string]interface{})
  38924. var struct3501s []models.Struct3501
  38925. var struct3501 models.Struct3501
  38926. struct3501.OrgName = miConfig.OrgName
  38927. struct3501.AccessKey = miConfig.AccessKey
  38928. struct3501.RequestUrl = miConfig.Url
  38929. struct3501.SecretKey = miConfig.SecretKey
  38930. struct3501.ManuDate = "2022-08-17"
  38931. struct3501.FixmedinsBchno = ""
  38932. struct3501.ManuLotnum = ""
  38933. struct3501.RxFlag = "0"
  38934. struct3501.ExpyEnd = "2022-08-17"
  38935. struct3501.Invdate = "2022-08-17"
  38936. struct3501.InvCnt = "20.25"
  38937. struct3501.Memo = ""
  38938. struct3501.MedListCodg = "XB01ABD056B002020200517"
  38939. struct3501.FixmedinsHilistId = miConfig.Code
  38940. struct3501.FixmedinsHilistName = miConfig.OrgName
  38941. struct3501s = append(struct3501s, struct3501)
  38942. data["struct_3501s"] = struct3501s
  38943. client := &http.Client{}
  38944. bytesData, _ := json.Marshal(data)
  38945. var req *http.Request
  38946. if miConfig.MdtrtareaAdmvs == "320921" {
  38947. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38948. } else {
  38949. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  38950. }
  38951. resp, _ := client.Do(req)
  38952. defer resp.Body.Close()
  38953. body, ioErr := ioutil.ReadAll(resp.Body)
  38954. if ioErr != nil {
  38955. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38957. return
  38958. }
  38959. var respJSON map[string]interface{}
  38960. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  38961. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38963. return
  38964. }
  38965. var res ResultSix
  38966. var resSix10265 ResultSix10265 //1101结果
  38967. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  38968. result, _ := json.Marshal(respJSON)
  38969. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  38970. utils.ErrorLog("解析失败:%v", err)
  38971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38972. return
  38973. }
  38974. res.InfRefmsgid = resSix10265.InfRefmsgid
  38975. res.Output = resSix10265.Output
  38976. res.ErrMsg = resSix10265.ErrMsg
  38977. res.Cainfo = resSix10265.Cainfo
  38978. res.WarnMsg = resSix10265.WarnMsg
  38979. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  38980. res.Infcode = infocode
  38981. if infocode == 0 {
  38982. c.ServeSuccessJSON(map[string]interface{}{
  38983. "msg": "上传成功",
  38984. })
  38985. return
  38986. } else {
  38987. c.ServeSuccessJSON(map[string]interface{}{
  38988. "failed_code": -10,
  38989. "msg": res.ErrMsg,
  38990. })
  38991. return
  38992. }
  38993. }
  38994. func (c *HisApiController) Post3502() {
  38995. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38996. data := make(map[string]interface{})
  38997. var struct3502s []models.Struct3502
  38998. var struct3502 models.Struct3502
  38999. struct3502.OrgName = miConfig.OrgName
  39000. struct3502.AccessKey = miConfig.AccessKey
  39001. struct3502.RequestUrl = miConfig.Url
  39002. struct3502.SecretKey = miConfig.SecretKey
  39003. struct3502.ManuDate = "2022-08-15"
  39004. struct3502.FixmedinsBchno = ""
  39005. struct3502.ManuLotnum = ""
  39006. struct3502.RxFlag = "0"
  39007. struct3502.ExpyEnd = "2022-08-15"
  39008. struct3502.Invdate = "2022-08-15"
  39009. struct3502.InvCnt = "20.25"
  39010. struct3502.Memo = ""
  39011. struct3502.MedListCodg = "XB01ABD056B002020200517"
  39012. struct3502.FixmedinsHilistId = miConfig.Code
  39013. struct3502.FixmedinsHilistName = miConfig.OrgName
  39014. struct3502s = append(struct3502s, struct3502)
  39015. data["struct_3502s"] = struct3502s
  39016. client := &http.Client{}
  39017. bytesData, _ := json.Marshal(data)
  39018. var req *http.Request
  39019. if miConfig.MdtrtareaAdmvs == "320921" {
  39020. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39021. } else {
  39022. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39023. }
  39024. resp, _ := client.Do(req)
  39025. defer resp.Body.Close()
  39026. body, ioErr := ioutil.ReadAll(resp.Body)
  39027. if ioErr != nil {
  39028. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39030. return
  39031. }
  39032. var respJSON map[string]interface{}
  39033. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39034. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39036. return
  39037. }
  39038. var res ResultSix
  39039. var resSix10265 ResultSix10265 //1101结果
  39040. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39041. result, _ := json.Marshal(respJSON)
  39042. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39043. utils.ErrorLog("解析失败:%v", err)
  39044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39045. return
  39046. }
  39047. res.InfRefmsgid = resSix10265.InfRefmsgid
  39048. res.Output = resSix10265.Output
  39049. res.ErrMsg = resSix10265.ErrMsg
  39050. res.Cainfo = resSix10265.Cainfo
  39051. res.WarnMsg = resSix10265.WarnMsg
  39052. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39053. res.Infcode = infocode
  39054. if infocode == 0 {
  39055. c.ServeSuccessJSON(map[string]interface{}{
  39056. "msg": "上传成功",
  39057. })
  39058. return
  39059. } else {
  39060. c.ServeSuccessJSON(map[string]interface{}{
  39061. "failed_code": -10,
  39062. "msg": res.ErrMsg,
  39063. })
  39064. return
  39065. }
  39066. }
  39067. func (c *HisApiController) Post3503() {
  39068. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39069. data := make(map[string]interface{})
  39070. var struct3501s []models.Struct3501
  39071. var struct3501 models.Struct3501
  39072. struct3501.OrgName = miConfig.OrgName
  39073. struct3501.AccessKey = miConfig.AccessKey
  39074. struct3501.RequestUrl = miConfig.Url
  39075. struct3501.SecretKey = miConfig.SecretKey
  39076. struct3501.ManuDate = "2022-08-15"
  39077. struct3501.FixmedinsBchno = ""
  39078. struct3501.ManuLotnum = ""
  39079. struct3501.RxFlag = "0"
  39080. struct3501.ExpyEnd = "2022-08-15"
  39081. struct3501.Invdate = "2022-08-15"
  39082. struct3501.InvCnt = "20.25"
  39083. struct3501.Memo = ""
  39084. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39085. struct3501.FixmedinsHilistId = miConfig.Code
  39086. struct3501.FixmedinsHilistName = miConfig.OrgName
  39087. struct3501s = append(struct3501s, struct3501)
  39088. data["struct_3501s"] = struct3501s
  39089. client := &http.Client{}
  39090. bytesData, _ := json.Marshal(data)
  39091. var req *http.Request
  39092. if miConfig.MdtrtareaAdmvs == "320921" {
  39093. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39094. } else {
  39095. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39096. }
  39097. resp, _ := client.Do(req)
  39098. defer resp.Body.Close()
  39099. body, ioErr := ioutil.ReadAll(resp.Body)
  39100. if ioErr != nil {
  39101. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39103. return
  39104. }
  39105. var respJSON map[string]interface{}
  39106. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39107. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39109. return
  39110. }
  39111. var res ResultSix
  39112. var resSix10265 ResultSix10265 //1101结果
  39113. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39114. result, _ := json.Marshal(respJSON)
  39115. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39116. utils.ErrorLog("解析失败:%v", err)
  39117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39118. return
  39119. }
  39120. res.InfRefmsgid = resSix10265.InfRefmsgid
  39121. res.Output = resSix10265.Output
  39122. res.ErrMsg = resSix10265.ErrMsg
  39123. res.Cainfo = resSix10265.Cainfo
  39124. res.WarnMsg = resSix10265.WarnMsg
  39125. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39126. res.Infcode = infocode
  39127. if infocode == 0 {
  39128. c.ServeSuccessJSON(map[string]interface{}{
  39129. "msg": "上传成功",
  39130. })
  39131. return
  39132. } else {
  39133. c.ServeSuccessJSON(map[string]interface{}{
  39134. "failed_code": -10,
  39135. "msg": res.ErrMsg,
  39136. })
  39137. return
  39138. }
  39139. }
  39140. func (c *HisApiController) Post3504() {
  39141. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39142. data := make(map[string]interface{})
  39143. var struct3501s []models.Struct3501
  39144. var struct3501 models.Struct3501
  39145. struct3501.OrgName = miConfig.OrgName
  39146. struct3501.AccessKey = miConfig.AccessKey
  39147. struct3501.RequestUrl = miConfig.Url
  39148. struct3501.SecretKey = miConfig.SecretKey
  39149. struct3501.ManuDate = "2022-08-15"
  39150. struct3501.FixmedinsBchno = ""
  39151. struct3501.ManuLotnum = ""
  39152. struct3501.RxFlag = "0"
  39153. struct3501.ExpyEnd = "2022-08-15"
  39154. struct3501.Invdate = "2022-08-15"
  39155. struct3501.InvCnt = "20.25"
  39156. struct3501.Memo = ""
  39157. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39158. struct3501.FixmedinsHilistId = miConfig.Code
  39159. struct3501.FixmedinsHilistName = miConfig.OrgName
  39160. struct3501s = append(struct3501s, struct3501)
  39161. data["struct_3501s"] = struct3501s
  39162. client := &http.Client{}
  39163. bytesData, _ := json.Marshal(data)
  39164. var req *http.Request
  39165. if miConfig.MdtrtareaAdmvs == "320921" {
  39166. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39167. } else {
  39168. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39169. }
  39170. resp, _ := client.Do(req)
  39171. defer resp.Body.Close()
  39172. body, ioErr := ioutil.ReadAll(resp.Body)
  39173. if ioErr != nil {
  39174. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39176. return
  39177. }
  39178. var respJSON map[string]interface{}
  39179. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39180. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39182. return
  39183. }
  39184. var res ResultSix
  39185. var resSix10265 ResultSix10265 //1101结果
  39186. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39187. result, _ := json.Marshal(respJSON)
  39188. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39189. utils.ErrorLog("解析失败:%v", err)
  39190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39191. return
  39192. }
  39193. res.InfRefmsgid = resSix10265.InfRefmsgid
  39194. res.Output = resSix10265.Output
  39195. res.ErrMsg = resSix10265.ErrMsg
  39196. res.Cainfo = resSix10265.Cainfo
  39197. res.WarnMsg = resSix10265.WarnMsg
  39198. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39199. res.Infcode = infocode
  39200. if infocode == 0 {
  39201. c.ServeSuccessJSON(map[string]interface{}{
  39202. "msg": "上传成功",
  39203. })
  39204. return
  39205. } else {
  39206. c.ServeSuccessJSON(map[string]interface{}{
  39207. "failed_code": -10,
  39208. "msg": res.ErrMsg,
  39209. })
  39210. return
  39211. }
  39212. }
  39213. func (c *HisApiController) Post3505() {
  39214. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39215. data := make(map[string]interface{})
  39216. var struct3501s []models.Struct3501
  39217. var struct3501 models.Struct3501
  39218. struct3501.OrgName = miConfig.OrgName
  39219. struct3501.AccessKey = miConfig.AccessKey
  39220. struct3501.RequestUrl = miConfig.Url
  39221. struct3501.SecretKey = miConfig.SecretKey
  39222. struct3501.ManuDate = "2022-08-15"
  39223. struct3501.FixmedinsBchno = ""
  39224. struct3501.ManuLotnum = ""
  39225. struct3501.RxFlag = "0"
  39226. struct3501.ExpyEnd = "2022-08-15"
  39227. struct3501.Invdate = "2022-08-15"
  39228. struct3501.InvCnt = "20.25"
  39229. struct3501.Memo = ""
  39230. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39231. struct3501.FixmedinsHilistId = miConfig.Code
  39232. struct3501.FixmedinsHilistName = miConfig.OrgName
  39233. struct3501s = append(struct3501s, struct3501)
  39234. data["struct_3501s"] = struct3501s
  39235. client := &http.Client{}
  39236. bytesData, _ := json.Marshal(data)
  39237. var req *http.Request
  39238. if miConfig.MdtrtareaAdmvs == "320921" {
  39239. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39240. } else {
  39241. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39242. }
  39243. resp, _ := client.Do(req)
  39244. defer resp.Body.Close()
  39245. body, ioErr := ioutil.ReadAll(resp.Body)
  39246. if ioErr != nil {
  39247. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39249. return
  39250. }
  39251. var respJSON map[string]interface{}
  39252. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39255. return
  39256. }
  39257. var res ResultSix
  39258. var resSix10265 ResultSix10265 //1101结果
  39259. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39260. result, _ := json.Marshal(respJSON)
  39261. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39262. utils.ErrorLog("解析失败:%v", err)
  39263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39264. return
  39265. }
  39266. res.InfRefmsgid = resSix10265.InfRefmsgid
  39267. res.Output = resSix10265.Output
  39268. res.ErrMsg = resSix10265.ErrMsg
  39269. res.Cainfo = resSix10265.Cainfo
  39270. res.WarnMsg = resSix10265.WarnMsg
  39271. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39272. res.Infcode = infocode
  39273. if infocode == 0 {
  39274. c.ServeSuccessJSON(map[string]interface{}{
  39275. "msg": "上传成功",
  39276. })
  39277. return
  39278. } else {
  39279. c.ServeSuccessJSON(map[string]interface{}{
  39280. "failed_code": -10,
  39281. "msg": res.ErrMsg,
  39282. })
  39283. return
  39284. }
  39285. }
  39286. func (c *HisApiController) Post3506() {
  39287. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39288. data := make(map[string]interface{})
  39289. var struct3501s []models.Struct3501
  39290. var struct3501 models.Struct3501
  39291. struct3501.OrgName = miConfig.OrgName
  39292. struct3501.AccessKey = miConfig.AccessKey
  39293. struct3501.RequestUrl = miConfig.Url
  39294. struct3501.SecretKey = miConfig.SecretKey
  39295. struct3501.ManuDate = "2022-08-15"
  39296. struct3501.FixmedinsBchno = ""
  39297. struct3501.ManuLotnum = ""
  39298. struct3501.RxFlag = "0"
  39299. struct3501.ExpyEnd = "2022-08-15"
  39300. struct3501.Invdate = "2022-08-15"
  39301. struct3501.InvCnt = "20.25"
  39302. struct3501.Memo = ""
  39303. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39304. struct3501.FixmedinsHilistId = miConfig.Code
  39305. struct3501.FixmedinsHilistName = miConfig.OrgName
  39306. struct3501s = append(struct3501s, struct3501)
  39307. data["struct_3501s"] = struct3501s
  39308. client := &http.Client{}
  39309. bytesData, _ := json.Marshal(data)
  39310. var req *http.Request
  39311. if miConfig.MdtrtareaAdmvs == "320921" {
  39312. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39313. } else {
  39314. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39315. }
  39316. resp, _ := client.Do(req)
  39317. defer resp.Body.Close()
  39318. body, ioErr := ioutil.ReadAll(resp.Body)
  39319. if ioErr != nil {
  39320. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39322. return
  39323. }
  39324. var respJSON map[string]interface{}
  39325. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39326. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39328. return
  39329. }
  39330. var res ResultSix
  39331. var resSix10265 ResultSix10265 //1101结果
  39332. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39333. result, _ := json.Marshal(respJSON)
  39334. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39335. utils.ErrorLog("解析失败:%v", err)
  39336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39337. return
  39338. }
  39339. res.InfRefmsgid = resSix10265.InfRefmsgid
  39340. res.Output = resSix10265.Output
  39341. res.ErrMsg = resSix10265.ErrMsg
  39342. res.Cainfo = resSix10265.Cainfo
  39343. res.WarnMsg = resSix10265.WarnMsg
  39344. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39345. res.Infcode = infocode
  39346. if infocode == 0 {
  39347. c.ServeSuccessJSON(map[string]interface{}{
  39348. "msg": "上传成功",
  39349. })
  39350. return
  39351. } else {
  39352. c.ServeSuccessJSON(map[string]interface{}{
  39353. "failed_code": -10,
  39354. "msg": res.ErrMsg,
  39355. })
  39356. return
  39357. }
  39358. }
  39359. func (c *HisApiController) Post3507() {
  39360. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  39361. data := make(map[string]interface{})
  39362. var struct3501s []models.Struct3501
  39363. var struct3501 models.Struct3501
  39364. struct3501.OrgName = miConfig.OrgName
  39365. struct3501.AccessKey = miConfig.AccessKey
  39366. struct3501.RequestUrl = miConfig.Url
  39367. struct3501.SecretKey = miConfig.SecretKey
  39368. struct3501.ManuDate = "2022-08-15"
  39369. struct3501.FixmedinsBchno = ""
  39370. struct3501.ManuLotnum = ""
  39371. struct3501.RxFlag = "0"
  39372. struct3501.ExpyEnd = "2022-08-15"
  39373. struct3501.Invdate = "2022-08-15"
  39374. struct3501.InvCnt = "20.25"
  39375. struct3501.Memo = ""
  39376. struct3501.MedListCodg = "XB01ABD056B002020200517"
  39377. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  39378. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  39379. struct3501s = append(struct3501s, struct3501)
  39380. data["struct_3501s"] = struct3501s
  39381. client := &http.Client{}
  39382. bytesData, _ := json.Marshal(data)
  39383. var req *http.Request
  39384. if miConfig.MdtrtareaAdmvs == "320921" {
  39385. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39386. } else {
  39387. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  39388. }
  39389. resp, _ := client.Do(req)
  39390. defer resp.Body.Close()
  39391. body, ioErr := ioutil.ReadAll(resp.Body)
  39392. if ioErr != nil {
  39393. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39395. return
  39396. }
  39397. var respJSON map[string]interface{}
  39398. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39401. return
  39402. }
  39403. var res ResultSix
  39404. var resSix10265 ResultSix10265 //1101结果
  39405. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  39406. result, _ := json.Marshal(respJSON)
  39407. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  39408. utils.ErrorLog("解析失败:%v", err)
  39409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39410. return
  39411. }
  39412. res.InfRefmsgid = resSix10265.InfRefmsgid
  39413. res.Output = resSix10265.Output
  39414. res.ErrMsg = resSix10265.ErrMsg
  39415. res.Cainfo = resSix10265.Cainfo
  39416. res.WarnMsg = resSix10265.WarnMsg
  39417. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  39418. res.Infcode = infocode
  39419. if infocode == 0 {
  39420. c.ServeSuccessJSON(map[string]interface{}{
  39421. "msg": "上传成功",
  39422. })
  39423. return
  39424. } else {
  39425. c.ServeSuccessJSON(map[string]interface{}{
  39426. "failed_code": -10,
  39427. "msg": res.ErrMsg,
  39428. })
  39429. return
  39430. }
  39431. }
  39432. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39433. // WebSocket服务器地址
  39434. serverURL := "ws://127.0.0.1:8899"
  39435. // 解析WebSocket服务器地址
  39436. u, err := url.Parse(serverURL)
  39437. if err != nil {
  39438. }
  39439. // 建立WebSocket连接
  39440. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39441. if err != nil {
  39442. }
  39443. defer conn.Close()
  39444. input2 := make(map[string]interface{})
  39445. input := make(map[string]interface{})
  39446. inputData := make(map[string]interface{})
  39447. inputData["orgId"] = code
  39448. inputData["businessType"] = "01101"
  39449. inputData["operatorId"] = operator_id
  39450. inputData["operatorName"] = operator_name
  39451. inputData["officeId"] = "001"
  39452. inputData["officeName"] = "血透室"
  39453. inputData["deviceType"] = ""
  39454. input["data"] = inputData
  39455. input["orgId"] = code
  39456. input["transType"] = "ec.query"
  39457. //if md == ""
  39458. if md[:4] == "4403" {
  39459. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39460. } else if md[:4] == "4401" {
  39461. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39462. } else {
  39463. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39464. }
  39465. input2["indata"] = input
  39466. fmt.Println(input2)
  39467. bytesData, _ := json.Marshal(input2)
  39468. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39469. if err != nil {
  39470. fmt.Println(err)
  39471. }
  39472. // 接收消息
  39473. _, receivedMessage, err := conn.ReadMessage()
  39474. if err != nil {
  39475. fmt.Println(err)
  39476. }
  39477. return "", string(receivedMessage)
  39478. }
  39479. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  39480. // WebSocket服务器地址
  39481. serverURL := "ws://127.0.0.1:8899"
  39482. // 解析WebSocket服务器地址
  39483. u, err := url.Parse(serverURL)
  39484. if err != nil {
  39485. }
  39486. // 建立WebSocket连接
  39487. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39488. if err != nil {
  39489. }
  39490. defer conn.Close()
  39491. input2 := make(map[string]interface{})
  39492. input := make(map[string]interface{})
  39493. inputData := make(map[string]interface{})
  39494. inputData["orgId"] = code
  39495. inputData["businessType"] = "01101"
  39496. inputData["operatorId"] = operator_id
  39497. inputData["operatorName"] = operator_name
  39498. inputData["officeId"] = "001"
  39499. inputData["officeName"] = "血透室"
  39500. inputData["deviceType"] = ""
  39501. input["data"] = inputData
  39502. input["orgId"] = code
  39503. input["transType"] = "ec.query"
  39504. //if md == ""
  39505. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39506. input2["indata"] = input
  39507. fmt.Println(input2)
  39508. bytesData, _ := json.Marshal(input2)
  39509. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39510. if err != nil {
  39511. fmt.Println(err)
  39512. }
  39513. // 接收消息
  39514. _, receivedMessage, err := conn.ReadMessage()
  39515. if err != nil {
  39516. fmt.Println(err)
  39517. }
  39518. return "", string(receivedMessage)
  39519. }
  39520. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  39521. // WebSocket服务器地址
  39522. serverURL := "ws://127.0.0.1:8899"
  39523. // 解析WebSocket服务器地址
  39524. u, err := url.Parse(serverURL)
  39525. if err != nil {
  39526. }
  39527. // 建立WebSocket连接
  39528. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39529. if err != nil {
  39530. }
  39531. defer conn.Close()
  39532. input2 := make(map[string]interface{})
  39533. input := make(map[string]interface{})
  39534. inputData := make(map[string]interface{})
  39535. inputData["orgId"] = code
  39536. inputData["businessType"] = "01301"
  39537. inputData["operatorId"] = operator_id
  39538. inputData["operatorName"] = operator_name
  39539. inputData["officeId"] = "001"
  39540. inputData["officeName"] = "血透室"
  39541. inputData["deviceType"] = ""
  39542. input["data"] = inputData
  39543. input["orgId"] = code
  39544. input["transType"] = "ec.query"
  39545. //if md == ""
  39546. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  39547. input2["indata"] = input
  39548. fmt.Println(input2)
  39549. bytesData, _ := json.Marshal(input2)
  39550. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39551. if err != nil {
  39552. fmt.Println(err)
  39553. }
  39554. // 接收消息
  39555. _, receivedMessage, err := conn.ReadMessage()
  39556. if err != nil {
  39557. fmt.Println(err)
  39558. }
  39559. return "", string(receivedMessage)
  39560. }
  39561. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  39562. // WebSocket服务器地址
  39563. serverURL := "ws://127.0.0.1:8899"
  39564. // 解析WebSocket服务器地址
  39565. u, err := url.Parse(serverURL)
  39566. if err != nil {
  39567. }
  39568. // 建立WebSocket连接
  39569. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39570. if err != nil {
  39571. }
  39572. defer conn.Close()
  39573. input2 := make(map[string]interface{})
  39574. input := make(map[string]interface{})
  39575. inputData := make(map[string]interface{})
  39576. inputData["orgId"] = code
  39577. inputData["businessType"] = "01103"
  39578. inputData["operatorId"] = operator_id
  39579. inputData["operatorName"] = operator_name
  39580. inputData["officeId"] = "001"
  39581. inputData["officeName"] = "血透室"
  39582. inputData["deviceType"] = ""
  39583. input["data"] = inputData
  39584. input["orgId"] = code
  39585. input["transType"] = "ec.query"
  39586. //if md ==
  39587. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  39588. input2["indata"] = input
  39589. fmt.Println(input2)
  39590. bytesData, _ := json.Marshal(input2)
  39591. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39592. if err != nil {
  39593. fmt.Println(err)
  39594. }
  39595. // 接收消息
  39596. _, receivedMessage, err := conn.ReadMessage()
  39597. if err != nil {
  39598. fmt.Println(err)
  39599. }
  39600. return "", string(receivedMessage)
  39601. }
  39602. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  39603. // WebSocket服务器地址
  39604. serverURL := "ws://127.0.0.1:8899"
  39605. // 解析WebSocket服务器地址
  39606. u, err := url.Parse(serverURL)
  39607. if err != nil {
  39608. }
  39609. // 建立WebSocket连接
  39610. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39611. if err != nil {
  39612. }
  39613. defer conn.Close()
  39614. input2 := make(map[string]interface{})
  39615. input := make(map[string]interface{})
  39616. inputData := make(map[string]interface{})
  39617. inputData["orgId"] = code
  39618. inputData["businessType"] = "01101"
  39619. inputData["operatorId"] = operator_id
  39620. inputData["operatorName"] = operator_name
  39621. inputData["officeId"] = "001"
  39622. inputData["officeName"] = "血透室"
  39623. inputData["deviceType"] = ""
  39624. input["data"] = inputData
  39625. input["orgId"] = code
  39626. input["transType"] = "ec.query"
  39627. //if md == ""
  39628. if md[:4] == "4403" {
  39629. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39630. } else if md[:4] == "4401" {
  39631. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39632. } else {
  39633. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39634. }
  39635. input2["indata"] = input
  39636. fmt.Println(input2)
  39637. bytesData, _ := json.Marshal(input2)
  39638. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39639. if err != nil {
  39640. fmt.Println(err)
  39641. }
  39642. // 接收消息
  39643. _, receivedMessage, err := conn.ReadMessage()
  39644. if err != nil {
  39645. fmt.Println(err)
  39646. }
  39647. return "", string(receivedMessage)
  39648. }
  39649. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  39650. // WebSocket服务器地址
  39651. serverURL := "ws://127.0.0.1:8899"
  39652. // 解析WebSocket服务器地址
  39653. u, err := url.Parse(serverURL)
  39654. if err != nil {
  39655. }
  39656. // 建立WebSocket连接
  39657. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  39658. if err != nil {
  39659. }
  39660. defer conn.Close()
  39661. input2 := make(map[string]interface{})
  39662. input := make(map[string]interface{})
  39663. inputData := make(map[string]interface{})
  39664. inputData["orgId"] = code
  39665. inputData["businessType"] = "01301"
  39666. inputData["operatorId"] = operator_id
  39667. inputData["operatorName"] = operator_name
  39668. inputData["officeId"] = "001"
  39669. inputData["officeName"] = "血透室"
  39670. inputData["deviceType"] = ""
  39671. input["data"] = inputData
  39672. input["orgId"] = code
  39673. input["transType"] = "ec.query"
  39674. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  39675. input2["indata"] = input
  39676. bytesData, _ := json.Marshal(input2)
  39677. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  39678. if err != nil {
  39679. fmt.Println(err)
  39680. }
  39681. // 接收消息
  39682. _, receivedMessage, err := conn.ReadMessage()
  39683. if err != nil {
  39684. fmt.Println(err)
  39685. }
  39686. return "", string(receivedMessage)
  39687. }
  39688. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  39689. newArr = make([]string, 0)
  39690. for i := 0; i < len(arr); i++ {
  39691. repeat := false
  39692. for j := i + 1; j < len(arr); j++ {
  39693. if arr[i] == arr[j] {
  39694. repeat = true
  39695. break
  39696. }
  39697. }
  39698. if !repeat {
  39699. newArr = append(newArr, arr[i])
  39700. }
  39701. }
  39702. return
  39703. }
  39704. func getBirthdateAndAge(idNumber string) (string, int, error) {
  39705. if len(idNumber) != 18 {
  39706. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  39707. }
  39708. // 提取出生日期
  39709. year, err := strconv.Atoi(idNumber[6:10])
  39710. if err != nil {
  39711. return "", 0, err
  39712. }
  39713. month, err := strconv.Atoi(idNumber[10:12])
  39714. if err != nil {
  39715. return "", 0, err
  39716. }
  39717. day, err := strconv.Atoi(idNumber[12:14])
  39718. if err != nil {
  39719. return "", 0, err
  39720. }
  39721. // 格式化生日字符串
  39722. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  39723. birthdateFormatted := birthdate.Format("2006-01-02")
  39724. // 计算年龄
  39725. today := time.Now()
  39726. age := today.Year() - birthdate.Year()
  39727. if today.YearDay() < birthdate.YearDay() {
  39728. age--
  39729. }
  39730. return birthdateFormatted, age, nil
  39731. }
  39732. // 从身份证号码中提取出生年月日
  39733. func getBirthDateFromIDCard(idCard string) (string, error) {
  39734. // 身份证号码长度应为18位
  39735. if len(idCard) != 18 {
  39736. return "", fmt.Errorf("身份证号码长度应为18位")
  39737. }
  39738. // 提取出生日期部分 (YYYYMMDD)
  39739. birthDateStr := idCard[6:14]
  39740. // 解析出生日期
  39741. birthDate, err := time.Parse("20060102", birthDateStr)
  39742. if err != nil {
  39743. return "", fmt.Errorf("解析出生日期失败: %v", err)
  39744. }
  39745. // 格式化出生日期为 YYYY-MM-DD
  39746. formattedDate := birthDate.Format("2006-01-02")
  39747. return formattedDate, nil
  39748. }