his_api_controller.go 1.5MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. //"github.com/tjfoc/gmsm/sm3"
  8. "math"
  9. //"crypto/x509/pkix"
  10. "encoding/json"
  11. "fmt"
  12. "gdyb/controllers"
  13. "gdyb/enums"
  14. "gdyb/models"
  15. "gdyb/service"
  16. "gdyb/utils"
  17. "github.com/astaxie/beego"
  18. "github.com/axgle/mahonia"
  19. "github.com/go-ole/go-ole/oleutil"
  20. "github.com/gorilla/websocket"
  21. "github.com/jinzhu/gorm"
  22. "github.com/shopspring/decimal"
  23. "io"
  24. "io/ioutil"
  25. //"math"
  26. "math/rand"
  27. "net/http"
  28. "net/url"
  29. "os"
  30. "path/filepath"
  31. "regexp"
  32. "strconv"
  33. "strings"
  34. "syscall"
  35. "time"
  36. "unsafe"
  37. "github.com/go-ole/go-ole"
  38. )
  39. type HisApiController struct {
  40. controllers.BaseAuthAPIController
  41. }
  42. func HisManagerApiRegistRouters() {
  43. //挂号
  44. beego.Router("/test/net", &HisApiController{}, "get:TestNet")
  45. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  46. //上传就诊信息-上传明细-结算
  47. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  48. //查询
  49. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  50. //对总账
  51. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  52. //对明细
  53. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  54. //退费,退明细
  55. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  56. //退号
  57. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  58. //退明细
  59. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  60. //上传就诊信息-上传明细-预结算
  61. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  62. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  63. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  64. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  65. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  66. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  67. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  68. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  69. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  70. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  71. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  72. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  73. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  74. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  75. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  76. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  77. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  78. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  79. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  80. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  81. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  82. beego.Router("/api/check", &HisApiController{}, "get:Check")
  83. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  84. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  85. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  86. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  87. beego.Router("/api/3204a", &HisApiController{}, "get:Post3204a")
  88. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  89. beego.Router("/api/8404", &HisApiController{}, "get:Post8404")
  90. beego.Router("/api/3204", &HisApiController{}, "get:Post3204")
  91. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  92. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  93. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  94. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  95. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  96. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  97. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  98. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  99. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  100. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  101. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  102. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  103. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  104. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  105. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  106. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  107. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  108. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  109. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  110. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  111. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  112. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  113. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  114. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  115. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  116. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  117. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  118. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  119. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  120. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  121. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  122. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  123. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  124. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  125. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  126. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  127. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  128. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  129. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  130. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  131. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  132. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  133. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  134. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  135. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  136. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  137. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  138. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  139. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  140. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  141. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  142. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  143. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  144. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  145. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  146. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  147. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  148. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  149. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  150. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  151. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  152. //库盘和变更
  153. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  154. //删除库盘和变更
  155. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  156. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  157. //药品变更
  158. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  159. beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  160. beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  161. beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  162. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  163. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  164. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  165. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  166. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  167. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  168. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  169. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  170. //beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  171. //beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  172. }
  173. func (c *HisApiController) TestNet() {
  174. c.ServeSuccessJSON(map[string]interface{}{
  175. "msg": "成功",
  176. })
  177. }
  178. func (c *HisApiController) Get3508() {
  179. admin_user_id, _ := c.GetInt64("admin_user_id")
  180. drug_id, _ := c.GetInt64("id")
  181. start_time := c.GetString("start_time")
  182. end_time := c.GetString("end_time")
  183. adminUser := c.GetAdminUserInfo()
  184. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  185. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  186. drug, _ := service.GetDrugByID(drug_id)
  187. var struct3508 models.Struct3508
  188. struct3508.OrgName = miConfig.OrgName
  189. struct3508.FixmedinsCode = miConfig.Code
  190. struct3508.AccessKey = miConfig.AccessKey
  191. struct3508.Opter = curRoles.UserName
  192. struct3508.RequestUrl = miConfig.Url
  193. struct3508.Url = miConfig.Url
  194. struct3508.AppId = miConfig.Cainfo
  195. struct3508.AppSecret = miConfig.AppSecret
  196. struct3508.Enckey = miConfig.EncKey
  197. struct3508.SignKey = miConfig.SignKey
  198. struct3508.SecretKey = miConfig.SecretKey
  199. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  200. struct3508.Begndate = start_time
  201. struct3508.Enddate = end_time
  202. result1, result2, _ := service.FJyb3508(struct3508)
  203. saveLog(result1, result2, "3508", "3508")
  204. var res models.Result3508
  205. var respJSON2 map[string]interface{}
  206. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  207. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  209. return
  210. }
  211. userJSONBytes2, _ := json.Marshal(respJSON2)
  212. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  213. utils.ErrorLog("解析失败:%v", err)
  214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  215. return
  216. }
  217. if res.Infcode == -1 {
  218. c.ServeSuccessJSON(map[string]interface{}{
  219. "failed_code": -10,
  220. "msg": res.ErrMsg,
  221. })
  222. } else {
  223. c.ServeSuccessJSON(map[string]interface{}{
  224. "info": res.Output,
  225. })
  226. }
  227. }
  228. func (c *HisApiController) Get3509() {
  229. admin_user_id, _ := c.GetInt64("admin_user_id")
  230. drug_id, _ := c.GetInt64("id")
  231. start_time := c.GetString("start_time")
  232. end_time := c.GetString("end_time")
  233. adminUser := c.GetAdminUserInfo()
  234. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  235. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  236. drug, _ := service.GetDrugByID(drug_id)
  237. var struct3508 models.Struct3509
  238. struct3508.OrgName = miConfig.OrgName
  239. struct3508.FixmedinsCode = miConfig.Code
  240. struct3508.AccessKey = miConfig.AccessKey
  241. struct3508.Opter = curRoles.UserName
  242. struct3508.RequestUrl = miConfig.Url
  243. struct3508.Url = miConfig.Url
  244. struct3508.AppId = miConfig.Cainfo
  245. struct3508.AppSecret = miConfig.AppSecret
  246. struct3508.Enckey = miConfig.EncKey
  247. struct3508.SignKey = miConfig.SignKey
  248. struct3508.SecretKey = miConfig.SecretKey
  249. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  250. struct3508.Begndate = start_time
  251. struct3508.Enddate = end_time
  252. result1, result2, _ := service.FJyb3509(struct3508)
  253. saveLog(result1, result2, "3509", "3509")
  254. var res models.Result3509
  255. var respJSON2 map[string]interface{}
  256. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  257. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  259. return
  260. }
  261. userJSONBytes2, _ := json.Marshal(respJSON2)
  262. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  263. utils.ErrorLog("解析失败:%v", err)
  264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  265. return
  266. }
  267. if res.Infcode == -1 {
  268. c.ServeSuccessJSON(map[string]interface{}{
  269. "failed_code": -10,
  270. "msg": res.ErrMsg,
  271. })
  272. } else {
  273. c.ServeSuccessJSON(map[string]interface{}{
  274. "info": res.Output,
  275. })
  276. }
  277. }
  278. func (c *HisApiController) Get3510() {
  279. admin_user_id, _ := c.GetInt64("admin_user_id")
  280. drug_id, _ := c.GetInt64("id")
  281. start_time := c.GetString("start_time")
  282. end_time := c.GetString("end_time")
  283. adminUser := c.GetAdminUserInfo()
  284. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  285. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  286. drug, _ := service.GetDrugByID(drug_id)
  287. var struct3508 models.Struct3510
  288. struct3508.FixmedinsCode = miConfig.Code
  289. struct3508.OrgName = miConfig.OrgName
  290. struct3508.AccessKey = miConfig.AccessKey
  291. struct3508.Opter = curRoles.UserName
  292. struct3508.RequestUrl = miConfig.Url
  293. struct3508.Url = miConfig.Url
  294. struct3508.AppId = miConfig.Cainfo
  295. struct3508.AppSecret = miConfig.AppSecret
  296. struct3508.Enckey = miConfig.EncKey
  297. struct3508.SignKey = miConfig.SignKey
  298. struct3508.SecretKey = miConfig.SecretKey
  299. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  300. struct3508.Begndate = start_time
  301. struct3508.Enddate = end_time
  302. result1, result2, _ := service.FJyb3510(struct3508)
  303. saveLog(result1, result2, "3510", "3510")
  304. var res models.Result3510
  305. var respJSON2 map[string]interface{}
  306. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  307. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  309. return
  310. }
  311. userJSONBytes2, _ := json.Marshal(respJSON2)
  312. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  313. utils.ErrorLog("解析失败:%v", err)
  314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  315. return
  316. }
  317. if res.Infcode == -1 {
  318. c.ServeSuccessJSON(map[string]interface{}{
  319. "failed_code": -10,
  320. "msg": res.ErrMsg,
  321. })
  322. } else {
  323. c.ServeSuccessJSON(map[string]interface{}{
  324. "info": res.Output,
  325. })
  326. }
  327. }
  328. func (c *HisApiController) Get3511() {
  329. admin_user_id, _ := c.GetInt64("admin_user_id")
  330. drug_id, _ := c.GetInt64("id")
  331. start_time := c.GetString("start_time")
  332. end_time := c.GetString("end_time")
  333. adminUser := c.GetAdminUserInfo()
  334. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  335. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  336. drug, _ := service.GetDrugByID(drug_id)
  337. var struct3508 models.Struct3511
  338. struct3508.FixmedinsCode = miConfig.Code
  339. struct3508.OrgName = miConfig.OrgName
  340. struct3508.AccessKey = miConfig.AccessKey
  341. struct3508.Opter = curRoles.UserName
  342. struct3508.RequestUrl = miConfig.Url
  343. struct3508.Url = miConfig.Url
  344. struct3508.AppId = miConfig.Cainfo
  345. struct3508.AppSecret = miConfig.AppSecret
  346. struct3508.Enckey = miConfig.EncKey
  347. struct3508.SignKey = miConfig.SignKey
  348. struct3508.SecretKey = miConfig.SecretKey
  349. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  350. struct3508.Begndate = start_time
  351. struct3508.Enddate = end_time
  352. result1, result2, _ := service.FJyb3511(struct3508)
  353. saveLog(result1, result2, "3511", "3511")
  354. var res models.Result3511
  355. var respJSON2 map[string]interface{}
  356. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  357. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  359. return
  360. }
  361. userJSONBytes2, _ := json.Marshal(respJSON2)
  362. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  363. utils.ErrorLog("解析失败:%v", err)
  364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  365. return
  366. }
  367. if res.Infcode == -1 {
  368. c.ServeSuccessJSON(map[string]interface{}{
  369. "failed_code": -10,
  370. "msg": res.ErrMsg,
  371. })
  372. } else {
  373. c.ServeSuccessJSON(map[string]interface{}{
  374. "info": res.Output,
  375. })
  376. }
  377. }
  378. func (c *HisApiController) Get3512() {
  379. admin_user_id, _ := c.GetInt64("admin_user_id")
  380. drug_id, _ := c.GetInt64("id")
  381. start_time := c.GetString("start_time")
  382. end_time := c.GetString("end_time")
  383. adminUser := c.GetAdminUserInfo()
  384. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  385. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  386. drug, _ := service.GetDrugByID(drug_id)
  387. var struct3508 models.Struct3512
  388. struct3508.FixmedinsCode = miConfig.Code
  389. struct3508.OrgName = miConfig.OrgName
  390. struct3508.AccessKey = miConfig.AccessKey
  391. struct3508.Opter = curRoles.UserName
  392. struct3508.RequestUrl = miConfig.Url
  393. struct3508.Url = miConfig.Url
  394. struct3508.AppId = miConfig.Cainfo
  395. struct3508.AppSecret = miConfig.AppSecret
  396. struct3508.Enckey = miConfig.EncKey
  397. struct3508.SignKey = miConfig.SignKey
  398. struct3508.SecretKey = miConfig.SecretKey
  399. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  400. struct3508.Begndate = start_time
  401. struct3508.Enddate = end_time
  402. result1, result2, _ := service.FJyb3512(struct3508)
  403. saveLog(result1, result2, "3512", "3512")
  404. var res models.Result3512
  405. var respJSON2 map[string]interface{}
  406. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  407. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  409. return
  410. }
  411. userJSONBytes2, _ := json.Marshal(respJSON2)
  412. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  413. utils.ErrorLog("解析失败:%v", err)
  414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  415. return
  416. }
  417. if res.Infcode == -1 {
  418. c.ServeSuccessJSON(map[string]interface{}{
  419. "failed_code": -10,
  420. "msg": res.ErrMsg,
  421. })
  422. } else {
  423. c.ServeSuccessJSON(map[string]interface{}{
  424. "info": res.Output,
  425. })
  426. }
  427. }
  428. func (c *HisApiController) Get3513() {
  429. admin_user_id, _ := c.GetInt64("admin_user_id")
  430. drug_id, _ := c.GetInt64("id")
  431. start_time := c.GetString("start_time")
  432. end_time := c.GetString("end_time")
  433. adminUser := c.GetAdminUserInfo()
  434. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  435. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  436. drug, _ := service.GetDrugByID(drug_id)
  437. var struct3508 models.Struct3513
  438. struct3508.FixmedinsCode = miConfig.Code
  439. struct3508.OrgName = miConfig.OrgName
  440. struct3508.AccessKey = miConfig.AccessKey
  441. struct3508.Opter = curRoles.UserName
  442. struct3508.RequestUrl = miConfig.Url
  443. struct3508.Url = miConfig.Url
  444. struct3508.AppId = miConfig.Cainfo
  445. struct3508.AppSecret = miConfig.AppSecret
  446. struct3508.Enckey = miConfig.EncKey
  447. struct3508.SignKey = miConfig.SignKey
  448. struct3508.SecretKey = miConfig.SecretKey
  449. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  450. struct3508.Begndate = start_time
  451. struct3508.Enddate = end_time
  452. result1, result2, _ := service.FJyb3513(struct3508)
  453. saveLog(result1, result2, "3513", "3513")
  454. var res models.Result3513
  455. var respJSON2 map[string]interface{}
  456. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  459. return
  460. }
  461. userJSONBytes2, _ := json.Marshal(respJSON2)
  462. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  463. utils.ErrorLog("解析失败:%v", err)
  464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  465. return
  466. }
  467. if res.Infcode == -1 {
  468. c.ServeSuccessJSON(map[string]interface{}{
  469. "failed_code": -10,
  470. "msg": res.ErrMsg,
  471. })
  472. } else {
  473. c.ServeSuccessJSON(map[string]interface{}{
  474. "info": res.Output,
  475. })
  476. }
  477. }
  478. func (c *HisApiController) Get35081() {
  479. admin_user_id, _ := c.GetInt64("admin_user_id")
  480. drug_id, _ := c.GetInt64("id")
  481. //start_time := c.GetString("start_time")
  482. //end_time := c.GetString("end_time")
  483. page, _ := c.GetInt("page")
  484. adminUser := c.GetAdminUserInfo()
  485. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  486. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  487. drug, _ := service.GetDrugByID(drug_id)
  488. var struct3508 models.Struct35081
  489. struct3508.FixmedinsCode = miConfig.Code
  490. struct3508.OrgName = miConfig.OrgName
  491. struct3508.AccessKey = miConfig.AccessKey
  492. struct3508.Opter = curRoles.UserName
  493. struct3508.RequestUrl = miConfig.Url
  494. struct3508.Url = miConfig.Url
  495. struct3508.AppId = miConfig.Cainfo
  496. struct3508.AppSecret = miConfig.AppSecret
  497. struct3508.Enckey = miConfig.EncKey
  498. struct3508.SignKey = miConfig.SignKey
  499. struct3508.SecretKey = miConfig.SecretKey
  500. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  501. struct3508.PageNum = page
  502. struct3508.PageSize = 10
  503. result1, result2, _ := service.FJyb35081(struct3508)
  504. saveLog(result1, result2, "35081", "35081")
  505. var res models.Result35081
  506. var respJSON2 map[string]interface{}
  507. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  508. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  510. return
  511. }
  512. userJSONBytes2, _ := json.Marshal(respJSON2)
  513. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  514. utils.ErrorLog("解析失败:%v", err)
  515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  516. return
  517. }
  518. if res.Infcode == -1 {
  519. c.ServeSuccessJSON(map[string]interface{}{
  520. "failed_code": -10,
  521. "msg": res.ErrMsg,
  522. })
  523. } else {
  524. c.ServeSuccessJSON(map[string]interface{}{
  525. "info": res.Output,
  526. })
  527. }
  528. }
  529. func (c *HisApiController) Get35082() {
  530. admin_user_id, _ := c.GetInt64("admin_user_id")
  531. drug_id, _ := c.GetInt64("id")
  532. //start_time := c.GetString("start_time")
  533. //end_time := c.GetString("end_time")
  534. page, _ := c.GetInt("page")
  535. adminUser := c.GetAdminUserInfo()
  536. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  537. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  538. drug, _ := service.GetDrugByID(drug_id)
  539. var struct3508 models.Struct35082
  540. struct3508.FixmedinsCode = miConfig.Code
  541. struct3508.OrgName = miConfig.OrgName
  542. struct3508.AccessKey = miConfig.AccessKey
  543. struct3508.Opter = curRoles.UserName
  544. struct3508.RequestUrl = miConfig.Url
  545. struct3508.Url = miConfig.Url
  546. struct3508.AppId = miConfig.Cainfo
  547. struct3508.AppSecret = miConfig.AppSecret
  548. struct3508.Enckey = miConfig.EncKey
  549. struct3508.SignKey = miConfig.SignKey
  550. struct3508.SecretKey = miConfig.SecretKey
  551. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  552. struct3508.PageNum = page
  553. struct3508.PageSize = 10
  554. result1, result2, _ := service.FJyb35082(struct3508)
  555. saveLog(result1, result2, "35082", "35082")
  556. var res models.Result35082
  557. var respJSON2 map[string]interface{}
  558. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  559. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  561. return
  562. }
  563. userJSONBytes2, _ := json.Marshal(respJSON2)
  564. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  565. utils.ErrorLog("解析失败:%v", err)
  566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  567. return
  568. }
  569. if res.Infcode == -1 {
  570. c.ServeSuccessJSON(map[string]interface{}{
  571. "failed_code": -10,
  572. "msg": res.ErrMsg,
  573. })
  574. } else {
  575. c.ServeSuccessJSON(map[string]interface{}{
  576. "info": res.Output,
  577. })
  578. }
  579. }
  580. func (c *HisApiController) FJ3501AND3502() {
  581. ids := c.GetString("ids")
  582. admin_user_id, _ := c.GetInt64("admin_user_id")
  583. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  584. id_arr := strings.Split(ids, ",")
  585. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  586. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  587. //库盘
  588. var errs []string
  589. for _, drug := range drugs {
  590. if drug.IsPc == 0 && drug.IsBg == 0 {
  591. var res2 ResultSix
  592. var res3 ResultSix
  593. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  594. var struct3501 models.Struct3501
  595. struct3501.Code = miConfig.Code
  596. struct3501.OrgName = miConfig.OrgName
  597. struct3501.AccessKey = miConfig.AccessKey
  598. struct3501.Opter = roles.UserName
  599. struct3501.RequestUrl = miConfig.Url
  600. struct3501.Url = miConfig.Url
  601. struct3501.AppId = miConfig.Cainfo
  602. struct3501.AppSecret = miConfig.AppSecret
  603. struct3501.Enckey = miConfig.EncKey
  604. struct3501.SignKey = miConfig.SignKey
  605. struct3501.SecretKey = miConfig.SecretKey
  606. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  607. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  608. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  609. struct3501.RxFlag = "0"
  610. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  611. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  612. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  613. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  614. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  615. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  616. struct3501.FixmedinsBchno = number
  617. struct3501.DrugTracCodg = drug.DrugCode
  618. memo := make(map[string]interface{})
  619. memo["pric"] = drug.Price
  620. bytesData, _ := json.Marshal(memo)
  621. struct3501.Memo = string(bytesData)
  622. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  623. result1, result2, _ := service.FJyb3501(struct3501)
  624. saveLog(result1, result2, "3501", "3501")
  625. //saveLog(result, requestLog, "2201", "挂号")
  626. var respJSON2 map[string]interface{}
  627. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  630. return
  631. }
  632. userJSONBytes2, _ := json.Marshal(respJSON2)
  633. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  634. utils.ErrorLog("解析失败:%v", err)
  635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  636. return
  637. }
  638. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  639. data := make(map[string]interface{})
  640. data["struct_3501s"] = struct3501
  641. client := &http.Client{}
  642. bytesData, _ := json.Marshal(data)
  643. var req *http.Request
  644. if miConfig.MdtrtareaAdmvs == "320921" {
  645. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  646. } else {
  647. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  648. }
  649. resp, _ := client.Do(req)
  650. defer resp.Body.Close()
  651. body, ioErr := ioutil.ReadAll(resp.Body)
  652. if ioErr != nil {
  653. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  654. }
  655. var respJSON map[string]interface{}
  656. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  659. return
  660. }
  661. var resSix10265 ResultSix10265 //1101结果
  662. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  663. result, _ := json.Marshal(respJSON)
  664. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  665. utils.ErrorLog("解析失败:%v", err)
  666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  667. return
  668. }
  669. res2.InfRefmsgid = resSix10265.InfRefmsgid
  670. res2.Output = resSix10265.Output
  671. res2.ErrMsg = resSix10265.ErrMsg
  672. res2.Cainfo = resSix10265.Cainfo
  673. res2.WarnMsg = resSix10265.WarnMsg
  674. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  675. res2.Infcode = infocode
  676. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  677. data := make(map[string]interface{})
  678. data["struct_3501s"] = struct3501
  679. client := &http.Client{}
  680. bytesData, _ := json.Marshal(data)
  681. var req *http.Request
  682. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  683. resp, _ := client.Do(req)
  684. defer resp.Body.Close()
  685. body, ioErr := ioutil.ReadAll(resp.Body)
  686. if ioErr != nil {
  687. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  688. }
  689. var respJSON map[string]interface{}
  690. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  691. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  693. return
  694. }
  695. var resSix10265 ResultSix10265 //1101结果
  696. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  697. result, _ := json.Marshal(respJSON)
  698. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  699. utils.ErrorLog("解析失败:%v", err)
  700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  701. return
  702. }
  703. res2.InfRefmsgid = resSix10265.InfRefmsgid
  704. res2.Output = resSix10265.Output
  705. res2.ErrMsg = resSix10265.ErrMsg
  706. res2.Cainfo = resSix10265.Cainfo
  707. res2.WarnMsg = resSix10265.WarnMsg
  708. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  709. res2.Infcode = infocode
  710. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  711. data := make(map[string]interface{})
  712. data["struct_3501s"] = struct3501
  713. client := &http.Client{}
  714. bytesData, _ := json.Marshal(data)
  715. var req *http.Request
  716. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  717. resp, _ := client.Do(req)
  718. defer resp.Body.Close()
  719. body, ioErr := ioutil.ReadAll(resp.Body)
  720. if ioErr != nil {
  721. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  722. }
  723. var respJSON map[string]interface{}
  724. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  725. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  727. return
  728. }
  729. var resSix10265 ResultSix10265 //1101结果
  730. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  731. result, _ := json.Marshal(respJSON)
  732. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  733. utils.ErrorLog("解析失败:%v", err)
  734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  735. return
  736. }
  737. res2.InfRefmsgid = resSix10265.InfRefmsgid
  738. res2.Output = resSix10265.Output
  739. res2.ErrMsg = resSix10265.ErrMsg
  740. res2.Cainfo = resSix10265.Cainfo
  741. res2.WarnMsg = resSix10265.WarnMsg
  742. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  743. res2.Infcode = infocode
  744. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") { //广东
  745. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  746. saveLog(result1, result2, "3501", "3501")
  747. //saveLog(result, requestLog, "2201", "挂号")
  748. var respJSON2 map[string]interface{}
  749. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  750. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  752. return
  753. }
  754. userJSONBytes2, _ := json.Marshal(respJSON2)
  755. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  756. utils.ErrorLog("解析失败:%v", err)
  757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  758. return
  759. }
  760. }
  761. if res2.Infcode != -1 {
  762. drug.IsPc = 1
  763. drug.Bchno = number
  764. drug.PcDate = time.Now().Unix()
  765. err := service.SaveW(drug)
  766. if err == nil {
  767. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  768. var struct3502 models.Struct3502
  769. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  770. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  771. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  772. struct3502.FixmedinsCode = miConfig.Code
  773. struct3502.Code = miConfig.Code
  774. struct3502.RxFlag = "0"
  775. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  776. struct3502.OrgName = miConfig.OrgName
  777. struct3502.Opter = roles.UserName
  778. struct3502.AccessKey = miConfig.AccessKey
  779. struct3502.RequestUrl = miConfig.Url
  780. struct3502.SecretKey = miConfig.SecretKey
  781. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  782. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  783. struct3502.Url = miConfig.Url
  784. struct3502.AppId = miConfig.Cainfo
  785. struct3502.AppSecret = miConfig.AppSecret
  786. struct3502.Enckey = miConfig.EncKey
  787. struct3502.SignKey = miConfig.SignKey
  788. struct3502.SecretKey = miConfig.SecretKey
  789. struct3502.DrugTracCodg = drug.DrugCode
  790. struct3502.Memo = ""
  791. struct3502.InvChgType = "108"
  792. struct3502.FixmedinsBchno = bg_number
  793. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  794. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  795. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  796. result11, result22, _ := service.FJyb3502(struct3502)
  797. saveLog(result11, result22, "3502", "3502")
  798. var respJSON3 map[string]interface{}
  799. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  800. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  802. return
  803. }
  804. userJSONBytes3, _ := json.Marshal(respJSON3)
  805. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  806. utils.ErrorLog("解析失败:%v", err)
  807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  808. return
  809. }
  810. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  811. data := make(map[string]interface{})
  812. data["struct_3502s"] = struct3502
  813. client := &http.Client{}
  814. bytesData, _ := json.Marshal(data)
  815. var req *http.Request
  816. if miConfig.MdtrtareaAdmvs == "320921" {
  817. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  818. } else {
  819. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  820. }
  821. resp, _ := client.Do(req)
  822. defer resp.Body.Close()
  823. body, ioErr := ioutil.ReadAll(resp.Body)
  824. if ioErr != nil {
  825. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  826. }
  827. var respJSON map[string]interface{}
  828. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  829. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  831. return
  832. }
  833. var resSix10265 ResultSix10265 //1101结果
  834. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  835. result, _ := json.Marshal(respJSON)
  836. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  837. utils.ErrorLog("解析失败:%v", err)
  838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  839. return
  840. }
  841. res3.InfRefmsgid = resSix10265.InfRefmsgid
  842. res3.Output = resSix10265.Output
  843. res3.ErrMsg = resSix10265.ErrMsg
  844. res3.Cainfo = resSix10265.Cainfo
  845. res3.WarnMsg = resSix10265.WarnMsg
  846. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  847. res3.Infcode = infocode
  848. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  849. data := make(map[string]interface{})
  850. data["struct_3502s"] = struct3502
  851. client := &http.Client{}
  852. bytesData, _ := json.Marshal(data)
  853. var req *http.Request
  854. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  855. resp, _ := client.Do(req)
  856. defer resp.Body.Close()
  857. body, ioErr := ioutil.ReadAll(resp.Body)
  858. if ioErr != nil {
  859. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  860. }
  861. var respJSON map[string]interface{}
  862. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  863. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  865. return
  866. }
  867. var resSix10265 ResultSix10265 //1101结果
  868. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  869. result, _ := json.Marshal(respJSON)
  870. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  871. utils.ErrorLog("解析失败:%v", err)
  872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  873. return
  874. }
  875. res3.InfRefmsgid = resSix10265.InfRefmsgid
  876. res3.Output = resSix10265.Output
  877. res3.ErrMsg = resSix10265.ErrMsg
  878. res3.Cainfo = resSix10265.Cainfo
  879. res3.WarnMsg = resSix10265.WarnMsg
  880. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  881. res3.Infcode = infocode
  882. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  883. data := make(map[string]interface{})
  884. data["struct_3501s"] = struct3501
  885. client := &http.Client{}
  886. bytesData, _ := json.Marshal(data)
  887. var req *http.Request
  888. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  889. resp, _ := client.Do(req)
  890. defer resp.Body.Close()
  891. body, ioErr := ioutil.ReadAll(resp.Body)
  892. if ioErr != nil {
  893. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  894. }
  895. var respJSON map[string]interface{}
  896. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  897. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  899. return
  900. }
  901. var resSix10265 ResultSix10265 //1101结果
  902. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  903. result, _ := json.Marshal(respJSON)
  904. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  905. utils.ErrorLog("解析失败:%v", err)
  906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  907. return
  908. }
  909. res2.InfRefmsgid = resSix10265.InfRefmsgid
  910. res2.Output = resSix10265.Output
  911. res2.ErrMsg = resSix10265.ErrMsg
  912. res2.Cainfo = resSix10265.Cainfo
  913. res2.WarnMsg = resSix10265.WarnMsg
  914. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  915. res2.Infcode = infocode
  916. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  917. result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  918. saveLog(result11, result22, "3502", "3502")
  919. var respJSON3 map[string]interface{}
  920. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  921. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  923. return
  924. }
  925. userJSONBytes3, _ := json.Marshal(respJSON3)
  926. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  927. utils.ErrorLog("解析失败:%v", err)
  928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  929. return
  930. }
  931. }
  932. if res3.Infcode == -1 {
  933. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  934. c.ServeSuccessJSON(map[string]interface{}{
  935. "failed_code": -10,
  936. "msg": res3.ErrMsg,
  937. })
  938. } else {
  939. drug.IsBg = 1
  940. drug.BgBchno = bg_number
  941. service.SaveW(drug)
  942. }
  943. }
  944. } else {
  945. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  946. }
  947. }
  948. //变更
  949. if drug.IsPc == 1 && drug.IsBg == 0 {
  950. var res3 ResultSix
  951. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  952. var struct3502 models.Struct3502
  953. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  954. struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  955. struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  956. struct3502.FixmedinsCode = miConfig.Code
  957. struct3502.Code = miConfig.Code
  958. struct3502.Opter = roles.UserName
  959. struct3502.RxFlag = "0"
  960. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  961. struct3502.OrgName = miConfig.OrgName
  962. struct3502.AccessKey = miConfig.AccessKey
  963. struct3502.RequestUrl = miConfig.Url
  964. struct3502.SecretKey = miConfig.SecretKey
  965. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  966. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  967. struct3502.InvChgType = "108"
  968. struct3502.DrugTracCodg = drug.DrugCode
  969. struct3502.Url = miConfig.Url
  970. struct3502.AppId = miConfig.Cainfo
  971. struct3502.AppSecret = miConfig.AppSecret
  972. struct3502.Enckey = miConfig.EncKey
  973. struct3502.SignKey = miConfig.SignKey
  974. struct3502.SecretKey = miConfig.SecretKey
  975. struct3502.FixmedinsBchno = bg_number
  976. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  977. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  978. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  979. result1, result2, _ := service.FJyb3502(struct3502)
  980. saveLog(result1, result2, "3502", "3502")
  981. var respJSON3 map[string]interface{}
  982. if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  983. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  985. return
  986. }
  987. userJSONBytes3, _ := json.Marshal(respJSON3)
  988. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  989. utils.ErrorLog("解析失败:%v", err)
  990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  991. return
  992. }
  993. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  994. data := make(map[string]interface{})
  995. data["struct_3502s"] = struct3502
  996. client := &http.Client{}
  997. bytesData, _ := json.Marshal(data)
  998. var req *http.Request
  999. if miConfig.MdtrtareaAdmvs == "320921" {
  1000. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1001. } else {
  1002. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1003. }
  1004. resp, _ := client.Do(req)
  1005. defer resp.Body.Close()
  1006. body, ioErr := ioutil.ReadAll(resp.Body)
  1007. if ioErr != nil {
  1008. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1009. }
  1010. var respJSON map[string]interface{}
  1011. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1012. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1014. return
  1015. }
  1016. var resSix10265 ResultSix10265 //1101结果
  1017. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1018. result, _ := json.Marshal(respJSON)
  1019. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1020. utils.ErrorLog("解析失败:%v", err)
  1021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1022. return
  1023. }
  1024. res3.InfRefmsgid = resSix10265.InfRefmsgid
  1025. res3.Output = resSix10265.Output
  1026. res3.ErrMsg = resSix10265.ErrMsg
  1027. res3.Cainfo = resSix10265.Cainfo
  1028. res3.WarnMsg = resSix10265.WarnMsg
  1029. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1030. res3.Infcode = infocode
  1031. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  1032. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  1033. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  1034. }
  1035. if res3.Infcode == -1 {
  1036. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  1037. } else {
  1038. drug.IsBg = 1
  1039. drug.BgBchno = bg_number
  1040. service.SaveW(drug)
  1041. }
  1042. }
  1043. }
  1044. if len(errs) == 0 {
  1045. c.ServeSuccessJSON(map[string]interface{}{
  1046. "msg": "盘存变更成功",
  1047. })
  1048. } else {
  1049. c.ServeSuccessJSON(map[string]interface{}{
  1050. "failed_code": -10,
  1051. "msg": errs,
  1052. })
  1053. }
  1054. }
  1055. func (c *HisApiController) DeletePCandBG() {
  1056. ids := c.GetString("ids")
  1057. id_arr := strings.Split(ids, ",")
  1058. admin_user_id, _ := c.GetInt64("admin_user_id")
  1059. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1060. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1061. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1062. var err []string
  1063. for _, item := range drugs {
  1064. if item.IsPc == 1 && item.IsBg == 1 {
  1065. var res FJ3507Result
  1066. var res2 FJ3507Result
  1067. var struct3507 models.Struct3507
  1068. struct3507.FixmedinsBchno = item.Bchno
  1069. struct3507.InvDataType = "1"
  1070. struct3507.Opter = roles.UserName
  1071. struct3507.OrgName = miConfig.OrgName
  1072. struct3507.AccessKey = miConfig.AccessKey
  1073. struct3507.RequestUrl = miConfig.Url
  1074. struct3507.FixmedinsCode = miConfig.Code
  1075. struct3507.Code = miConfig.Code
  1076. struct3507.SecretKey = miConfig.SecretKey
  1077. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1078. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1079. struct3507.Url = miConfig.Url
  1080. struct3507.AppId = miConfig.Cainfo
  1081. struct3507.AppSecret = miConfig.AppSecret
  1082. struct3507.Enckey = miConfig.EncKey
  1083. struct3507.SignKey = miConfig.SignKey
  1084. struct3507.SecretKey = miConfig.SecretKey
  1085. if miConfig.MdtrtareaAdmvs == "350500" {
  1086. result, result1, _ := service.FJyb3507(struct3507)
  1087. saveLog(result, result1, "3507", "3507")
  1088. var respJSON2 map[string]interface{}
  1089. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1090. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1092. return
  1093. }
  1094. userJSONBytes2, _ := json.Marshal(respJSON2)
  1095. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1096. utils.ErrorLog("解析失败:%v", err)
  1097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1098. return
  1099. }
  1100. } else {
  1101. data := make(map[string]interface{})
  1102. data["struct_3507s"] = struct3507
  1103. client := &http.Client{}
  1104. bytesData, _ := json.Marshal(data)
  1105. var req *http.Request
  1106. if miConfig.MdtrtareaAdmvs == "320921" {
  1107. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1108. } else {
  1109. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1110. }
  1111. resp, _ := client.Do(req)
  1112. defer resp.Body.Close()
  1113. body, ioErr := ioutil.ReadAll(resp.Body)
  1114. if ioErr != nil {
  1115. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1116. }
  1117. var respJSON map[string]interface{}
  1118. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1119. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1121. return
  1122. }
  1123. var resSix10265 ResultSix10265 //1101结果
  1124. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1125. result, _ := json.Marshal(respJSON)
  1126. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1127. utils.ErrorLog("解析失败:%v", err)
  1128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1129. return
  1130. }
  1131. res.InfRefmsgid = resSix10265.InfRefmsgid
  1132. //res.Output = resSix10265.Output
  1133. res.ErrMsg = resSix10265.ErrMsg
  1134. res.Cainfo = resSix10265.Cainfo
  1135. res.WarnMsg = resSix10265.WarnMsg
  1136. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1137. res.Infcode = infocode
  1138. }
  1139. if res.Infcode == 0 {
  1140. item.IsPc = 0
  1141. err2 := service.SaveW(item)
  1142. if err2 == nil {
  1143. var struct3507_2 models.Struct3507
  1144. struct3507_2.OrgName = miConfig.OrgName
  1145. struct3507_2.AccessKey = miConfig.AccessKey
  1146. struct3507_2.RequestUrl = miConfig.Url
  1147. struct3507_2.Opter = roles.UserName
  1148. struct3507_2.FixmedinsCode = miConfig.Code
  1149. struct3507_2.Code = miConfig.Code
  1150. struct3507_2.SecretKey = miConfig.SecretKey
  1151. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1152. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1153. struct3507_2.Url = miConfig.Url
  1154. struct3507_2.AppId = miConfig.Cainfo
  1155. struct3507_2.AppSecret = miConfig.AppSecret
  1156. struct3507_2.Enckey = miConfig.EncKey
  1157. struct3507_2.SignKey = miConfig.SignKey
  1158. struct3507_2.SecretKey = miConfig.SecretKey
  1159. struct3507_2.FixmedinsBchno = item.BgBchno
  1160. struct3507_2.InvDataType = "2"
  1161. if miConfig.MdtrtareaAdmvs == "350500" {
  1162. result11, result22, _ := service.FJyb3507(struct3507_2)
  1163. saveLog(result11, result22, "3507", "3507")
  1164. var respJSON3 map[string]interface{}
  1165. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1168. return
  1169. }
  1170. userJSONBytes3, _ := json.Marshal(respJSON3)
  1171. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1172. utils.ErrorLog("解析失败:%v", err)
  1173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1174. return
  1175. }
  1176. } else {
  1177. data := make(map[string]interface{})
  1178. data["struct_3507s"] = struct3507_2
  1179. client := &http.Client{}
  1180. bytesData, _ := json.Marshal(data)
  1181. var req *http.Request
  1182. if miConfig.MdtrtareaAdmvs == "320921" {
  1183. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1184. } else {
  1185. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1186. }
  1187. resp, _ := client.Do(req)
  1188. defer resp.Body.Close()
  1189. body, ioErr := ioutil.ReadAll(resp.Body)
  1190. if ioErr != nil {
  1191. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1192. }
  1193. var respJSON map[string]interface{}
  1194. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1195. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1197. return
  1198. }
  1199. var resSix10265 ResultSix10265 //1101结果
  1200. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1201. result, _ := json.Marshal(respJSON)
  1202. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1203. utils.ErrorLog("解析失败:%v", err)
  1204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1205. return
  1206. }
  1207. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1208. //res2.Output = resSix10265.Output
  1209. res2.ErrMsg = resSix10265.ErrMsg
  1210. res2.Cainfo = resSix10265.Cainfo
  1211. res2.WarnMsg = resSix10265.WarnMsg
  1212. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1213. res2.Infcode = infocode
  1214. }
  1215. if res2.Infcode != -1 {
  1216. item.IsBg = 0
  1217. item.Bchno = ""
  1218. item.BgBchno = ""
  1219. item.PcDate = 0
  1220. service.SaveW(item)
  1221. } else {
  1222. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1223. }
  1224. }
  1225. } else {
  1226. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1227. }
  1228. }
  1229. if item.IsPc == 1 && item.IsBg == 0 {
  1230. var res FJ3507Result
  1231. var struct3507 models.Struct3507
  1232. struct3507.FixmedinsBchno = item.Bchno
  1233. struct3507.InvDataType = "1"
  1234. struct3507.Opter = roles.UserName
  1235. struct3507.FixmedinsCode = miConfig.Code
  1236. struct3507.Code = miConfig.Code
  1237. struct3507.OrgName = miConfig.OrgName
  1238. struct3507.AccessKey = miConfig.AccessKey
  1239. struct3507.RequestUrl = miConfig.Url
  1240. struct3507.SecretKey = miConfig.SecretKey
  1241. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1242. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1243. struct3507.Url = miConfig.Url
  1244. struct3507.AppId = miConfig.Cainfo
  1245. struct3507.AppSecret = miConfig.AppSecret
  1246. struct3507.Enckey = miConfig.EncKey
  1247. struct3507.SignKey = miConfig.SignKey
  1248. struct3507.SecretKey = miConfig.SecretKey
  1249. //result, result1, _ := service.FJyb3507(struct3507)
  1250. //saveLog(result, result1, "3507", "3507")
  1251. if miConfig.MdtrtareaAdmvs == "350500" {
  1252. result, result1, _ := service.FJyb3507(struct3507)
  1253. saveLog(result, result1, "3507", "3507")
  1254. var respJSON2 map[string]interface{}
  1255. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1256. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1258. return
  1259. }
  1260. userJSONBytes2, _ := json.Marshal(respJSON2)
  1261. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1262. utils.ErrorLog("解析失败:%v", err)
  1263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1264. return
  1265. }
  1266. } else {
  1267. data := make(map[string]interface{})
  1268. data["struct_3507s"] = struct3507
  1269. client := &http.Client{}
  1270. bytesData, _ := json.Marshal(data)
  1271. var req *http.Request
  1272. if miConfig.MdtrtareaAdmvs == "320921" {
  1273. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1274. } else {
  1275. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1276. }
  1277. resp, _ := client.Do(req)
  1278. defer resp.Body.Close()
  1279. body, ioErr := ioutil.ReadAll(resp.Body)
  1280. if ioErr != nil {
  1281. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1282. }
  1283. var respJSON map[string]interface{}
  1284. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1285. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1287. return
  1288. }
  1289. var resSix10265 ResultSix10265 //1101结果
  1290. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1291. result, _ := json.Marshal(respJSON)
  1292. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1293. utils.ErrorLog("解析失败:%v", err)
  1294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1295. return
  1296. }
  1297. res.InfRefmsgid = resSix10265.InfRefmsgid
  1298. //res.Output = resSix10265.Output
  1299. res.ErrMsg = resSix10265.ErrMsg
  1300. res.Cainfo = resSix10265.Cainfo
  1301. res.WarnMsg = resSix10265.WarnMsg
  1302. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1303. res.Infcode = infocode
  1304. }
  1305. if res.Infcode == 0 {
  1306. item.IsPc = 0
  1307. item.Bchno = ""
  1308. item.BgBchno = ""
  1309. item.PcDate = 0
  1310. service.SaveW(item)
  1311. } else {
  1312. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1313. }
  1314. }
  1315. if item.IsPc == 0 && item.IsBg == 1 {
  1316. var res FJ3507Result
  1317. var struct3507 models.Struct3507
  1318. struct3507.FixmedinsBchno = item.BgBchno
  1319. struct3507.InvDataType = "2"
  1320. struct3507.Opter = roles.UserName
  1321. struct3507.FixmedinsCode = miConfig.Code
  1322. struct3507.OrgName = miConfig.OrgName
  1323. struct3507.AccessKey = miConfig.AccessKey
  1324. struct3507.RequestUrl = miConfig.Url
  1325. struct3507.SecretKey = miConfig.SecretKey
  1326. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1327. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1328. struct3507.Url = miConfig.Url
  1329. struct3507.AppId = miConfig.Cainfo
  1330. struct3507.AppSecret = miConfig.AppSecret
  1331. struct3507.Enckey = miConfig.EncKey
  1332. struct3507.SignKey = miConfig.SignKey
  1333. struct3507.SecretKey = miConfig.SecretKey
  1334. //result, result1, _ := service.FJyb3507(struct3507)
  1335. //saveLog(result, result1, "3507", "3507")
  1336. if miConfig.MdtrtareaAdmvs == "350500" {
  1337. result, result1, _ := service.FJyb3507(struct3507)
  1338. saveLog(result, result1, "3507", "3507")
  1339. var respJSON2 map[string]interface{}
  1340. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1341. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1343. return
  1344. }
  1345. userJSONBytes2, _ := json.Marshal(respJSON2)
  1346. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1347. utils.ErrorLog("解析失败:%v", err)
  1348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1349. return
  1350. }
  1351. } else {
  1352. data := make(map[string]interface{})
  1353. data["struct_3507s"] = struct3507
  1354. client := &http.Client{}
  1355. bytesData, _ := json.Marshal(data)
  1356. var req *http.Request
  1357. if miConfig.MdtrtareaAdmvs == "320921" {
  1358. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1359. } else {
  1360. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1361. }
  1362. resp, _ := client.Do(req)
  1363. defer resp.Body.Close()
  1364. body, ioErr := ioutil.ReadAll(resp.Body)
  1365. if ioErr != nil {
  1366. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1367. }
  1368. var respJSON map[string]interface{}
  1369. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1370. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1372. return
  1373. }
  1374. var resSix10265 ResultSix10265 //1101结果
  1375. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1376. result, _ := json.Marshal(respJSON)
  1377. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1378. utils.ErrorLog("解析失败:%v", err)
  1379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1380. return
  1381. }
  1382. res.InfRefmsgid = resSix10265.InfRefmsgid
  1383. //res.Output = resSix10265.Output
  1384. res.ErrMsg = resSix10265.ErrMsg
  1385. res.Cainfo = resSix10265.Cainfo
  1386. res.WarnMsg = resSix10265.WarnMsg
  1387. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1388. res.Infcode = infocode
  1389. }
  1390. if res.Infcode == 0 {
  1391. item.IsBg = 0
  1392. item.Bchno = ""
  1393. item.BgBchno = ""
  1394. item.PcDate = 0
  1395. service.SaveW(item)
  1396. } else {
  1397. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1398. }
  1399. }
  1400. }
  1401. if len(err) == 0 {
  1402. c.ServeSuccessJSON(map[string]interface{}{
  1403. "msg": "删除盘存变更成功",
  1404. })
  1405. } else {
  1406. c.ServeSuccessJSON(map[string]interface{}{
  1407. "failed_code": -10,
  1408. "msg": err,
  1409. })
  1410. }
  1411. }
  1412. func (c *HisApiController) DeleteXSandBG() {
  1413. ids := c.GetString("ids")
  1414. id_arr := strings.Split(ids, ",")
  1415. admin_user_id, _ := c.GetInt64("admin_user_id")
  1416. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1417. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1418. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1419. var err []string
  1420. for _, item := range flows {
  1421. if item.IsSale == 1 && item.IsChange == 1 {
  1422. var res FJ3507Result
  1423. var res2 FJ3507Result
  1424. var struct3507 models.Struct3507
  1425. struct3507.FixmedinsBchno = item.Bchno
  1426. struct3507.InvDataType = "4"
  1427. struct3507.Opter = roles.UserName
  1428. struct3507.OrgName = miConfig.OrgName
  1429. struct3507.AccessKey = miConfig.AccessKey
  1430. struct3507.RequestUrl = miConfig.Url
  1431. struct3507.FixmedinsCode = miConfig.Code
  1432. struct3507.SecretKey = miConfig.SecretKey
  1433. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1434. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1435. struct3507.Url = miConfig.Url
  1436. struct3507.AppId = miConfig.Cainfo
  1437. struct3507.AppSecret = miConfig.AppSecret
  1438. struct3507.Enckey = miConfig.EncKey
  1439. struct3507.SignKey = miConfig.SignKey
  1440. struct3507.SecretKey = miConfig.SecretKey
  1441. //result, result1, _ := service.FJyb3507(struct3507)
  1442. //saveLog(result, result1, "3507", "3507")
  1443. if miConfig.MdtrtareaAdmvs == "350500" {
  1444. result, result1, _ := service.FJyb3507(struct3507)
  1445. saveLog(result, result1, "3507", "3507")
  1446. var respJSON2 map[string]interface{}
  1447. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1448. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1450. return
  1451. }
  1452. userJSONBytes2, _ := json.Marshal(respJSON2)
  1453. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1454. utils.ErrorLog("解析失败:%v", err)
  1455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1456. return
  1457. }
  1458. } else {
  1459. data := make(map[string]interface{})
  1460. data["struct_3507s"] = struct3507
  1461. client := &http.Client{}
  1462. bytesData, _ := json.Marshal(data)
  1463. var req *http.Request
  1464. if miConfig.MdtrtareaAdmvs == "320921" {
  1465. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1466. } else {
  1467. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1468. }
  1469. resp, _ := client.Do(req)
  1470. defer resp.Body.Close()
  1471. body, ioErr := ioutil.ReadAll(resp.Body)
  1472. if ioErr != nil {
  1473. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1474. }
  1475. var respJSON map[string]interface{}
  1476. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1477. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1479. return
  1480. }
  1481. var resSix10265 ResultSix10265 //1101结果
  1482. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1483. result, _ := json.Marshal(respJSON)
  1484. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1485. utils.ErrorLog("解析失败:%v", err)
  1486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1487. return
  1488. }
  1489. res.InfRefmsgid = resSix10265.InfRefmsgid
  1490. //res.Output = resSix10265.Output
  1491. res.ErrMsg = resSix10265.ErrMsg
  1492. res.Cainfo = resSix10265.Cainfo
  1493. res.WarnMsg = resSix10265.WarnMsg
  1494. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1495. res.Infcode = infocode
  1496. }
  1497. if res.Infcode == 0 {
  1498. item.IsSale = 0
  1499. item.SaleDate = ""
  1500. item.Bchno = ""
  1501. err2 := service.SaveDF(item)
  1502. if err2 == nil {
  1503. var struct3507_2 models.Struct3507
  1504. struct3507_2.OrgName = miConfig.OrgName
  1505. struct3507_2.AccessKey = miConfig.AccessKey
  1506. struct3507_2.RequestUrl = miConfig.Url
  1507. struct3507_2.Opter = roles.UserName
  1508. struct3507_2.FixmedinsCode = miConfig.Code
  1509. struct3507_2.Code = miConfig.Code
  1510. struct3507_2.SecretKey = miConfig.SecretKey
  1511. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1512. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1513. struct3507_2.Url = miConfig.Url
  1514. struct3507_2.AppId = miConfig.Cainfo
  1515. struct3507_2.AppSecret = miConfig.AppSecret
  1516. struct3507_2.Enckey = miConfig.EncKey
  1517. struct3507_2.SignKey = miConfig.SignKey
  1518. struct3507_2.SecretKey = miConfig.SecretKey
  1519. struct3507_2.FixmedinsBchno = item.BgBchno
  1520. struct3507_2.InvDataType = "2"
  1521. if miConfig.MdtrtareaAdmvs == "350500" {
  1522. result11, result22, _ := service.FJyb3507(struct3507_2)
  1523. saveLog(result11, result22, "3507", "3507")
  1524. var respJSON3 map[string]interface{}
  1525. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1526. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1528. return
  1529. }
  1530. userJSONBytes3, _ := json.Marshal(respJSON3)
  1531. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1532. utils.ErrorLog("解析失败:%v", err)
  1533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1534. return
  1535. }
  1536. } else {
  1537. data := make(map[string]interface{})
  1538. data["struct_3507s"] = struct3507_2
  1539. client := &http.Client{}
  1540. bytesData, _ := json.Marshal(data)
  1541. var req *http.Request
  1542. if miConfig.MdtrtareaAdmvs == "320921" {
  1543. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1544. } else {
  1545. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1546. }
  1547. resp, _ := client.Do(req)
  1548. defer resp.Body.Close()
  1549. body, ioErr := ioutil.ReadAll(resp.Body)
  1550. if ioErr != nil {
  1551. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1552. }
  1553. var respJSON map[string]interface{}
  1554. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1555. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1557. return
  1558. }
  1559. var resSix10265 ResultSix10265 //1101结果
  1560. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1561. result, _ := json.Marshal(respJSON)
  1562. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1563. utils.ErrorLog("解析失败:%v", err)
  1564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1565. return
  1566. }
  1567. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1568. //res.Output = resSix10265.Output
  1569. res2.ErrMsg = resSix10265.ErrMsg
  1570. res2.Cainfo = resSix10265.Cainfo
  1571. res2.WarnMsg = resSix10265.WarnMsg
  1572. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1573. res2.Infcode = infocode
  1574. }
  1575. if res2.Infcode == 0 {
  1576. item.IsChange = 0
  1577. item.BgBchno = ""
  1578. service.SaveDF2(item)
  1579. } else {
  1580. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1581. }
  1582. }
  1583. } else {
  1584. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1585. }
  1586. }
  1587. if item.IsSale == 2 && item.IsChange == 1 {
  1588. var res FJ3507Result
  1589. var res2 FJ3507Result
  1590. var struct3507 models.Struct3507
  1591. struct3507.FixmedinsBchno = item.Bchno
  1592. struct3507.InvDataType = "4"
  1593. struct3507.Opter = roles.UserName
  1594. struct3507.OrgName = miConfig.OrgName
  1595. struct3507.AccessKey = miConfig.AccessKey
  1596. struct3507.RequestUrl = miConfig.Url
  1597. struct3507.FixmedinsCode = miConfig.Code
  1598. struct3507.Code = miConfig.Code
  1599. struct3507.SecretKey = miConfig.SecretKey
  1600. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1601. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1602. struct3507.Url = miConfig.Url
  1603. struct3507.AppId = miConfig.Cainfo
  1604. struct3507.AppSecret = miConfig.AppSecret
  1605. struct3507.Enckey = miConfig.EncKey
  1606. struct3507.SignKey = miConfig.SignKey
  1607. struct3507.SecretKey = miConfig.SecretKey
  1608. //result, result1, _ := service.FJyb3507(struct3507)
  1609. //saveLog(result, result1, "3507", "3507")
  1610. //
  1611. //var respJSON2 map[string]interface{}
  1612. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1613. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1614. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1615. // return
  1616. //}
  1617. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1618. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1619. // utils.ErrorLog("解析失败:%v", err)
  1620. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1621. // return
  1622. //}
  1623. if miConfig.MdtrtareaAdmvs == "350500" {
  1624. result, result1, _ := service.FJyb3507(struct3507)
  1625. saveLog(result, result1, "3507", "3507")
  1626. var respJSON2 map[string]interface{}
  1627. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1630. return
  1631. }
  1632. userJSONBytes2, _ := json.Marshal(respJSON2)
  1633. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1634. utils.ErrorLog("解析失败:%v", err)
  1635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1636. return
  1637. }
  1638. } else {
  1639. data := make(map[string]interface{})
  1640. data["struct_3507s"] = struct3507
  1641. client := &http.Client{}
  1642. bytesData, _ := json.Marshal(data)
  1643. var req *http.Request
  1644. if miConfig.MdtrtareaAdmvs == "320921" {
  1645. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1646. } else {
  1647. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1648. }
  1649. resp, _ := client.Do(req)
  1650. defer resp.Body.Close()
  1651. body, ioErr := ioutil.ReadAll(resp.Body)
  1652. if ioErr != nil {
  1653. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1654. }
  1655. var respJSON map[string]interface{}
  1656. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1659. return
  1660. }
  1661. var resSix10265 ResultSix10265 //1101结果
  1662. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1663. result, _ := json.Marshal(respJSON)
  1664. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1665. utils.ErrorLog("解析失败:%v", err)
  1666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1667. return
  1668. }
  1669. res.InfRefmsgid = resSix10265.InfRefmsgid
  1670. //res.Output = resSix10265.Output
  1671. res.ErrMsg = resSix10265.ErrMsg
  1672. res.Cainfo = resSix10265.Cainfo
  1673. res.WarnMsg = resSix10265.WarnMsg
  1674. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1675. res.Infcode = infocode
  1676. }
  1677. if res.Infcode == 0 {
  1678. item.IsSale = 0
  1679. item.SaleDate = ""
  1680. item.Bchno = ""
  1681. err2 := service.SaveDF(item)
  1682. if err2 == nil {
  1683. var struct3507_2 models.Struct3507
  1684. struct3507_2.OrgName = miConfig.OrgName
  1685. struct3507_2.AccessKey = miConfig.AccessKey
  1686. struct3507_2.RequestUrl = miConfig.Url
  1687. struct3507_2.Opter = roles.UserName
  1688. struct3507_2.FixmedinsCode = miConfig.Code
  1689. struct3507_2.Code = miConfig.Code
  1690. struct3507_2.SecretKey = miConfig.SecretKey
  1691. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1692. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1693. struct3507_2.Url = miConfig.Url
  1694. struct3507_2.AppId = miConfig.Cainfo
  1695. struct3507_2.AppSecret = miConfig.AppSecret
  1696. struct3507_2.Enckey = miConfig.EncKey
  1697. struct3507_2.SignKey = miConfig.SignKey
  1698. struct3507_2.SecretKey = miConfig.SecretKey
  1699. struct3507_2.FixmedinsBchno = item.BgBchno
  1700. struct3507_2.InvDataType = "2"
  1701. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1702. //saveLog(result11, result22, "3507", "3507")
  1703. //var respJSON3 map[string]interface{}
  1704. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1705. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1706. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1707. // return
  1708. //}
  1709. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1710. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1711. // utils.ErrorLog("解析失败:%v", err)
  1712. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1713. // return
  1714. //}
  1715. if miConfig.MdtrtareaAdmvs == "350500" {
  1716. result11, result22, _ := service.FJyb3507(struct3507_2)
  1717. saveLog(result11, result22, "3507", "3507")
  1718. var respJSON3 map[string]interface{}
  1719. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1722. return
  1723. }
  1724. userJSONBytes3, _ := json.Marshal(respJSON3)
  1725. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1726. utils.ErrorLog("解析失败:%v", err)
  1727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1728. return
  1729. }
  1730. } else {
  1731. data := make(map[string]interface{})
  1732. data["struct_3507s"] = struct3507_2
  1733. client := &http.Client{}
  1734. bytesData, _ := json.Marshal(data)
  1735. var req *http.Request
  1736. if miConfig.MdtrtareaAdmvs == "320921" {
  1737. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1738. } else {
  1739. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1740. }
  1741. resp, _ := client.Do(req)
  1742. defer resp.Body.Close()
  1743. body, ioErr := ioutil.ReadAll(resp.Body)
  1744. if ioErr != nil {
  1745. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1746. }
  1747. var respJSON map[string]interface{}
  1748. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1749. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1751. return
  1752. }
  1753. var resSix10265 ResultSix10265 //1101结果
  1754. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1755. result, _ := json.Marshal(respJSON)
  1756. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1757. utils.ErrorLog("解析失败:%v", err)
  1758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1759. return
  1760. }
  1761. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1762. //res.Output = resSix10265.Output
  1763. res2.ErrMsg = resSix10265.ErrMsg
  1764. res2.Cainfo = resSix10265.Cainfo
  1765. res2.WarnMsg = resSix10265.WarnMsg
  1766. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1767. res2.Infcode = infocode
  1768. }
  1769. if res2.Infcode == 0 {
  1770. item.IsChange = 0
  1771. item.BgBchno = ""
  1772. service.SaveDF2(item)
  1773. } else {
  1774. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1775. }
  1776. }
  1777. } else {
  1778. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1779. }
  1780. }
  1781. if item.IsSale == 1 && item.IsChange == 0 {
  1782. var res FJ3507Result
  1783. var struct3507 models.Struct3507
  1784. struct3507.FixmedinsBchno = item.Bchno
  1785. struct3507.InvDataType = "4"
  1786. struct3507.Opter = roles.UserName
  1787. struct3507.FixmedinsCode = miConfig.Code
  1788. struct3507.Code = miConfig.Code
  1789. struct3507.OrgName = miConfig.OrgName
  1790. struct3507.AccessKey = miConfig.AccessKey
  1791. struct3507.RequestUrl = miConfig.Url
  1792. struct3507.SecretKey = miConfig.SecretKey
  1793. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1794. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1795. struct3507.Url = miConfig.Url
  1796. struct3507.AppId = miConfig.Cainfo
  1797. struct3507.AppSecret = miConfig.AppSecret
  1798. struct3507.Enckey = miConfig.EncKey
  1799. struct3507.SignKey = miConfig.SignKey
  1800. struct3507.SecretKey = miConfig.SecretKey
  1801. //result, result1, _ := service.FJyb3507(struct3507)
  1802. //saveLog(result, result1, "3507", "3507")
  1803. //
  1804. //var respJSON3 map[string]interface{}
  1805. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1806. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1807. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1808. // return
  1809. //}
  1810. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1811. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1812. // utils.ErrorLog("解析失败:%v", err)
  1813. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1814. // return
  1815. //}
  1816. if miConfig.MdtrtareaAdmvs == "350500" {
  1817. result, result1, _ := service.FJyb3507(struct3507)
  1818. saveLog(result, result1, "3507", "3507")
  1819. var respJSON2 map[string]interface{}
  1820. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1823. return
  1824. }
  1825. userJSONBytes2, _ := json.Marshal(respJSON2)
  1826. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1827. utils.ErrorLog("解析失败:%v", err)
  1828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1829. return
  1830. }
  1831. } else {
  1832. data := make(map[string]interface{})
  1833. data["struct_3507s"] = struct3507
  1834. client := &http.Client{}
  1835. bytesData, _ := json.Marshal(data)
  1836. var req *http.Request
  1837. if miConfig.MdtrtareaAdmvs == "320921" {
  1838. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1839. } else {
  1840. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1841. }
  1842. resp, _ := client.Do(req)
  1843. defer resp.Body.Close()
  1844. body, ioErr := ioutil.ReadAll(resp.Body)
  1845. if ioErr != nil {
  1846. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1847. }
  1848. var respJSON map[string]interface{}
  1849. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1850. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1852. return
  1853. }
  1854. var resSix10265 ResultSix10265 //1101结果
  1855. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1856. result, _ := json.Marshal(respJSON)
  1857. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1858. utils.ErrorLog("解析失败:%v", err)
  1859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1860. return
  1861. }
  1862. res.InfRefmsgid = resSix10265.InfRefmsgid
  1863. //res.Output = resSix10265.Output
  1864. res.ErrMsg = resSix10265.ErrMsg
  1865. res.Cainfo = resSix10265.Cainfo
  1866. res.WarnMsg = resSix10265.WarnMsg
  1867. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1868. res.Infcode = infocode
  1869. }
  1870. if res.Infcode == 0 {
  1871. item.IsSale = 0
  1872. item.SaleDate = ""
  1873. service.SaveDF(item)
  1874. } else {
  1875. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1876. }
  1877. }
  1878. if item.IsSale == 2 && item.IsChange == 0 {
  1879. var res FJ3507Result
  1880. var struct3507 models.Struct3507
  1881. struct3507.FixmedinsBchno = item.Bchno
  1882. struct3507.InvDataType = "4"
  1883. struct3507.Opter = roles.UserName
  1884. struct3507.FixmedinsCode = miConfig.Code
  1885. struct3507.Code = miConfig.Code
  1886. struct3507.OrgName = miConfig.OrgName
  1887. struct3507.AccessKey = miConfig.AccessKey
  1888. struct3507.RequestUrl = miConfig.Url
  1889. struct3507.SecretKey = miConfig.SecretKey
  1890. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1891. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1892. struct3507.Url = miConfig.Url
  1893. struct3507.AppId = miConfig.Cainfo
  1894. struct3507.AppSecret = miConfig.AppSecret
  1895. struct3507.Enckey = miConfig.EncKey
  1896. struct3507.SignKey = miConfig.SignKey
  1897. struct3507.SecretKey = miConfig.SecretKey
  1898. //result, result1, _ := service.FJyb3507(struct3507)
  1899. //saveLog(result, result1, "3507", "3507")
  1900. //
  1901. //var respJSON3 map[string]interface{}
  1902. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1903. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1904. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1905. // return
  1906. //}
  1907. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1908. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1909. // utils.ErrorLog("解析失败:%v", err)
  1910. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1911. // return
  1912. //}
  1913. if miConfig.MdtrtareaAdmvs == "350500" {
  1914. result, result1, _ := service.FJyb3507(struct3507)
  1915. saveLog(result, result1, "3507", "3507")
  1916. var respJSON2 map[string]interface{}
  1917. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1918. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1920. return
  1921. }
  1922. userJSONBytes2, _ := json.Marshal(respJSON2)
  1923. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1924. utils.ErrorLog("解析失败:%v", err)
  1925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1926. return
  1927. }
  1928. } else {
  1929. data := make(map[string]interface{})
  1930. data["struct_3507s"] = struct3507
  1931. client := &http.Client{}
  1932. bytesData, _ := json.Marshal(data)
  1933. var req *http.Request
  1934. if miConfig.MdtrtareaAdmvs == "320921" {
  1935. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1936. } else {
  1937. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1938. }
  1939. resp, _ := client.Do(req)
  1940. defer resp.Body.Close()
  1941. body, ioErr := ioutil.ReadAll(resp.Body)
  1942. if ioErr != nil {
  1943. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1944. }
  1945. var respJSON map[string]interface{}
  1946. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1947. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1949. return
  1950. }
  1951. var resSix10265 ResultSix10265 //1101结果
  1952. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1953. result, _ := json.Marshal(respJSON)
  1954. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1955. utils.ErrorLog("解析失败:%v", err)
  1956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1957. return
  1958. }
  1959. res.InfRefmsgid = resSix10265.InfRefmsgid
  1960. //res.Output = resSix10265.Output
  1961. res.ErrMsg = resSix10265.ErrMsg
  1962. res.Cainfo = resSix10265.Cainfo
  1963. res.WarnMsg = resSix10265.WarnMsg
  1964. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1965. res.Infcode = infocode
  1966. }
  1967. if res.Infcode == 0 {
  1968. item.IsSale = 0
  1969. item.SaleDate = ""
  1970. item.Bchno = ""
  1971. service.SaveDF(item)
  1972. } else {
  1973. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1974. }
  1975. }
  1976. if item.IsSale == 0 && item.IsChange == 1 {
  1977. var res FJ3507Result
  1978. var struct3507 models.Struct3507
  1979. struct3507.FixmedinsBchno = item.BgBchno
  1980. struct3507.InvDataType = "2"
  1981. struct3507.Opter = roles.UserName
  1982. struct3507.FixmedinsCode = miConfig.Code
  1983. struct3507.Code = miConfig.Code
  1984. struct3507.OrgName = miConfig.OrgName
  1985. struct3507.AccessKey = miConfig.AccessKey
  1986. struct3507.RequestUrl = miConfig.Url
  1987. struct3507.SecretKey = miConfig.SecretKey
  1988. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1989. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1990. struct3507.Url = miConfig.Url
  1991. struct3507.AppId = miConfig.Cainfo
  1992. struct3507.AppSecret = miConfig.AppSecret
  1993. struct3507.Enckey = miConfig.EncKey
  1994. struct3507.SignKey = miConfig.SignKey
  1995. struct3507.SecretKey = miConfig.SecretKey
  1996. //result, result1, _ := service.FJyb3507(struct3507)
  1997. //saveLog(result, result1, "3507", "3507")
  1998. //
  1999. //var respJSON3 map[string]interface{}
  2000. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2001. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2002. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2003. // return
  2004. //}
  2005. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2006. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2007. // utils.ErrorLog("解析失败:%v", err)
  2008. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2009. // return
  2010. //}
  2011. if miConfig.MdtrtareaAdmvs == "350500" {
  2012. result, result1, _ := service.FJyb3507(struct3507)
  2013. saveLog(result, result1, "3507", "3507")
  2014. var respJSON2 map[string]interface{}
  2015. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2016. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2018. return
  2019. }
  2020. userJSONBytes2, _ := json.Marshal(respJSON2)
  2021. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2022. utils.ErrorLog("解析失败:%v", err)
  2023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2024. return
  2025. }
  2026. } else {
  2027. data := make(map[string]interface{})
  2028. data["struct_3507s"] = struct3507
  2029. client := &http.Client{}
  2030. bytesData, _ := json.Marshal(data)
  2031. var req *http.Request
  2032. if miConfig.MdtrtareaAdmvs == "320921" {
  2033. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2034. } else {
  2035. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2036. }
  2037. resp, _ := client.Do(req)
  2038. defer resp.Body.Close()
  2039. body, ioErr := ioutil.ReadAll(resp.Body)
  2040. if ioErr != nil {
  2041. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2042. }
  2043. var respJSON map[string]interface{}
  2044. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2045. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2047. return
  2048. }
  2049. var resSix10265 ResultSix10265 //1101结果
  2050. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2051. result, _ := json.Marshal(respJSON)
  2052. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2053. utils.ErrorLog("解析失败:%v", err)
  2054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2055. return
  2056. }
  2057. res.InfRefmsgid = resSix10265.InfRefmsgid
  2058. //res.Output = resSix10265.Output
  2059. res.ErrMsg = resSix10265.ErrMsg
  2060. res.Cainfo = resSix10265.Cainfo
  2061. res.WarnMsg = resSix10265.WarnMsg
  2062. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2063. res.Infcode = infocode
  2064. }
  2065. if res.Infcode == 0 {
  2066. item.IsChange = 0
  2067. item.BgBchno = ""
  2068. service.SaveDF2(item)
  2069. } else {
  2070. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2071. }
  2072. }
  2073. }
  2074. if len(err) == 0 {
  2075. c.ServeSuccessJSON(map[string]interface{}{
  2076. "msg": "删除销售变更成功",
  2077. })
  2078. } else {
  2079. c.ServeSuccessJSON(map[string]interface{}{
  2080. "failed_code": -10,
  2081. "msg": err,
  2082. })
  2083. }
  2084. }
  2085. //func (c *HisApiController) DeleteXSandBGTwo() {
  2086. // patient_id, _ := c.GetInt64("patient_id")
  2087. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2088. // //id_arr := strings.Split(ids, ",")
  2089. // times := c.GetString("time", "")
  2090. // timeLayout := "2006-01-02"
  2091. // loc, _ := time.LoadLocation("Local")
  2092. // var stime, etime int64
  2093. // if times == "" {
  2094. // stime, etime = GetNowTime()
  2095. // } else {
  2096. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2097. // stime = stmp.Unix()
  2098. // etime = stime + 86399
  2099. // }
  2100. // advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2101. // var flows []*models.DrugFlow
  2102. // for _, item := range advicelist {
  2103. // flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.ID, times, c.GetAdminUserInfo().CurrentOrgId)
  2104. // flows = append(flows, flow...)
  2105. // }
  2106. //
  2107. // //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2108. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2109. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2110. //
  2111. // var err []string
  2112. // for _, item := range flows {
  2113. // if item.IsSale == 1 && item.IsChange == 1 {
  2114. // var res FJ3507Result
  2115. // var res2 FJ3507Result
  2116. //
  2117. // var struct3507 models.Struct3507
  2118. // struct3507.FixmedinsBchno = item.Bchno
  2119. // struct3507.InvDataType = "4"
  2120. // struct3507.Opter = roles.UserName
  2121. // struct3507.OrgName = miConfig.OrgName
  2122. // struct3507.AccessKey = miConfig.AccessKey
  2123. // struct3507.RequestUrl = miConfig.Url
  2124. // struct3507.FixmedinsCode = miConfig.Code
  2125. // struct3507.SecretKey = miConfig.SecretKey
  2126. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2127. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2128. // struct3507.Url = miConfig.Url
  2129. // struct3507.AppId = miConfig.Cainfo
  2130. // struct3507.AppSecret = miConfig.AppSecret
  2131. // struct3507.Enckey = miConfig.EncKey
  2132. // struct3507.SignKey = miConfig.SignKey
  2133. // struct3507.SecretKey = miConfig.SecretKey
  2134. //
  2135. // //result, result1, _ := service.FJyb3507(struct3507)
  2136. // //saveLog(result, result1, "3507", "3507")
  2137. //
  2138. // if miConfig.MdtrtareaAdmvs == "350500" {
  2139. // result, result1, _ := service.FJyb3507(struct3507)
  2140. // saveLog(result, result1, "3507", "3507")
  2141. // var respJSON2 map[string]interface{}
  2142. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2143. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2144. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2145. // return
  2146. // }
  2147. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2148. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2149. // utils.ErrorLog("解析失败:%v", err)
  2150. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2151. // return
  2152. // }
  2153. // } else {
  2154. // data := make(map[string]interface{})
  2155. // data["struct_3507s"] = struct3507
  2156. // client := &http.Client{}
  2157. // bytesData, _ := json.Marshal(data)
  2158. // var req *http.Request
  2159. // if miConfig.MdtrtareaAdmvs == "320921" {
  2160. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2161. // } else {
  2162. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2163. // }
  2164. //
  2165. // resp, _ := client.Do(req)
  2166. // defer resp.Body.Close()
  2167. // body, ioErr := ioutil.ReadAll(resp.Body)
  2168. // if ioErr != nil {
  2169. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2170. // }
  2171. // var respJSON map[string]interface{}
  2172. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2173. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2174. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2175. // return
  2176. // }
  2177. // var resSix10265 ResultSix10265 //1101结果
  2178. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2179. // result, _ := json.Marshal(respJSON)
  2180. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2181. // utils.ErrorLog("解析失败:%v", err)
  2182. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2183. // return
  2184. // }
  2185. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2186. // //res.Output = resSix10265.Output
  2187. // res.ErrMsg = resSix10265.ErrMsg
  2188. // res.Cainfo = resSix10265.Cainfo
  2189. // res.WarnMsg = resSix10265.WarnMsg
  2190. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2191. // res.Infcode = infocode
  2192. // }
  2193. //
  2194. // if res.Infcode == 0 {
  2195. // item.IsSale = 0
  2196. // item.SaleDate = ""
  2197. // item.Bchno = ""
  2198. //
  2199. // err2 := service.SaveDF(item)
  2200. // if err2 == nil {
  2201. // var struct3507_2 models.Struct3507
  2202. // struct3507_2.OrgName = miConfig.OrgName
  2203. // struct3507_2.AccessKey = miConfig.AccessKey
  2204. // struct3507_2.RequestUrl = miConfig.Url
  2205. // struct3507_2.Opter = roles.UserName
  2206. // struct3507_2.FixmedinsCode = miConfig.Code
  2207. // struct3507_2.Code = miConfig.Code
  2208. //
  2209. // struct3507_2.SecretKey = miConfig.SecretKey
  2210. // struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2211. // struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2212. // struct3507_2.Url = miConfig.Url
  2213. // struct3507_2.AppId = miConfig.Cainfo
  2214. // struct3507_2.AppSecret = miConfig.AppSecret
  2215. // struct3507_2.Enckey = miConfig.EncKey
  2216. // struct3507_2.SignKey = miConfig.SignKey
  2217. // struct3507_2.SecretKey = miConfig.SecretKey
  2218. // struct3507_2.FixmedinsBchno = item.BgBchno
  2219. // struct3507_2.InvDataType = "2"
  2220. //
  2221. // if miConfig.MdtrtareaAdmvs == "350500" {
  2222. // result11, result22, _ := service.FJyb3507(struct3507_2)
  2223. // saveLog(result11, result22, "3507", "3507")
  2224. //
  2225. // var respJSON3 map[string]interface{}
  2226. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2227. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2228. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2229. // return
  2230. // }
  2231. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2232. // if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2233. // utils.ErrorLog("解析失败:%v", err)
  2234. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2235. // return
  2236. // }
  2237. // } else {
  2238. //
  2239. // data := make(map[string]interface{})
  2240. // data["struct_3507s"] = struct3507_2
  2241. // client := &http.Client{}
  2242. // bytesData, _ := json.Marshal(data)
  2243. // var req *http.Request
  2244. // if miConfig.MdtrtareaAdmvs == "320921" {
  2245. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2246. // } else {
  2247. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2248. // }
  2249. //
  2250. // resp, _ := client.Do(req)
  2251. // defer resp.Body.Close()
  2252. // body, ioErr := ioutil.ReadAll(resp.Body)
  2253. // if ioErr != nil {
  2254. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2255. // }
  2256. // var respJSON map[string]interface{}
  2257. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2258. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2259. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2260. // return
  2261. // }
  2262. // var resSix10265 ResultSix10265 //1101结果
  2263. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2264. // result, _ := json.Marshal(respJSON)
  2265. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2266. // utils.ErrorLog("解析失败:%v", err)
  2267. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2268. // return
  2269. // }
  2270. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2271. // //res.Output = resSix10265.Output
  2272. // res2.ErrMsg = resSix10265.ErrMsg
  2273. // res2.Cainfo = resSix10265.Cainfo
  2274. // res2.WarnMsg = resSix10265.WarnMsg
  2275. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2276. // res2.Infcode = infocode
  2277. // }
  2278. //
  2279. // if res2.Infcode == 0 {
  2280. // item.IsChange = 0
  2281. // item.BgBchno = ""
  2282. // service.SaveDF2(item)
  2283. // } else {
  2284. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2285. // }
  2286. // }
  2287. // } else {
  2288. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2289. // }
  2290. //
  2291. // }
  2292. // if item.IsSale == 2 && item.IsChange == 1 {
  2293. // var res FJ3507Result
  2294. // var res2 FJ3507Result
  2295. //
  2296. // var struct3507 models.Struct3507
  2297. // struct3507.FixmedinsBchno = item.Bchno
  2298. // struct3507.InvDataType = "4"
  2299. // struct3507.Opter = roles.UserName
  2300. // struct3507.OrgName = miConfig.OrgName
  2301. // struct3507.AccessKey = miConfig.AccessKey
  2302. // struct3507.RequestUrl = miConfig.Url
  2303. // struct3507.FixmedinsCode = miConfig.Code
  2304. // struct3507.Code = miConfig.Code
  2305. //
  2306. // struct3507.SecretKey = miConfig.SecretKey
  2307. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2308. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2309. // struct3507.Url = miConfig.Url
  2310. // struct3507.AppId = miConfig.Cainfo
  2311. // struct3507.AppSecret = miConfig.AppSecret
  2312. // struct3507.Enckey = miConfig.EncKey
  2313. // struct3507.SignKey = miConfig.SignKey
  2314. // struct3507.SecretKey = miConfig.SecretKey
  2315. // //result, result1, _ := service.FJyb3507(struct3507)
  2316. // //saveLog(result, result1, "3507", "3507")
  2317. // //
  2318. // //var respJSON2 map[string]interface{}
  2319. // //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2320. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2321. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2322. // // return
  2323. // //}
  2324. // //userJSONBytes2, _ := json.Marshal(respJSON2)
  2325. // //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2326. // // utils.ErrorLog("解析失败:%v", err)
  2327. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2328. // // return
  2329. // //}
  2330. //
  2331. // if miConfig.MdtrtareaAdmvs == "350500" {
  2332. // result, result1, _ := service.FJyb3507(struct3507)
  2333. // saveLog(result, result1, "3507", "3507")
  2334. // var respJSON2 map[string]interface{}
  2335. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2336. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2337. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2338. // return
  2339. // }
  2340. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2341. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2342. // utils.ErrorLog("解析失败:%v", err)
  2343. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2344. // return
  2345. // }
  2346. // } else {
  2347. // data := make(map[string]interface{})
  2348. // data["struct_3507s"] = struct3507
  2349. // client := &http.Client{}
  2350. // bytesData, _ := json.Marshal(data)
  2351. // var req *http.Request
  2352. // if miConfig.MdtrtareaAdmvs == "320921" {
  2353. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2354. // } else {
  2355. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2356. // }
  2357. //
  2358. // resp, _ := client.Do(req)
  2359. // defer resp.Body.Close()
  2360. // body, ioErr := ioutil.ReadAll(resp.Body)
  2361. // if ioErr != nil {
  2362. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2363. // }
  2364. // var respJSON map[string]interface{}
  2365. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2366. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2367. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2368. // return
  2369. // }
  2370. // var resSix10265 ResultSix10265 //1101结果
  2371. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2372. // result, _ := json.Marshal(respJSON)
  2373. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2374. // utils.ErrorLog("解析失败:%v", err)
  2375. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2376. // return
  2377. // }
  2378. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2379. // //res.Output = resSix10265.Output
  2380. // res.ErrMsg = resSix10265.ErrMsg
  2381. // res.Cainfo = resSix10265.Cainfo
  2382. // res.WarnMsg = resSix10265.WarnMsg
  2383. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2384. // res.Infcode = infocode
  2385. // }
  2386. //
  2387. // if res.Infcode == 0 {
  2388. // item.IsSale = 0
  2389. // item.SaleDate = ""
  2390. // item.Bchno = ""
  2391. // err2 := service.SaveDF(item)
  2392. // if err2 == nil {
  2393. // var struct3507_2 models.Struct3507
  2394. // struct3507_2.OrgName = miConfig.OrgName
  2395. // struct3507_2.AccessKey = miConfig.AccessKey
  2396. // struct3507_2.RequestUrl = miConfig.Url
  2397. // struct3507_2.Opter = roles.UserName
  2398. // struct3507_2.FixmedinsCode = miConfig.Code
  2399. // struct3507_2.Code = miConfig.Code
  2400. //
  2401. // struct3507_2.SecretKey = miConfig.SecretKey
  2402. // struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2403. // struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2404. // struct3507_2.Url = miConfig.Url
  2405. // struct3507_2.AppId = miConfig.Cainfo
  2406. // struct3507_2.AppSecret = miConfig.AppSecret
  2407. // struct3507_2.Enckey = miConfig.EncKey
  2408. // struct3507_2.SignKey = miConfig.SignKey
  2409. // struct3507_2.SecretKey = miConfig.SecretKey
  2410. // struct3507_2.FixmedinsBchno = item.BgBchno
  2411. // struct3507_2.InvDataType = "2"
  2412. //
  2413. // //result11, result22, _ := service.FJyb3507(struct3507_2)
  2414. // //saveLog(result11, result22, "3507", "3507")
  2415. // //var respJSON3 map[string]interface{}
  2416. // //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2417. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2418. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2419. // // return
  2420. // //}
  2421. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  2422. // //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2423. // // utils.ErrorLog("解析失败:%v", err)
  2424. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2425. // // return
  2426. // //}
  2427. //
  2428. // if miConfig.MdtrtareaAdmvs == "350500" {
  2429. // result11, result22, _ := service.FJyb3507(struct3507_2)
  2430. // saveLog(result11, result22, "3507", "3507")
  2431. //
  2432. // var respJSON3 map[string]interface{}
  2433. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2434. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2435. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2436. // return
  2437. // }
  2438. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2439. // if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2440. // utils.ErrorLog("解析失败:%v", err)
  2441. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2442. // return
  2443. // }
  2444. // } else {
  2445. //
  2446. // data := make(map[string]interface{})
  2447. // data["struct_3507s"] = struct3507_2
  2448. // client := &http.Client{}
  2449. // bytesData, _ := json.Marshal(data)
  2450. // var req *http.Request
  2451. // if miConfig.MdtrtareaAdmvs == "320921" {
  2452. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2453. // } else {
  2454. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2455. // }
  2456. //
  2457. // resp, _ := client.Do(req)
  2458. // defer resp.Body.Close()
  2459. // body, ioErr := ioutil.ReadAll(resp.Body)
  2460. // if ioErr != nil {
  2461. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2462. // }
  2463. // var respJSON map[string]interface{}
  2464. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2465. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2466. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2467. // return
  2468. // }
  2469. // var resSix10265 ResultSix10265 //1101结果
  2470. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2471. // result, _ := json.Marshal(respJSON)
  2472. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2473. // utils.ErrorLog("解析失败:%v", err)
  2474. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2475. // return
  2476. // }
  2477. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2478. // //res.Output = resSix10265.Output
  2479. // res2.ErrMsg = resSix10265.ErrMsg
  2480. // res2.Cainfo = resSix10265.Cainfo
  2481. // res2.WarnMsg = resSix10265.WarnMsg
  2482. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2483. // res2.Infcode = infocode
  2484. // }
  2485. // if res2.Infcode == 0 {
  2486. // item.IsChange = 0
  2487. // item.BgBchno = ""
  2488. // service.SaveDF2(item)
  2489. // } else {
  2490. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2491. // }
  2492. // }
  2493. // } else {
  2494. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2495. // }
  2496. //
  2497. // }
  2498. // if item.IsSale == 1 && item.IsChange == 0 {
  2499. //
  2500. // var res FJ3507Result
  2501. // var struct3507 models.Struct3507
  2502. // struct3507.FixmedinsBchno = item.Bchno
  2503. // struct3507.InvDataType = "4"
  2504. // struct3507.Opter = roles.UserName
  2505. // struct3507.FixmedinsCode = miConfig.Code
  2506. // struct3507.Code = miConfig.Code
  2507. //
  2508. // struct3507.OrgName = miConfig.OrgName
  2509. // struct3507.AccessKey = miConfig.AccessKey
  2510. // struct3507.RequestUrl = miConfig.Url
  2511. // struct3507.SecretKey = miConfig.SecretKey
  2512. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2513. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2514. // struct3507.Url = miConfig.Url
  2515. // struct3507.AppId = miConfig.Cainfo
  2516. // struct3507.AppSecret = miConfig.AppSecret
  2517. // struct3507.Enckey = miConfig.EncKey
  2518. // struct3507.SignKey = miConfig.SignKey
  2519. // struct3507.SecretKey = miConfig.SecretKey
  2520. // //result, result1, _ := service.FJyb3507(struct3507)
  2521. // //saveLog(result, result1, "3507", "3507")
  2522. // //
  2523. // //var respJSON3 map[string]interface{}
  2524. // //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2525. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2526. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2527. // // return
  2528. // //}
  2529. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  2530. // //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2531. // // utils.ErrorLog("解析失败:%v", err)
  2532. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2533. // // return
  2534. // //}
  2535. // if miConfig.MdtrtareaAdmvs == "350500" {
  2536. // result, result1, _ := service.FJyb3507(struct3507)
  2537. // saveLog(result, result1, "3507", "3507")
  2538. // var respJSON2 map[string]interface{}
  2539. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2540. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2541. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2542. // return
  2543. // }
  2544. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2545. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2546. // utils.ErrorLog("解析失败:%v", err)
  2547. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2548. // return
  2549. // }
  2550. // } else {
  2551. // data := make(map[string]interface{})
  2552. // data["struct_3507s"] = struct3507
  2553. // client := &http.Client{}
  2554. // bytesData, _ := json.Marshal(data)
  2555. // var req *http.Request
  2556. // if miConfig.MdtrtareaAdmvs == "320921" {
  2557. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2558. // } else {
  2559. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2560. // }
  2561. //
  2562. // resp, _ := client.Do(req)
  2563. // defer resp.Body.Close()
  2564. // body, ioErr := ioutil.ReadAll(resp.Body)
  2565. // if ioErr != nil {
  2566. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2567. // }
  2568. // var respJSON map[string]interface{}
  2569. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2570. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2571. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2572. // return
  2573. // }
  2574. // var resSix10265 ResultSix10265 //1101结果
  2575. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2576. // result, _ := json.Marshal(respJSON)
  2577. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2578. // utils.ErrorLog("解析失败:%v", err)
  2579. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2580. // return
  2581. // }
  2582. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2583. // //res.Output = resSix10265.Output
  2584. // res.ErrMsg = resSix10265.ErrMsg
  2585. // res.Cainfo = resSix10265.Cainfo
  2586. // res.WarnMsg = resSix10265.WarnMsg
  2587. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2588. // res.Infcode = infocode
  2589. // }
  2590. //
  2591. // if res.Infcode == 0 {
  2592. // item.IsSale = 0
  2593. // item.SaleDate = ""
  2594. // service.SaveDF(item)
  2595. // } else {
  2596. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2597. // }
  2598. // }
  2599. // if item.IsSale == 2 && item.IsChange == 0 {
  2600. //
  2601. // var res FJ3507Result
  2602. // var struct3507 models.Struct3507
  2603. // struct3507.FixmedinsBchno = item.Bchno
  2604. // struct3507.InvDataType = "4"
  2605. // struct3507.Opter = roles.UserName
  2606. // struct3507.FixmedinsCode = miConfig.Code
  2607. // struct3507.Code = miConfig.Code
  2608. //
  2609. // struct3507.OrgName = miConfig.OrgName
  2610. // struct3507.AccessKey = miConfig.AccessKey
  2611. // struct3507.RequestUrl = miConfig.Url
  2612. // struct3507.SecretKey = miConfig.SecretKey
  2613. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2614. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2615. // struct3507.Url = miConfig.Url
  2616. // struct3507.AppId = miConfig.Cainfo
  2617. // struct3507.AppSecret = miConfig.AppSecret
  2618. // struct3507.Enckey = miConfig.EncKey
  2619. // struct3507.SignKey = miConfig.SignKey
  2620. // struct3507.SecretKey = miConfig.SecretKey
  2621. // //result, result1, _ := service.FJyb3507(struct3507)
  2622. // //saveLog(result, result1, "3507", "3507")
  2623. // //
  2624. // //var respJSON3 map[string]interface{}
  2625. // //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2626. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2627. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2628. // // return
  2629. // //}
  2630. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  2631. // //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2632. // // utils.ErrorLog("解析失败:%v", err)
  2633. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2634. // // return
  2635. // //}
  2636. // if miConfig.MdtrtareaAdmvs == "350500" {
  2637. // result, result1, _ := service.FJyb3507(struct3507)
  2638. // saveLog(result, result1, "3507", "3507")
  2639. // var respJSON2 map[string]interface{}
  2640. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2641. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2642. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2643. // return
  2644. // }
  2645. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2646. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2647. // utils.ErrorLog("解析失败:%v", err)
  2648. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2649. // return
  2650. // }
  2651. // } else {
  2652. // data := make(map[string]interface{})
  2653. // data["struct_3507s"] = struct3507
  2654. // client := &http.Client{}
  2655. // bytesData, _ := json.Marshal(data)
  2656. // var req *http.Request
  2657. // if miConfig.MdtrtareaAdmvs == "320921" {
  2658. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2659. // } else {
  2660. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2661. // }
  2662. //
  2663. // resp, _ := client.Do(req)
  2664. // defer resp.Body.Close()
  2665. // body, ioErr := ioutil.ReadAll(resp.Body)
  2666. // if ioErr != nil {
  2667. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2668. // }
  2669. // var respJSON map[string]interface{}
  2670. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2671. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2672. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2673. // return
  2674. // }
  2675. // var resSix10265 ResultSix10265 //1101结果
  2676. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2677. // result, _ := json.Marshal(respJSON)
  2678. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2679. // utils.ErrorLog("解析失败:%v", err)
  2680. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2681. // return
  2682. // }
  2683. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2684. // //res.Output = resSix10265.Output
  2685. // res.ErrMsg = resSix10265.ErrMsg
  2686. // res.Cainfo = resSix10265.Cainfo
  2687. // res.WarnMsg = resSix10265.WarnMsg
  2688. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2689. // res.Infcode = infocode
  2690. // }
  2691. //
  2692. // if res.Infcode == 0 {
  2693. // item.IsSale = 0
  2694. // item.SaleDate = ""
  2695. // item.Bchno = ""
  2696. //
  2697. // service.SaveDF(item)
  2698. // } else {
  2699. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2700. // }
  2701. // }
  2702. // if item.IsSale == 0 && item.IsChange == 1 {
  2703. //
  2704. // var res FJ3507Result
  2705. // var struct3507 models.Struct3507
  2706. // struct3507.FixmedinsBchno = item.BgBchno
  2707. // struct3507.InvDataType = "2"
  2708. // struct3507.Opter = roles.UserName
  2709. // struct3507.FixmedinsCode = miConfig.Code
  2710. // struct3507.Code = miConfig.Code
  2711. //
  2712. // struct3507.OrgName = miConfig.OrgName
  2713. // struct3507.AccessKey = miConfig.AccessKey
  2714. // struct3507.RequestUrl = miConfig.Url
  2715. // struct3507.SecretKey = miConfig.SecretKey
  2716. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2717. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2718. // struct3507.Url = miConfig.Url
  2719. // struct3507.AppId = miConfig.Cainfo
  2720. // struct3507.AppSecret = miConfig.AppSecret
  2721. // struct3507.Enckey = miConfig.EncKey
  2722. // struct3507.SignKey = miConfig.SignKey
  2723. // struct3507.SecretKey = miConfig.SecretKey
  2724. // //result, result1, _ := service.FJyb3507(struct3507)
  2725. // //saveLog(result, result1, "3507", "3507")
  2726. // //
  2727. // //var respJSON3 map[string]interface{}
  2728. // //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2729. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2730. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2731. // // return
  2732. // //}
  2733. // //userJSONBytes3, _ := json.Marshal(respJSON3)
  2734. // //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2735. // // utils.ErrorLog("解析失败:%v", err)
  2736. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2737. // // return
  2738. // //}
  2739. // if miConfig.MdtrtareaAdmvs == "350500" {
  2740. // result, result1, _ := service.FJyb3507(struct3507)
  2741. // saveLog(result, result1, "3507", "3507")
  2742. // var respJSON2 map[string]interface{}
  2743. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2744. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2745. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2746. // return
  2747. // }
  2748. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2749. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2750. // utils.ErrorLog("解析失败:%v", err)
  2751. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2752. // return
  2753. // }
  2754. // } else {
  2755. // data := make(map[string]interface{})
  2756. // data["struct_3507s"] = struct3507
  2757. // client := &http.Client{}
  2758. // bytesData, _ := json.Marshal(data)
  2759. // var req *http.Request
  2760. // if miConfig.MdtrtareaAdmvs == "320921" {
  2761. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2762. // } else {
  2763. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2764. // }
  2765. //
  2766. // resp, _ := client.Do(req)
  2767. // defer resp.Body.Close()
  2768. // body, ioErr := ioutil.ReadAll(resp.Body)
  2769. // if ioErr != nil {
  2770. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2771. // }
  2772. // var respJSON map[string]interface{}
  2773. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2774. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2775. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2776. // return
  2777. // }
  2778. // var resSix10265 ResultSix10265 //1101结果
  2779. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2780. // result, _ := json.Marshal(respJSON)
  2781. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2782. // utils.ErrorLog("解析失败:%v", err)
  2783. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2784. // return
  2785. // }
  2786. // res.InfRefmsgid = resSix10265.InfRefmsgid
  2787. // //res.Output = resSix10265.Output
  2788. // res.ErrMsg = resSix10265.ErrMsg
  2789. // res.Cainfo = resSix10265.Cainfo
  2790. // res.WarnMsg = resSix10265.WarnMsg
  2791. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2792. // res.Infcode = infocode
  2793. // }
  2794. //
  2795. // if res.Infcode == 0 {
  2796. // item.IsChange = 0
  2797. // item.BgBchno = ""
  2798. // service.SaveDF2(item)
  2799. // } else {
  2800. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2801. // }
  2802. // }
  2803. // }
  2804. // if len(err) == 0 {
  2805. // c.ServeSuccessJSON(map[string]interface{}{
  2806. // "msg": "删除销售变更成功",
  2807. // })
  2808. //
  2809. // } else {
  2810. // c.ServeSuccessJSON(map[string]interface{}{
  2811. // "failed_code": -10,
  2812. // "msg": err,
  2813. // })
  2814. //
  2815. // }
  2816. //
  2817. //}
  2818. // 获取当天起止时间戳
  2819. func GetNowTime() (int64, int64) {
  2820. t := time.Now()
  2821. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  2822. timesamp := addTime.Unix()
  2823. return timesamp, timesamp + 86399
  2824. }
  2825. //func (c *HisApiController) ChangeDrugfour() {
  2826. // patient_id, _ := c.GetInt64("patient_id")
  2827. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2828. // //id_arr := strings.Split(ids, ",")
  2829. // times := c.GetString("time", "")
  2830. // timeLayout := "2006-01-02"
  2831. // loc, _ := time.LoadLocation("Local")
  2832. // var stime, etime int64
  2833. // if times == "" {
  2834. // stime, etime = GetNowTime()
  2835. // } else {
  2836. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2837. // stime = stmp.Unix()
  2838. // etime = stime + 86399
  2839. // }
  2840. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2841. // var flows []*models.DrugFlow
  2842. // for _, item := range advicelist {
  2843. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.ID, times, c.GetAdminUserInfo().CurrentOrgId)
  2844. // flows = append(flows, flow...)
  2845. // }
  2846. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2847. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2848. // var err []string
  2849. //
  2850. // for _, item := range flows {
  2851. // var res3 ResultSix
  2852. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  2853. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  2854. // if prescription.OrderStatus == 2 {
  2855. // //已经结算
  2856. // //判断是否已经销售
  2857. // if item.IsSale == 1 { //是否已经销售,1是 0否
  2858. // //是否已经变更 1是 0否
  2859. // if item.IsChange == 0 { //没变更,进行变更操作
  2860. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2861. //
  2862. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  2863. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  2864. // var respJSON3 map[string]interface{}
  2865. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2866. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2867. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2868. // return
  2869. // }
  2870. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2871. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2872. // utils.ErrorLog("解析失败:%v", err)
  2873. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2874. // return
  2875. // }
  2876. // if res3.Infcode == 0 {
  2877. // item.IsChange = 1
  2878. // item.BgBchno = bg_number
  2879. // service.SaveDF2(item)
  2880. // } else {
  2881. //
  2882. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2883. // }
  2884. // }
  2885. // } else { //没销售,
  2886. // var res FJ3507Result
  2887. // var res3507for10188 FJ3507ResultFor10188
  2888. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  2889. //
  2890. // //进行商品销售接口
  2891. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  2892. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  2893. // var respJSON3 map[string]interface{}
  2894. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  2895. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2896. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2897. // return
  2898. // }
  2899. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2900. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2901. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2902. // utils.ErrorLog("解析失败:%v", err)
  2903. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2904. // return
  2905. // }
  2906. // //if res3507for10188.Infcode
  2907. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  2908. // //res.Output = resSix10265.Output
  2909. // res.ErrMsg = res3507for10188.ErrMsg
  2910. // res.Cainfo = res3507for10188.Cainfo
  2911. // res.WarnMsg = res3507for10188.WarnMsg
  2912. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2913. // res.Infcode = infocode
  2914. // } else {
  2915. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2916. // utils.ErrorLog("解析失败:%v", err)
  2917. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2918. // return
  2919. // }
  2920. //
  2921. // }
  2922. // if res.Infcode == 0 {
  2923. // item.IsSale = 1
  2924. // item.Bchno = number
  2925. // item.SaleDate = time.Now().Format("2006-01-02")
  2926. //
  2927. // err5 := service.SaveDF(item)
  2928. // if err5 == nil {
  2929. // if item.IsChange == 0 { //没变更,进行变更操作
  2930. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  2931. //
  2932. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  2933. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  2934. //
  2935. // var respJSON3 map[string]interface{}
  2936. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2937. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2938. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2939. // return
  2940. // }
  2941. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  2942. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  2943. // utils.ErrorLog("解析失败:%v", err)
  2944. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2945. // return
  2946. // }
  2947. // //if res3507for10188.Infcode
  2948. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  2949. // //res.Output = resSix10265.Output
  2950. // res3.ErrMsg = res3507for10188.ErrMsg
  2951. // res3.Cainfo = res3507for10188.Cainfo
  2952. // res3.WarnMsg = res3507for10188.WarnMsg
  2953. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  2954. // res3.Infcode = infocode
  2955. // } else {
  2956. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2957. // utils.ErrorLog("解析失败:%v", err)
  2958. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2959. // return
  2960. // }
  2961. // }
  2962. // if res3.Infcode == 0 {
  2963. // item.IsChange = 1
  2964. // item.BgBchno = bg_number
  2965. // service.SaveDF2(item)
  2966. // } else {
  2967. //
  2968. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  2969. // }
  2970. // }
  2971. // }
  2972. // } else {
  2973. //
  2974. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  2975. // }
  2976. // }
  2977. //
  2978. // } else { //还没结,提示用户去结算,并药品追溯上传
  2979. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  2980. // }
  2981. // }
  2982. // }
  2983. // if len(err) == 0 {
  2984. // c.ServeSuccessJSON(map[string]interface{}{
  2985. // "msg": "销售变更成功",
  2986. // })
  2987. // } else {
  2988. // c.ServeSuccessJSON(map[string]interface{}{
  2989. // "failed_code": -10,
  2990. // "msg": err,
  2991. // })
  2992. // }
  2993. //}
  2994. //func (c *HisApiController) ChangeDrugfour() {
  2995. // patient_id, _ := c.GetInt64("patient_id")
  2996. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2997. // //id_arr := strings.Split(ids, ",")
  2998. // times := c.GetString("time", "")
  2999. // timeLayout := "2006-01-02"
  3000. // loc, _ := time.LoadLocation("Local")
  3001. // var stime, etime int64
  3002. // if times == "" {
  3003. // stime, etime = GetNowTime()
  3004. // } else {
  3005. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3006. // stime = stmp.Unix()
  3007. // etime = stime + 86399
  3008. // }
  3009. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3010. // var flows []*models.DrugFlow
  3011. // for _, item := range advicelist {
  3012. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3013. // flows = append(flows, flow...)
  3014. // }
  3015. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3016. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3017. // var err []string
  3018. //
  3019. // for _, item := range flows {
  3020. // var res3 ResultSix
  3021. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3022. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3023. // if prescription.OrderStatus == 2 {
  3024. // //已经结算
  3025. // //判断是否已经销售
  3026. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3027. // //是否已经变更 1是 0否
  3028. // if item.IsChange == 0 { //没变更,进行变更操作
  3029. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3030. //
  3031. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3032. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3033. // var respJSON3 map[string]interface{}
  3034. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3035. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3036. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3037. // return
  3038. // }
  3039. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3040. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3041. // utils.ErrorLog("解析失败:%v", err)
  3042. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3043. // return
  3044. // }
  3045. // if res3.Infcode == 0 {
  3046. // item.IsChange = 1
  3047. // item.BgBchno = bg_number
  3048. // service.SaveDF2(item)
  3049. // } else {
  3050. //
  3051. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3052. // }
  3053. // }
  3054. // } else { //没销售,
  3055. // var res FJ3507Result
  3056. // var res3507for10188 FJ3507ResultFor10188
  3057. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3058. //
  3059. // //进行商品销售接口
  3060. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3061. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3062. // var respJSON3 map[string]interface{}
  3063. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3064. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3065. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3066. // return
  3067. // }
  3068. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3069. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3070. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3071. // utils.ErrorLog("解析失败:%v", err)
  3072. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3073. // return
  3074. // }
  3075. // //if res3507for10188.Infcode
  3076. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3077. // //res.Output = resSix10265.Output
  3078. // res.ErrMsg = res3507for10188.ErrMsg
  3079. // res.Cainfo = res3507for10188.Cainfo
  3080. // res.WarnMsg = res3507for10188.WarnMsg
  3081. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3082. // res.Infcode = infocode
  3083. // } else {
  3084. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3085. // utils.ErrorLog("解析失败:%v", err)
  3086. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3087. // return
  3088. // }
  3089. //
  3090. // }
  3091. // if res.Infcode == 0 {
  3092. // item.IsSale = 1
  3093. // item.Bchno = number
  3094. // item.SaleDate = time.Now().Format("2006-01-02")
  3095. //
  3096. // err5 := service.SaveDF(item)
  3097. // if err5 == nil {
  3098. // if item.IsChange == 0 { //没变更,进行变更操作
  3099. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3100. //
  3101. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3102. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3103. //
  3104. // var respJSON3 map[string]interface{}
  3105. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3106. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3107. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3108. // return
  3109. // }
  3110. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3111. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3112. // utils.ErrorLog("解析失败:%v", err)
  3113. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3114. // return
  3115. // }
  3116. // //if res3507for10188.Infcode
  3117. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3118. // //res.Output = resSix10265.Output
  3119. // res3.ErrMsg = res3507for10188.ErrMsg
  3120. // res3.Cainfo = res3507for10188.Cainfo
  3121. // res3.WarnMsg = res3507for10188.WarnMsg
  3122. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3123. // res3.Infcode = infocode
  3124. // } else {
  3125. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3126. // utils.ErrorLog("解析失败:%v", err)
  3127. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3128. // return
  3129. // }
  3130. // }
  3131. // if res3.Infcode == 0 {
  3132. // item.IsChange = 1
  3133. // item.BgBchno = bg_number
  3134. // service.SaveDF2(item)
  3135. // } else {
  3136. //
  3137. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3138. // }
  3139. // }
  3140. // }
  3141. // } else {
  3142. //
  3143. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3144. // }
  3145. // }
  3146. //
  3147. // } else { //还没结,提示用户去结算,并药品追溯上传
  3148. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3149. // }
  3150. // }
  3151. // }
  3152. // if len(err) == 0 {
  3153. // c.ServeSuccessJSON(map[string]interface{}{
  3154. // "msg": "销售变更成功",
  3155. // })
  3156. // } else {
  3157. // c.ServeSuccessJSON(map[string]interface{}{
  3158. // "failed_code": -10,
  3159. // "msg": err,
  3160. // })
  3161. // }
  3162. //}
  3163. func (c *HisApiController) ChangeDrug() {
  3164. ids := c.GetString("ids")
  3165. id_arr := strings.Split(ids, ",")
  3166. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3167. admin_user_id, _ := c.GetInt64("admin_user_id")
  3168. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3169. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3170. var err []string
  3171. for _, item := range flows {
  3172. var res3 ResultSix
  3173. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3174. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3175. if prescription.OrderStatus == 2 {
  3176. //已经结算
  3177. //判断是否已经销售
  3178. if item.IsSale == 1 { //是否已经销售,1是 0否
  3179. //是否已经变更 1是 0否
  3180. if item.IsChange == 0 { //没变更,进行变更操作
  3181. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3182. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3183. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3184. var respJSON3 map[string]interface{}
  3185. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3186. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3188. return
  3189. }
  3190. userJSONBytes3, _ := json.Marshal(respJSON3)
  3191. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3192. utils.ErrorLog("解析失败:%v", err)
  3193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3194. return
  3195. }
  3196. if res3.Infcode == 0 {
  3197. item.IsChange = 1
  3198. item.BgBchno = bg_number
  3199. service.SaveDF2(item)
  3200. } else {
  3201. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3202. }
  3203. }
  3204. } else { //没销售,
  3205. var res FJ3507Result
  3206. var res3507for10188 FJ3507ResultFor10188
  3207. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3208. //进行商品销售接口
  3209. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3210. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3211. var respJSON3 map[string]interface{}
  3212. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3213. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3215. return
  3216. }
  3217. userJSONBytes3, _ := json.Marshal(respJSON3)
  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. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3226. //res.Output = resSix10265.Output
  3227. res.ErrMsg = res3507for10188.ErrMsg
  3228. res.Cainfo = res3507for10188.Cainfo
  3229. res.WarnMsg = res3507for10188.WarnMsg
  3230. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3231. res.Infcode = infocode
  3232. } else {
  3233. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3234. utils.ErrorLog("解析失败:%v", err)
  3235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3236. return
  3237. }
  3238. }
  3239. if res.Infcode == 0 {
  3240. item.IsSale = 1
  3241. item.Bchno = number
  3242. item.SaleDate = time.Now().Format("2006-01-02")
  3243. err5 := service.SaveDF(item)
  3244. if err5 == nil {
  3245. if item.IsChange == 0 { //没变更,进行变更操作
  3246. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3247. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3248. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3249. var respJSON3 map[string]interface{}
  3250. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3251. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3253. return
  3254. }
  3255. userJSONBytes3, _ := json.Marshal(respJSON3)
  3256. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3257. utils.ErrorLog("解析失败:%v", err)
  3258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3259. return
  3260. }
  3261. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3262. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3263. utils.ErrorLog("解析失败:%v", err)
  3264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3265. return
  3266. }
  3267. //if res3507for10188.Infcode
  3268. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3269. //res.Output = resSix10265.Output
  3270. res3.ErrMsg = res3507for10188.ErrMsg
  3271. res3.Cainfo = res3507for10188.Cainfo
  3272. res3.WarnMsg = res3507for10188.WarnMsg
  3273. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3274. res3.Infcode = infocode
  3275. } else {
  3276. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3277. utils.ErrorLog("解析失败:%v", err)
  3278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3279. return
  3280. }
  3281. }
  3282. if res3.Infcode == 0 {
  3283. item.IsChange = 1
  3284. item.BgBchno = bg_number
  3285. service.SaveDF2(item)
  3286. } else {
  3287. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3288. }
  3289. }
  3290. }
  3291. } else {
  3292. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3293. }
  3294. }
  3295. } else { //还没结算
  3296. var res3507for10188 FJ3507ResultFor10188
  3297. if item.IsChange == 0 { //没变更,进行变更操作
  3298. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3299. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3300. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3301. var respJSON3 map[string]interface{}
  3302. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3305. return
  3306. }
  3307. userJSONBytes3, _ := json.Marshal(respJSON3)
  3308. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3309. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3310. utils.ErrorLog("解析失败:%v", err)
  3311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3312. return
  3313. }
  3314. //if res3507for10188.Infcode
  3315. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3316. //res.Output = resSix10265.Output
  3317. res3.ErrMsg = res3507for10188.ErrMsg
  3318. res3.Cainfo = res3507for10188.Cainfo
  3319. res3.WarnMsg = res3507for10188.WarnMsg
  3320. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3321. res3.Infcode = infocode
  3322. } else {
  3323. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3324. utils.ErrorLog("解析失败:%v", err)
  3325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3326. return
  3327. }
  3328. }
  3329. if res3.Infcode == 0 {
  3330. item.IsChange = 1
  3331. item.BgBchno = bg_number
  3332. service.SaveDF2(item)
  3333. } else {
  3334. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3335. }
  3336. }
  3337. }
  3338. } else if item.ConsumableType == 7 {
  3339. var res3507for10188 FJ3507ResultFor10188
  3340. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3341. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3342. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3343. //判断是否已经销售
  3344. if item.IsSale == 2 { //是否已经销售,1是 0否
  3345. //是否已经变更 1是 0否
  3346. if item.IsChange == 0 { //没变更,进行变更操作
  3347. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3348. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3349. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3350. var respJSON3 map[string]interface{}
  3351. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3352. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3354. return
  3355. }
  3356. userJSONBytes3, _ := json.Marshal(respJSON3)
  3357. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3358. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3359. utils.ErrorLog("解析失败:%v", err)
  3360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3361. return
  3362. }
  3363. //if res3507for10188.Infcode
  3364. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3365. //res.Output = resSix10265.Output
  3366. res3.ErrMsg = res3507for10188.ErrMsg
  3367. res3.Cainfo = res3507for10188.Cainfo
  3368. res3.WarnMsg = res3507for10188.WarnMsg
  3369. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3370. res3.Infcode = infocode
  3371. } else {
  3372. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3373. utils.ErrorLog("解析失败:%v", err)
  3374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3375. return
  3376. }
  3377. }
  3378. if res3.Infcode == 0 {
  3379. item.IsChange = 1
  3380. item.BgBchno = bg_number
  3381. service.SaveDF2(item)
  3382. } else {
  3383. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3384. }
  3385. }
  3386. } else { //没销售,
  3387. //进行商品销售退货接口
  3388. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3389. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3390. saveLog(result111, result222, "3506", "销售退货")
  3391. var res7 FJ3507Result
  3392. //进行商品销售接口
  3393. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3394. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3395. var respJSON3 map[string]interface{}
  3396. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3397. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3399. return
  3400. }
  3401. userJSONBytes3, _ := json.Marshal(respJSON3)
  3402. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3403. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3404. utils.ErrorLog("解析失败:%v", err)
  3405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3406. return
  3407. }
  3408. //if res3507for10188.Infcode
  3409. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3410. //res.Output = resSix10265.Output
  3411. res7.ErrMsg = res3507for10188.ErrMsg
  3412. res7.Cainfo = res3507for10188.Cainfo
  3413. res7.WarnMsg = res3507for10188.WarnMsg
  3414. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3415. res7.Infcode = infocode
  3416. } else {
  3417. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3418. utils.ErrorLog("解析失败:%v", err)
  3419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3420. return
  3421. }
  3422. }
  3423. if res7.Infcode == 0 {
  3424. item.IsSale = 2
  3425. item.SaleDate = item.SaleDate
  3426. item.Bchno = number
  3427. service.SaveDF(item)
  3428. if item.IsChange == 0 { //没变更,进行变更操作
  3429. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3430. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3431. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3432. var respJSON3 map[string]interface{}
  3433. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3434. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3436. return
  3437. }
  3438. userJSONBytes3, _ := json.Marshal(respJSON3)
  3439. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3440. // utils.ErrorLog("解析失败:%v", err)
  3441. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3442. // return
  3443. //}
  3444. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3445. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3446. utils.ErrorLog("解析失败:%v", err)
  3447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3448. return
  3449. }
  3450. //if res3507for10188.Infcode
  3451. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3452. //res.Output = resSix10265.Output
  3453. res3.ErrMsg = res3507for10188.ErrMsg
  3454. res3.Cainfo = res3507for10188.Cainfo
  3455. res3.WarnMsg = res3507for10188.WarnMsg
  3456. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3457. res3.Infcode = infocode
  3458. } else {
  3459. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3460. utils.ErrorLog("解析失败:%v", err)
  3461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3462. return
  3463. }
  3464. }
  3465. if res3.Infcode == 0 {
  3466. item.IsChange = 1
  3467. item.BgBchno = bg_number
  3468. service.SaveDF2(item)
  3469. } else {
  3470. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3471. }
  3472. }
  3473. } else {
  3474. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3475. }
  3476. }
  3477. } else { //还没结算
  3478. if item.IsChange == 0 { //没变更,进行变更操作
  3479. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3480. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3481. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3482. var respJSON3 map[string]interface{}
  3483. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3484. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3486. return
  3487. }
  3488. userJSONBytes3, _ := json.Marshal(respJSON3)
  3489. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3490. // utils.ErrorLog("解析失败:%v", err)
  3491. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3492. // return
  3493. //}
  3494. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3495. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3496. utils.ErrorLog("解析失败:%v", err)
  3497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3498. return
  3499. }
  3500. //if res3507for10188.Infcode
  3501. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3502. //res.Output = resSix10265.Output
  3503. res3.ErrMsg = res3507for10188.ErrMsg
  3504. res3.Cainfo = res3507for10188.Cainfo
  3505. res3.WarnMsg = res3507for10188.WarnMsg
  3506. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3507. res3.Infcode = infocode
  3508. } else {
  3509. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3510. utils.ErrorLog("解析失败:%v", err)
  3511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3512. return
  3513. }
  3514. }
  3515. if res3.Infcode == 0 {
  3516. item.IsChange = 1
  3517. item.BgBchno = bg_number
  3518. service.SaveDF2(item)
  3519. } else {
  3520. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3521. }
  3522. }
  3523. }
  3524. }
  3525. }
  3526. if len(err) == 0 {
  3527. c.ServeSuccessJSON(map[string]interface{}{
  3528. "msg": "销售变更成功",
  3529. })
  3530. } else {
  3531. c.ServeSuccessJSON(map[string]interface{}{
  3532. "failed_code": -10,
  3533. "msg": err,
  3534. })
  3535. }
  3536. }
  3537. func (c *HisApiController) ChangeDrugtwo() {
  3538. //ids := c.GetString("ids")
  3539. //id_arr := strings.Split(ids, ",")
  3540. flows, _ := service.GetNewDrugFlowInfotwo()
  3541. admin_user_id, _ := c.GetInt64("admin_user_id")
  3542. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3543. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3544. var err []string
  3545. for _, item := range flows {
  3546. var res3 ResultSix
  3547. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3548. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3549. if prescription.OrderStatus == 2 {
  3550. //已经结算
  3551. //判断是否已经销售
  3552. if item.IsSale == 1 { //是否已经销售,1是 0否
  3553. //是否已经变更 1是 0否
  3554. if item.IsChange == 0 { //没变更,进行变更操作
  3555. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3556. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3557. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3558. var respJSON3 map[string]interface{}
  3559. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3560. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3562. return
  3563. }
  3564. userJSONBytes3, _ := json.Marshal(respJSON3)
  3565. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3566. utils.ErrorLog("解析失败:%v", err)
  3567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3568. return
  3569. }
  3570. if res3.Infcode == 0 {
  3571. item.IsChange = 1
  3572. item.BgBchno = bg_number
  3573. service.SaveDF2(item)
  3574. } else {
  3575. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3576. }
  3577. }
  3578. } else { //没销售,
  3579. var res FJ3507Result
  3580. var res3507for10188 FJ3507ResultFor10188
  3581. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3582. //进行商品销售接口
  3583. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3584. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3585. var respJSON3 map[string]interface{}
  3586. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3587. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3589. return
  3590. }
  3591. userJSONBytes3, _ := json.Marshal(respJSON3)
  3592. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3593. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3594. utils.ErrorLog("解析失败:%v", err)
  3595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3596. return
  3597. }
  3598. //if res3507for10188.Infcode
  3599. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3600. //res.Output = resSix10265.Output
  3601. res.ErrMsg = res3507for10188.ErrMsg
  3602. res.Cainfo = res3507for10188.Cainfo
  3603. res.WarnMsg = res3507for10188.WarnMsg
  3604. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3605. res.Infcode = infocode
  3606. } else {
  3607. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3608. utils.ErrorLog("解析失败:%v", err)
  3609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3610. return
  3611. }
  3612. }
  3613. if res.Infcode == 0 {
  3614. item.IsSale = 1
  3615. item.Bchno = number
  3616. item.SaleDate = time.Now().Format("2006-01-02")
  3617. err5 := service.SaveDF(item)
  3618. if err5 == nil {
  3619. if item.IsChange == 0 { //没变更,进行变更操作
  3620. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3621. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3622. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3623. var respJSON3 map[string]interface{}
  3624. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3625. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3627. return
  3628. }
  3629. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3630. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3631. utils.ErrorLog("解析失败:%v", err)
  3632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3633. return
  3634. }
  3635. //if res3507for10188.Infcode
  3636. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3637. //res.Output = resSix10265.Output
  3638. res3.ErrMsg = res3507for10188.ErrMsg
  3639. res3.Cainfo = res3507for10188.Cainfo
  3640. res3.WarnMsg = res3507for10188.WarnMsg
  3641. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3642. res3.Infcode = infocode
  3643. } else {
  3644. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3645. utils.ErrorLog("解析失败:%v", err)
  3646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3647. return
  3648. }
  3649. }
  3650. if res3.Infcode == 0 {
  3651. item.IsChange = 1
  3652. item.BgBchno = bg_number
  3653. service.SaveDF2(item)
  3654. } else {
  3655. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3656. }
  3657. }
  3658. }
  3659. } else {
  3660. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3661. }
  3662. }
  3663. } else { //还没结算
  3664. var res3507for10188 FJ3507ResultFor10188
  3665. if item.IsChange == 0 { //没变更,进行变更操作
  3666. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3667. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3668. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3669. var respJSON3 map[string]interface{}
  3670. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3671. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3673. return
  3674. }
  3675. userJSONBytes3, _ := json.Marshal(respJSON3)
  3676. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3677. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3678. utils.ErrorLog("解析失败:%v", err)
  3679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3680. return
  3681. }
  3682. //if res3507for10188.Infcode
  3683. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3684. //res.Output = resSix10265.Output
  3685. res3.ErrMsg = res3507for10188.ErrMsg
  3686. res3.Cainfo = res3507for10188.Cainfo
  3687. res3.WarnMsg = res3507for10188.WarnMsg
  3688. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3689. res3.Infcode = infocode
  3690. } else {
  3691. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3692. utils.ErrorLog("解析失败:%v", err)
  3693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3694. return
  3695. }
  3696. }
  3697. if res3.Infcode == 0 {
  3698. item.IsChange = 1
  3699. item.BgBchno = bg_number
  3700. service.SaveDF2(item)
  3701. } else {
  3702. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3703. }
  3704. }
  3705. }
  3706. } else if item.ConsumableType == 7 {
  3707. var res3507for10188 FJ3507ResultFor10188
  3708. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3709. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3710. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3711. //判断是否已经销售
  3712. if item.IsSale == 2 { //是否已经销售,1是 0否
  3713. //是否已经变更 1是 0否
  3714. if item.IsChange == 0 { //没变更,进行变更操作
  3715. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3716. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3717. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3718. var respJSON3 map[string]interface{}
  3719. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3722. return
  3723. }
  3724. userJSONBytes3, _ := json.Marshal(respJSON3)
  3725. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3726. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3727. utils.ErrorLog("解析失败:%v", err)
  3728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3729. return
  3730. }
  3731. //if res3507for10188.Infcode
  3732. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3733. //res.Output = resSix10265.Output
  3734. res3.ErrMsg = res3507for10188.ErrMsg
  3735. res3.Cainfo = res3507for10188.Cainfo
  3736. res3.WarnMsg = res3507for10188.WarnMsg
  3737. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3738. res3.Infcode = infocode
  3739. } else {
  3740. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3741. utils.ErrorLog("解析失败:%v", err)
  3742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3743. return
  3744. }
  3745. }
  3746. if res3.Infcode == 0 {
  3747. item.IsChange = 1
  3748. item.BgBchno = bg_number
  3749. service.SaveDF2(item)
  3750. } else {
  3751. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3752. }
  3753. }
  3754. } else { //没销售,
  3755. //进行商品销售退货接口
  3756. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3757. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3758. saveLog(result111, result222, "3506", "销售退货")
  3759. var res7 FJ3507Result
  3760. //进行商品销售接口
  3761. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3762. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3763. var respJSON3 map[string]interface{}
  3764. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3765. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3767. return
  3768. }
  3769. userJSONBytes3, _ := json.Marshal(respJSON3)
  3770. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3771. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3772. utils.ErrorLog("解析失败:%v", err)
  3773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3774. return
  3775. }
  3776. //if res3507for10188.Infcode
  3777. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3778. //res.Output = resSix10265.Output
  3779. res7.ErrMsg = res3507for10188.ErrMsg
  3780. res7.Cainfo = res3507for10188.Cainfo
  3781. res7.WarnMsg = res3507for10188.WarnMsg
  3782. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3783. res7.Infcode = infocode
  3784. } else {
  3785. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3786. utils.ErrorLog("解析失败:%v", err)
  3787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3788. return
  3789. }
  3790. }
  3791. if res7.Infcode == 0 {
  3792. item.IsSale = 2
  3793. item.SaleDate = item.SaleDate
  3794. item.Bchno = number
  3795. service.SaveDF(item)
  3796. if item.IsChange == 0 { //没变更,进行变更操作
  3797. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3798. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3799. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3800. var respJSON3 map[string]interface{}
  3801. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3802. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3804. return
  3805. }
  3806. userJSONBytes3, _ := json.Marshal(respJSON3)
  3807. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3808. // utils.ErrorLog("解析失败:%v", err)
  3809. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3810. // return
  3811. //}
  3812. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3813. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3814. utils.ErrorLog("解析失败:%v", err)
  3815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3816. return
  3817. }
  3818. //if res3507for10188.Infcode
  3819. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3820. //res.Output = resSix10265.Output
  3821. res3.ErrMsg = res3507for10188.ErrMsg
  3822. res3.Cainfo = res3507for10188.Cainfo
  3823. res3.WarnMsg = res3507for10188.WarnMsg
  3824. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3825. res3.Infcode = infocode
  3826. } else {
  3827. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3828. utils.ErrorLog("解析失败:%v", err)
  3829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3830. return
  3831. }
  3832. }
  3833. if res3.Infcode == 0 {
  3834. item.IsChange = 1
  3835. item.BgBchno = bg_number
  3836. service.SaveDF2(item)
  3837. } else {
  3838. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3839. }
  3840. }
  3841. } else {
  3842. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3843. }
  3844. }
  3845. } else { //还没结算
  3846. if item.IsChange == 0 { //没变更,进行变更操作
  3847. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3848. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3849. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3850. var respJSON3 map[string]interface{}
  3851. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3852. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3854. return
  3855. }
  3856. userJSONBytes3, _ := json.Marshal(respJSON3)
  3857. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3858. // utils.ErrorLog("解析失败:%v", err)
  3859. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3860. // return
  3861. //}
  3862. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3863. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3864. utils.ErrorLog("解析失败:%v", err)
  3865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3866. return
  3867. }
  3868. //if res3507for10188.Infcode
  3869. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3870. //res.Output = resSix10265.Output
  3871. res3.ErrMsg = res3507for10188.ErrMsg
  3872. res3.Cainfo = res3507for10188.Cainfo
  3873. res3.WarnMsg = res3507for10188.WarnMsg
  3874. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3875. res3.Infcode = infocode
  3876. } else {
  3877. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3878. utils.ErrorLog("解析失败:%v", err)
  3879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3880. return
  3881. }
  3882. }
  3883. if res3.Infcode == 0 {
  3884. item.IsChange = 1
  3885. item.BgBchno = bg_number
  3886. service.SaveDF2(item)
  3887. } else {
  3888. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3889. }
  3890. }
  3891. }
  3892. }
  3893. }
  3894. if len(err) == 0 {
  3895. c.ServeSuccessJSON(map[string]interface{}{
  3896. "msg": "销售变更成功",
  3897. })
  3898. } else {
  3899. c.ServeSuccessJSON(map[string]interface{}{
  3900. "failed_code": -10,
  3901. "msg": err,
  3902. })
  3903. }
  3904. }
  3905. func (c *HisApiController) ChangeDrugthree() {
  3906. //ids := c.GetString("ids")
  3907. //id_arr := strings.Split(ids, ",")
  3908. flows, _ := service.GetNewDrugFlowInfothree()
  3909. admin_user_id, _ := c.GetInt64("admin_user_id")
  3910. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3911. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3912. var err []string
  3913. for _, item := range flows {
  3914. var res3 ResultSix
  3915. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3916. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3917. if prescription.OrderStatus == 2 {
  3918. //已经结算
  3919. //判断是否已经销售
  3920. if item.IsSale == 1 { //是否已经销售,1是 0否
  3921. //是否已经变更 1是 0否
  3922. if item.IsChange == 0 { //没变更,进行变更操作
  3923. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3924. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3925. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3926. var respJSON3 map[string]interface{}
  3927. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3928. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3930. return
  3931. }
  3932. userJSONBytes3, _ := json.Marshal(respJSON3)
  3933. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3934. utils.ErrorLog("解析失败:%v", err)
  3935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3936. return
  3937. }
  3938. if res3.Infcode == 0 {
  3939. item.IsChange = 1
  3940. item.BgBchno = bg_number
  3941. service.SaveDF2(item)
  3942. } else {
  3943. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3944. }
  3945. }
  3946. } else { //没销售,
  3947. var res FJ3507Result
  3948. var res3507for10188 FJ3507ResultFor10188
  3949. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3950. //进行商品销售接口
  3951. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3952. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3953. var respJSON3 map[string]interface{}
  3954. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3955. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3957. return
  3958. }
  3959. userJSONBytes3, _ := json.Marshal(respJSON3)
  3960. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3961. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3962. utils.ErrorLog("解析失败:%v", err)
  3963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3964. return
  3965. }
  3966. //if res3507for10188.Infcode
  3967. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3968. //res.Output = resSix10265.Output
  3969. res.ErrMsg = res3507for10188.ErrMsg
  3970. res.Cainfo = res3507for10188.Cainfo
  3971. res.WarnMsg = res3507for10188.WarnMsg
  3972. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3973. res.Infcode = infocode
  3974. } else {
  3975. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3976. utils.ErrorLog("解析失败:%v", err)
  3977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3978. return
  3979. }
  3980. }
  3981. if res.Infcode == 0 {
  3982. item.IsSale = 1
  3983. item.Bchno = number
  3984. item.SaleDate = time.Now().Format("2006-01-02")
  3985. err5 := service.SaveDF(item)
  3986. if err5 == nil {
  3987. if item.IsChange == 0 { //没变更,进行变更操作
  3988. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3989. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3990. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3991. var respJSON3 map[string]interface{}
  3992. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3995. return
  3996. }
  3997. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  3998. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3999. utils.ErrorLog("解析失败:%v", err)
  4000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4001. return
  4002. }
  4003. //if res3507for10188.Infcode
  4004. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4005. //res.Output = resSix10265.Output
  4006. res3.ErrMsg = res3507for10188.ErrMsg
  4007. res3.Cainfo = res3507for10188.Cainfo
  4008. res3.WarnMsg = res3507for10188.WarnMsg
  4009. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4010. res3.Infcode = infocode
  4011. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4012. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4013. utils.ErrorLog("解析失败:%v", err)
  4014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4015. return
  4016. }
  4017. //if res3507for10188.Infcode
  4018. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4019. //res.Output = resSix10265.Output
  4020. res3.ErrMsg = res3507for10188.ErrMsg
  4021. res3.Cainfo = res3507for10188.Cainfo
  4022. res3.WarnMsg = res3507for10188.WarnMsg
  4023. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4024. res3.Infcode = infocode
  4025. } else {
  4026. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4027. utils.ErrorLog("解析失败:%v", err)
  4028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4029. return
  4030. }
  4031. }
  4032. if res3.Infcode == 0 {
  4033. item.IsChange = 1
  4034. item.BgBchno = bg_number
  4035. service.SaveDF2(item)
  4036. } else {
  4037. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4038. }
  4039. }
  4040. }
  4041. } else {
  4042. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4043. }
  4044. }
  4045. } else { //还没结算
  4046. var res3507for10188 FJ3507ResultFor10188
  4047. if item.IsChange == 0 { //没变更,进行变更操作
  4048. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4049. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4050. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4051. var respJSON3 map[string]interface{}
  4052. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4053. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4055. return
  4056. }
  4057. userJSONBytes3, _ := json.Marshal(respJSON3)
  4058. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4059. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4060. utils.ErrorLog("解析失败:%v", err)
  4061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4062. return
  4063. }
  4064. //if res3507for10188.Infcode
  4065. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4066. //res.Output = resSix10265.Output
  4067. res3.ErrMsg = res3507for10188.ErrMsg
  4068. res3.Cainfo = res3507for10188.Cainfo
  4069. res3.WarnMsg = res3507for10188.WarnMsg
  4070. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4071. res3.Infcode = infocode
  4072. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4073. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4074. utils.ErrorLog("解析失败:%v", err)
  4075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4076. return
  4077. }
  4078. //if res3507for10188.Infcode
  4079. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4080. //res.Output = resSix10265.Output
  4081. res3.ErrMsg = res3507for10188.ErrMsg
  4082. res3.Cainfo = res3507for10188.Cainfo
  4083. res3.WarnMsg = res3507for10188.WarnMsg
  4084. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4085. res3.Infcode = infocode
  4086. } else {
  4087. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4088. utils.ErrorLog("解析失败:%v", err)
  4089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4090. return
  4091. }
  4092. }
  4093. if res3.Infcode == 0 {
  4094. item.IsChange = 1
  4095. item.BgBchno = bg_number
  4096. service.SaveDF2(item)
  4097. } else {
  4098. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4099. }
  4100. }
  4101. }
  4102. } else if item.ConsumableType == 7 {
  4103. var res3507for10188 FJ3507ResultFor10188
  4104. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4105. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4106. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4107. //判断是否已经销售
  4108. if item.IsSale == 2 { //是否已经销售,1是 0否
  4109. //是否已经变更 1是 0否
  4110. if item.IsChange == 0 { //没变更,进行变更操作
  4111. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4112. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4113. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4114. var respJSON3 map[string]interface{}
  4115. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4116. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4118. return
  4119. }
  4120. userJSONBytes3, _ := json.Marshal(respJSON3)
  4121. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4122. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4123. utils.ErrorLog("解析失败:%v", err)
  4124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4125. return
  4126. }
  4127. //if res3507for10188.Infcode
  4128. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4129. //res.Output = resSix10265.Output
  4130. res3.ErrMsg = res3507for10188.ErrMsg
  4131. res3.Cainfo = res3507for10188.Cainfo
  4132. res3.WarnMsg = res3507for10188.WarnMsg
  4133. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4134. res3.Infcode = infocode
  4135. } else {
  4136. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4137. utils.ErrorLog("解析失败:%v", err)
  4138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4139. return
  4140. }
  4141. }
  4142. if res3.Infcode == 0 {
  4143. item.IsChange = 1
  4144. item.BgBchno = bg_number
  4145. service.SaveDF2(item)
  4146. } else {
  4147. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4148. }
  4149. }
  4150. } else { //没销售,
  4151. //进行商品销售退货接口
  4152. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4153. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4154. saveLog(result111, result222, "3506", "销售退货")
  4155. var res7 FJ3507Result
  4156. //进行商品销售接口
  4157. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4158. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4159. var respJSON3 map[string]interface{}
  4160. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4161. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4163. return
  4164. }
  4165. userJSONBytes3, _ := json.Marshal(respJSON3)
  4166. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4167. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4168. utils.ErrorLog("解析失败:%v", err)
  4169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4170. return
  4171. }
  4172. //if res3507for10188.Infcode
  4173. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4174. //res.Output = resSix10265.Output
  4175. res7.ErrMsg = res3507for10188.ErrMsg
  4176. res7.Cainfo = res3507for10188.Cainfo
  4177. res7.WarnMsg = res3507for10188.WarnMsg
  4178. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4179. res7.Infcode = infocode
  4180. } else {
  4181. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4182. utils.ErrorLog("解析失败:%v", err)
  4183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4184. return
  4185. }
  4186. }
  4187. if res7.Infcode == 0 {
  4188. item.IsSale = 2
  4189. item.SaleDate = item.SaleDate
  4190. item.Bchno = number
  4191. service.SaveDF(item)
  4192. if item.IsChange == 0 { //没变更,进行变更操作
  4193. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4194. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4195. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4196. var respJSON3 map[string]interface{}
  4197. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4198. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4200. return
  4201. }
  4202. userJSONBytes3, _ := json.Marshal(respJSON3)
  4203. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4204. // utils.ErrorLog("解析失败:%v", err)
  4205. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4206. // return
  4207. //}
  4208. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4209. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4210. utils.ErrorLog("解析失败:%v", err)
  4211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4212. return
  4213. }
  4214. //if res3507for10188.Infcode
  4215. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4216. //res.Output = resSix10265.Output
  4217. res3.ErrMsg = res3507for10188.ErrMsg
  4218. res3.Cainfo = res3507for10188.Cainfo
  4219. res3.WarnMsg = res3507for10188.WarnMsg
  4220. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4221. res3.Infcode = infocode
  4222. } else {
  4223. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4224. utils.ErrorLog("解析失败:%v", err)
  4225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4226. return
  4227. }
  4228. }
  4229. if res3.Infcode == 0 {
  4230. item.IsChange = 1
  4231. item.BgBchno = bg_number
  4232. service.SaveDF2(item)
  4233. } else {
  4234. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4235. }
  4236. }
  4237. } else {
  4238. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4239. }
  4240. }
  4241. } else { //还没结算
  4242. if item.IsChange == 0 { //没变更,进行变更操作
  4243. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4244. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4245. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4246. var respJSON3 map[string]interface{}
  4247. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4248. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4250. return
  4251. }
  4252. userJSONBytes3, _ := json.Marshal(respJSON3)
  4253. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4254. // utils.ErrorLog("解析失败:%v", err)
  4255. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4256. // return
  4257. //}
  4258. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4259. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4260. utils.ErrorLog("解析失败:%v", err)
  4261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4262. return
  4263. }
  4264. //if res3507for10188.Infcode
  4265. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4266. //res.Output = resSix10265.Output
  4267. res3.ErrMsg = res3507for10188.ErrMsg
  4268. res3.Cainfo = res3507for10188.Cainfo
  4269. res3.WarnMsg = res3507for10188.WarnMsg
  4270. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4271. res3.Infcode = infocode
  4272. } else {
  4273. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4274. utils.ErrorLog("解析失败:%v", err)
  4275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4276. return
  4277. }
  4278. }
  4279. if res3.Infcode == 0 {
  4280. item.IsChange = 1
  4281. item.BgBchno = bg_number
  4282. service.SaveDF2(item)
  4283. } else {
  4284. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4285. }
  4286. }
  4287. }
  4288. }
  4289. }
  4290. if len(err) == 0 {
  4291. c.ServeSuccessJSON(map[string]interface{}{
  4292. "msg": "销售变更成功",
  4293. })
  4294. } else {
  4295. c.ServeSuccessJSON(map[string]interface{}{
  4296. "failed_code": -10,
  4297. "msg": err,
  4298. })
  4299. }
  4300. }
  4301. func (c *HisApiController) ChangeDrugTen() {
  4302. //ids := c.GetString("ids")
  4303. //id_arr := strings.Split(ids, ",")
  4304. now := time.Now()
  4305. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  4306. flows, _ := service.GetNewDrugFlowInforTen(timestamp,c.GetAdminUserInfo().CurrentOrgId)
  4307. admin_user_id, _ := c.GetInt64("admin_user_id")
  4308. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4309. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4310. var err []string
  4311. for _, item := range flows {
  4312. var res3 ResultSix
  4313. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4314. if item.HisDoctorAdviceInfo.PrescriptionId == 0{
  4315. continue
  4316. }
  4317. if item.HisDoctorAdviceInfo.PrescriptionId == 0{
  4318. continue
  4319. }
  4320. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4321. if prescription.OrderStatus == 2 {
  4322. //已经结算
  4323. //判断是否已经销售
  4324. if item.IsSale == 1 { //是否已经销售,1是 0否
  4325. //是否已经变更 1是 0否
  4326. if item.IsChange == 0 { //没变更,进行变更操作
  4327. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4328. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4329. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4330. var respJSON3 map[string]interface{}
  4331. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4332. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4334. return
  4335. }
  4336. userJSONBytes3, _ := json.Marshal(respJSON3)
  4337. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4338. utils.ErrorLog("解析失败:%v", err)
  4339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4340. return
  4341. }
  4342. if res3.Infcode == 0 {
  4343. item.IsChange = 1
  4344. item.BgBchno = bg_number
  4345. service.SaveDF2(item)
  4346. } else {
  4347. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4348. }
  4349. }
  4350. } else { //没销售,
  4351. var res FJ3507Result
  4352. var res3507for10188 FJ3507ResultFor10188
  4353. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4354. //进行商品销售接口
  4355. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4356. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4357. var respJSON3 map[string]interface{}
  4358. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4361. return
  4362. }
  4363. userJSONBytes3, _ := json.Marshal(respJSON3)
  4364. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4365. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4366. utils.ErrorLog("解析失败:%v", err)
  4367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4368. return
  4369. }
  4370. //if res3507for10188.Infcode
  4371. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4372. //res.Output = resSix10265.Output
  4373. res.ErrMsg = res3507for10188.ErrMsg
  4374. res.Cainfo = res3507for10188.Cainfo
  4375. res.WarnMsg = res3507for10188.WarnMsg
  4376. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4377. res.Infcode = infocode
  4378. } else {
  4379. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4380. utils.ErrorLog("解析失败:%v", err)
  4381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4382. return
  4383. }
  4384. }
  4385. if res.Infcode == 0 {
  4386. item.IsSale = 1
  4387. item.Bchno = number
  4388. item.SaleDate = time.Now().Format("2006-01-02")
  4389. err5 := service.SaveDF(item)
  4390. if err5 == nil {
  4391. if item.IsChange == 0 { //没变更,进行变更操作
  4392. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4393. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4394. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4395. var respJSON3 map[string]interface{}
  4396. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4397. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4399. return
  4400. }
  4401. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4402. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4403. utils.ErrorLog("解析失败:%v", err)
  4404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4405. return
  4406. }
  4407. //if res3507for10188.Infcode
  4408. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4409. //res.Output = resSix10265.Output
  4410. res3.ErrMsg = res3507for10188.ErrMsg
  4411. res3.Cainfo = res3507for10188.Cainfo
  4412. res3.WarnMsg = res3507for10188.WarnMsg
  4413. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4414. res3.Infcode = infocode
  4415. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4416. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4417. utils.ErrorLog("解析失败:%v", err)
  4418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4419. return
  4420. }
  4421. //if res3507for10188.Infcode
  4422. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4423. //res.Output = resSix10265.Output
  4424. res3.ErrMsg = res3507for10188.ErrMsg
  4425. res3.Cainfo = res3507for10188.Cainfo
  4426. res3.WarnMsg = res3507for10188.WarnMsg
  4427. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4428. res3.Infcode = infocode
  4429. } else {
  4430. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4431. utils.ErrorLog("解析失败:%v", err)
  4432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4433. return
  4434. }
  4435. }
  4436. if res3.Infcode == 0 {
  4437. item.IsChange = 1
  4438. item.BgBchno = bg_number
  4439. service.SaveDF2(item)
  4440. } else {
  4441. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4442. }
  4443. }
  4444. }
  4445. } else {
  4446. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4447. }
  4448. }
  4449. } else { //还没结算
  4450. var res3507for10188 FJ3507ResultFor10188
  4451. if item.IsChange == 0 { //没变更,进行变更操作
  4452. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4453. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4454. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4455. var respJSON3 map[string]interface{}
  4456. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4459. return
  4460. }
  4461. userJSONBytes3, _ := json.Marshal(respJSON3)
  4462. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4463. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4464. utils.ErrorLog("解析失败:%v", err)
  4465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4466. return
  4467. }
  4468. //if res3507for10188.Infcode
  4469. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4470. //res.Output = resSix10265.Output
  4471. res3.ErrMsg = res3507for10188.ErrMsg
  4472. res3.Cainfo = res3507for10188.Cainfo
  4473. res3.WarnMsg = res3507for10188.WarnMsg
  4474. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4475. res3.Infcode = infocode
  4476. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4477. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4478. utils.ErrorLog("解析失败:%v", err)
  4479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4480. return
  4481. }
  4482. //if res3507for10188.Infcode
  4483. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4484. //res.Output = resSix10265.Output
  4485. res3.ErrMsg = res3507for10188.ErrMsg
  4486. res3.Cainfo = res3507for10188.Cainfo
  4487. res3.WarnMsg = res3507for10188.WarnMsg
  4488. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4489. res3.Infcode = infocode
  4490. } else {
  4491. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4492. utils.ErrorLog("解析失败:%v", err)
  4493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4494. return
  4495. }
  4496. }
  4497. if res3.Infcode == 0 {
  4498. item.IsChange = 1
  4499. item.BgBchno = bg_number
  4500. service.SaveDF2(item)
  4501. } else {
  4502. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4503. }
  4504. }
  4505. }
  4506. } else if item.ConsumableType == 7 {
  4507. var res3507for10188 FJ3507ResultFor10188
  4508. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4509. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4510. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4511. //判断是否已经销售
  4512. if item.IsSale == 2 { //是否已经销售,1是 0否
  4513. //是否已经变更 1是 0否
  4514. if item.IsChange == 0 { //没变更,进行变更操作
  4515. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4516. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4517. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4518. var respJSON3 map[string]interface{}
  4519. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4520. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4522. return
  4523. }
  4524. userJSONBytes3, _ := json.Marshal(respJSON3)
  4525. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4526. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4527. utils.ErrorLog("解析失败:%v", err)
  4528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4529. return
  4530. }
  4531. //if res3507for10188.Infcode
  4532. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4533. //res.Output = resSix10265.Output
  4534. res3.ErrMsg = res3507for10188.ErrMsg
  4535. res3.Cainfo = res3507for10188.Cainfo
  4536. res3.WarnMsg = res3507for10188.WarnMsg
  4537. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4538. res3.Infcode = infocode
  4539. } else {
  4540. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4541. utils.ErrorLog("解析失败:%v", err)
  4542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4543. return
  4544. }
  4545. }
  4546. if res3.Infcode == 0 {
  4547. item.IsChange = 1
  4548. item.BgBchno = bg_number
  4549. service.SaveDF2(item)
  4550. } else {
  4551. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4552. }
  4553. }
  4554. } else { //没销售,
  4555. //进行商品销售退货接口
  4556. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4557. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4558. saveLog(result111, result222, "3506", "销售退货")
  4559. var res7 FJ3507Result
  4560. //进行商品销售接口
  4561. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4562. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4563. var respJSON3 map[string]interface{}
  4564. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4565. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4567. return
  4568. }
  4569. userJSONBytes3, _ := json.Marshal(respJSON3)
  4570. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4571. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4572. utils.ErrorLog("解析失败:%v", err)
  4573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4574. return
  4575. }
  4576. //if res3507for10188.Infcode
  4577. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4578. //res.Output = resSix10265.Output
  4579. res7.ErrMsg = res3507for10188.ErrMsg
  4580. res7.Cainfo = res3507for10188.Cainfo
  4581. res7.WarnMsg = res3507for10188.WarnMsg
  4582. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4583. res7.Infcode = infocode
  4584. } else {
  4585. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4586. utils.ErrorLog("解析失败:%v", err)
  4587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4588. return
  4589. }
  4590. }
  4591. if res7.Infcode == 0 {
  4592. item.IsSale = 2
  4593. item.SaleDate = item.SaleDate
  4594. item.Bchno = number
  4595. service.SaveDF(item)
  4596. if item.IsChange == 0 { //没变更,进行变更操作
  4597. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4598. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4599. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4600. var respJSON3 map[string]interface{}
  4601. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4602. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4604. return
  4605. }
  4606. userJSONBytes3, _ := json.Marshal(respJSON3)
  4607. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4608. // utils.ErrorLog("解析失败:%v", err)
  4609. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4610. // return
  4611. //}
  4612. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4613. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4614. utils.ErrorLog("解析失败:%v", err)
  4615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4616. return
  4617. }
  4618. //if res3507for10188.Infcode
  4619. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4620. //res.Output = resSix10265.Output
  4621. res3.ErrMsg = res3507for10188.ErrMsg
  4622. res3.Cainfo = res3507for10188.Cainfo
  4623. res3.WarnMsg = res3507for10188.WarnMsg
  4624. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4625. res3.Infcode = infocode
  4626. } else {
  4627. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4628. utils.ErrorLog("解析失败:%v", err)
  4629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4630. return
  4631. }
  4632. }
  4633. if res3.Infcode == 0 {
  4634. item.IsChange = 1
  4635. item.BgBchno = bg_number
  4636. service.SaveDF2(item)
  4637. } else {
  4638. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4639. }
  4640. }
  4641. } else {
  4642. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4643. }
  4644. }
  4645. } else { //还没结算
  4646. if item.IsChange == 0 { //没变更,进行变更操作
  4647. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4648. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4649. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4650. var respJSON3 map[string]interface{}
  4651. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4652. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4654. return
  4655. }
  4656. userJSONBytes3, _ := json.Marshal(respJSON3)
  4657. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4658. // utils.ErrorLog("解析失败:%v", err)
  4659. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4660. // return
  4661. //}
  4662. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4663. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4664. utils.ErrorLog("解析失败:%v", err)
  4665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4666. return
  4667. }
  4668. //if res3507for10188.Infcode
  4669. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4670. //res.Output = resSix10265.Output
  4671. res3.ErrMsg = res3507for10188.ErrMsg
  4672. res3.Cainfo = res3507for10188.Cainfo
  4673. res3.WarnMsg = res3507for10188.WarnMsg
  4674. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4675. res3.Infcode = infocode
  4676. } else {
  4677. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4678. utils.ErrorLog("解析失败:%v", err)
  4679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4680. return
  4681. }
  4682. }
  4683. if res3.Infcode == 0 {
  4684. item.IsChange = 1
  4685. item.BgBchno = bg_number
  4686. service.SaveDF2(item)
  4687. } else {
  4688. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4689. }
  4690. }
  4691. }
  4692. }
  4693. }
  4694. if len(err) == 0 {
  4695. c.ServeSuccessJSON(map[string]interface{}{
  4696. "msg": "销售变更成功",
  4697. })
  4698. } else {
  4699. c.ServeSuccessJSON(map[string]interface{}{
  4700. "failed_code": -10,
  4701. "msg": err,
  4702. })
  4703. }
  4704. }
  4705. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4706. var struct3502 models.Struct3502
  4707. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4708. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4709. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4710. struct3502.FixmedinsCode = miConfig.Code
  4711. struct3502.Code = miConfig.Code
  4712. struct3502.Opter = role.UserName
  4713. struct3502.RxFlag = "1"
  4714. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  4715. struct3502.OrgName = miConfig.OrgName
  4716. struct3502.AccessKey = miConfig.AccessKey
  4717. struct3502.RequestUrl = miConfig.Url
  4718. struct3502.SecretKey = miConfig.SecretKey
  4719. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4720. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4721. struct3502.Url = miConfig.Url
  4722. struct3502.AppId = miConfig.Cainfo
  4723. struct3502.AppSecret = miConfig.AppSecret
  4724. struct3502.Enckey = miConfig.EncKey
  4725. struct3502.SignKey = miConfig.SignKey
  4726. struct3502.SecretKey = miConfig.SecretKey
  4727. struct3502.InvChgType = chgType
  4728. struct3502.FixmedinsBchno = number
  4729. struct3502.Cnt = strconv.FormatInt(count, 10)
  4730. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  4731. //result1, result2, _ := service.FJyb3502(struct3502)
  4732. if miConfig.MdtrtareaAdmvs == "350500" {
  4733. result1, result2, _ := service.FJyb3502(struct3502)
  4734. //saveLog(result1, result2, "3502", "3502")
  4735. return result1, result2
  4736. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4737. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  4738. return result1, result2
  4739. }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  4740. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  4741. return result1, result2
  4742. } else {
  4743. data := make(map[string]interface{})
  4744. data["struct_3502s"] = struct3502
  4745. client := &http.Client{}
  4746. bytesData, _ := json.Marshal(data)
  4747. var req *http.Request
  4748. if miConfig.MdtrtareaAdmvs == "320921" {
  4749. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4750. } else {
  4751. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4752. }
  4753. resp, _ := client.Do(req)
  4754. defer resp.Body.Close()
  4755. body, ioErr := ioutil.ReadAll(resp.Body)
  4756. if ioErr != nil {
  4757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4758. }
  4759. var respJSON map[string]interface{}
  4760. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4762. }
  4763. //var resSix10265 ResultSix10265 //1101结果
  4764. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4765. result, _ := json.Marshal(respJSON)
  4766. return string(result), ""
  4767. }
  4768. }
  4769. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4770. var struct3505 models.Struct3505
  4771. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4772. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4773. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4774. struct3505.FixmedinsBchno = number
  4775. struct3505.Opter = role.UserName
  4776. struct3505.FixmedinsCode = miConfig.Code
  4777. struct3505.Code = miConfig.Code
  4778. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  4779. struct3505.PrscDrName = roles.UserName
  4780. if org_id == 10191 {
  4781. struct3505.PharName = "刘水山"
  4782. struct3505.PharPracCertNo = "2015026350260000002611351127"
  4783. }
  4784. if org_id == 10188 {
  4785. struct3505.PharName = "李汉清"
  4786. struct3505.PharPracCertNo = "30220200932022010034"
  4787. }
  4788. if org_id == 10217 {
  4789. struct3505.PharName = "张敏"
  4790. struct3505.PharPracCertNo = "30220230432090100108"
  4791. }
  4792. if org_id == 10318 {
  4793. struct3505.PharName = "邹刘阳"
  4794. struct3505.PharPracCertNo = "210441200001378"
  4795. }
  4796. if org_id == 10402 {
  4797. struct3505.PharName = "刘韶健"
  4798. struct3505.PharPracCertNo = "2015026440262015440501001198"
  4799. }
  4800. if org_id == 10567 {
  4801. struct3505.PharName = "范小兰"
  4802. struct3505.PharPracCertNo = "0200102079485"
  4803. }
  4804. order := service.GetHisOrderByNumber(pre.BatchNumber)
  4805. struct3505.SetlId = order.SetlId
  4806. struct3505.MdtrtSn = order.MdtrtId
  4807. struct3505.ManuLotnum = drug.Number
  4808. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  4809. struct3505.ExpyEnd = ""
  4810. struct3505.RxFlag = "1"
  4811. struct3505.TrdnFlag = "1"
  4812. struct3505.RtalDocno = order.Number
  4813. struct3505.PsnCertType = "01"
  4814. struct3505.CertNo = order.Certno
  4815. struct3505.PsnNo = order.PsnNo
  4816. struct3505.PsnName = order.PsnName
  4817. struct3505.Url = miConfig.Url
  4818. struct3505.AppId = miConfig.Cainfo
  4819. struct3505.AppSecret = miConfig.AppSecret
  4820. struct3505.Enckey = miConfig.EncKey
  4821. struct3505.SignKey = miConfig.SignKey
  4822. struct3505.SecretKey = miConfig.SecretKey
  4823. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  4824. struct3505.SelRetnCnt = strValue
  4825. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4826. struct3505.SelRetnOpterName = role.UserName
  4827. if order.IsMedicineInsurance == 1 {
  4828. struct3505.MdtrtSetlType = "1"
  4829. } else {
  4830. struct3505.MdtrtSetlType = "2"
  4831. }
  4832. struct3505.OrgName = miConfig.OrgName
  4833. struct3505.AccessKey = miConfig.AccessKey
  4834. struct3505.RequestUrl = miConfig.Url
  4835. struct3505.SecretKey = miConfig.SecretKey
  4836. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4837. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4838. struct3505.DrugTracCodg = drug.DrugCode
  4839. if miConfig.MdtrtareaAdmvs == "350500" {
  4840. result1, result2, _ := service.FJyb3505(struct3505)
  4841. return result1, result2
  4842. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4843. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  4844. return result1, result2
  4845. }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  4846. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  4847. return result1, result2
  4848. } else {
  4849. data := make(map[string]interface{})
  4850. data["struct_3505s"] = struct3505
  4851. client := &http.Client{}
  4852. bytesData, _ := json.Marshal(data)
  4853. var req *http.Request
  4854. if miConfig.MdtrtareaAdmvs == "320921" {
  4855. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  4856. } else {
  4857. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  4858. }
  4859. resp, _ := client.Do(req)
  4860. defer resp.Body.Close()
  4861. body, ioErr := ioutil.ReadAll(resp.Body)
  4862. if ioErr != nil {
  4863. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4864. }
  4865. var respJSON map[string]interface{}
  4866. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4867. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4868. }
  4869. //var resSix10265 ResultSix10265 //1101结果
  4870. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4871. result, _ := json.Marshal(respJSON)
  4872. return string(result), ""
  4873. }
  4874. }
  4875. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4876. var struct3506 models.Struct3506
  4877. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4878. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4879. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4880. struct3506.FixmedinsCode = miConfig.Code
  4881. struct3506.Code = miConfig.Code
  4882. struct3506.FixmedinsBchno = number
  4883. struct3506.Opter = role.UserName
  4884. order := service.GetHisOrderByNumber(pre.BatchNumber)
  4885. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  4886. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  4887. struct3506.MdtrtSn = order.MdtrtId
  4888. struct3506.ExpyEnd = ""
  4889. struct3506.RxFlag = "0"
  4890. struct3506.TrdnFlag = "1"
  4891. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  4892. struct3506.SelRetnCnt = strValue
  4893. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4894. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  4895. struct3506.SelRetnOpterName = role.UserName
  4896. struct3506.OrgName = miConfig.OrgName
  4897. struct3506.AccessKey = miConfig.AccessKey
  4898. struct3506.RequestUrl = miConfig.Url
  4899. struct3506.SecretKey = miConfig.SecretKey
  4900. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4901. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4902. struct3506.Url = miConfig.Url
  4903. struct3506.AppId = miConfig.Cainfo
  4904. struct3506.AppSecret = miConfig.AppSecret
  4905. struct3506.Enckey = miConfig.EncKey
  4906. struct3506.SignKey = miConfig.SignKey
  4907. struct3506.SecretKey = miConfig.SecretKey
  4908. struct3506.DrugTracCodg = drug.DrugCode
  4909. if miConfig.MdtrtareaAdmvs == "350500" {
  4910. result1, result2, _ := service.FJyb3506(struct3506)
  4911. return result1, result2
  4912. } else {
  4913. data := make(map[string]interface{})
  4914. data["struct_3506s"] = struct3506
  4915. client := &http.Client{}
  4916. bytesData, _ := json.Marshal(data)
  4917. var req *http.Request
  4918. if miConfig.MdtrtareaAdmvs == "320921" {
  4919. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  4920. } else {
  4921. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  4922. }
  4923. resp, _ := client.Do(req)
  4924. defer resp.Body.Close()
  4925. body, ioErr := ioutil.ReadAll(resp.Body)
  4926. if ioErr != nil {
  4927. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4928. }
  4929. var respJSON map[string]interface{}
  4930. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4931. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4932. }
  4933. //var resSix10265 ResultSix10265 //1101结果
  4934. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4935. result, _ := json.Marshal(respJSON)
  4936. return string(result), ""
  4937. }
  4938. }
  4939. func (c *HisApiController) Get1318() {
  4940. adminUser := c.GetAdminUserInfo()
  4941. admin_user_id, _ := c.GetInt64("admin_user_id")
  4942. code := c.GetString("code")
  4943. code = ""
  4944. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4945. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4946. api := ""
  4947. if miConfig.MdtrtareaAdmvs == "320921" {
  4948. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  4949. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  4950. } else {
  4951. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  4952. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  4953. }
  4954. resp, requestErr := http.Get(api)
  4955. if requestErr != nil {
  4956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4957. return
  4958. }
  4959. body, ioErr := ioutil.ReadAll(resp.Body)
  4960. if ioErr != nil {
  4961. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4963. return
  4964. }
  4965. var respJSON map[string]interface{}
  4966. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4967. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4969. return
  4970. }
  4971. //var res Result2406
  4972. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4973. result, _ := json.Marshal(respJSON)
  4974. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4975. utils.ErrorLog("解析失败:%v", err)
  4976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4977. return
  4978. }
  4979. if res.Infcode == "0" {
  4980. c.ServeSuccessJSON(map[string]interface{}{
  4981. "result": "",
  4982. })
  4983. } else {
  4984. c.ServeSuccessJSON(map[string]interface{}{
  4985. "failed_code": -10,
  4986. "msg": res.ErrMsg,
  4987. })
  4988. */return
  4989. //}
  4990. }
  4991. func (c *HisApiController) Get2503() {
  4992. adminUser := c.GetAdminUserInfo()
  4993. admin_user_id, _ := c.GetInt64("admin_user_id")
  4994. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4995. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4996. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  4997. }
  4998. func (c *HisApiController) Get2406() {
  4999. id, _ := c.GetInt64("id")
  5000. record_time := c.GetString("record_time")
  5001. his_patient_id, _ := c.GetInt64("his_patient_id")
  5002. admin_user_id, _ := c.GetInt64("admin_user_id")
  5003. diagnosis_id := c.GetString("diagnosis")
  5004. timeLayout := "2006-01-02"
  5005. loc, _ := time.LoadLocation("Local")
  5006. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5007. if err != nil {
  5008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5009. return
  5010. }
  5011. recordDateTime := theTime.Unix()
  5012. adminUser := c.GetAdminUserInfo()
  5013. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5014. var config []*models.HisXtDiagnoseConfig
  5015. for _, item := range diagnosis_ids {
  5016. id, _ := strconv.ParseInt(item, 10, 64)
  5017. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5018. config = append(config, &diagnosisConfig)
  5019. }
  5020. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5021. fmt.Println(his_patient_id)
  5022. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5023. //timestamp := time.Now().Unix()
  5024. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5025. var patientPrescription models.HisPrescriptionInfo
  5026. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5027. if patientPrescription.ID == 0 {
  5028. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5029. }
  5030. var res2 Result2406
  5031. if miConfig.MdtrtareaAdmvs == "341203" {
  5032. data := make(map[string]interface{})
  5033. client := &http.Client{}
  5034. data["psn_no"] = his.PsnNo
  5035. data["mdtrt_id"] = his.Number
  5036. data["operator"] = roles.UserName
  5037. data["cert_no"] = his.IdCardNo
  5038. data["org_name"] = miConfig.OrgName
  5039. data["psn_name"] = his.Name
  5040. data["ipt_otp_no"] = his.IptOtpNo
  5041. data["ipt_psn_sp_flag_type"] = "0901"
  5042. data["ipt_psn_sp_flag"] = "1"
  5043. data["fixmedins_code"] = miConfig.Code
  5044. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5045. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5046. data["url"] = miConfig.Url
  5047. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5048. bytesData, _ := json.Marshal(data)
  5049. var req *http.Request
  5050. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5051. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5052. resp, _ := client.Do(req)
  5053. defer resp.Body.Close()
  5054. body, ioErr := ioutil.ReadAll(resp.Body)
  5055. if ioErr != nil {
  5056. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5058. return
  5059. }
  5060. var respJSON map[string]interface{}
  5061. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5062. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5064. return
  5065. }
  5066. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5067. if status == "0" {
  5068. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5069. c.ServeSuccessJSON(map[string]interface{}{
  5070. "failed_code": -10,
  5071. "msg": err_msg,
  5072. })
  5073. return
  5074. }
  5075. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5076. userJSONBytes, _ := json.Marshal(respJSON)
  5077. fmt.Println("log")
  5078. fmt.Println(string(userJSONBytes))
  5079. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5080. utils.ErrorLog("解析失败:%v", err)
  5081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5082. return
  5083. }
  5084. }
  5085. if res2.Infcode != 0 {
  5086. adminUser := c.GetAdminUserInfo()
  5087. errlog := &models.HisOrderError{
  5088. UserOrgId: adminUser.CurrentOrgId,
  5089. Ctime: time.Now().Unix(),
  5090. Mtime: time.Now().Unix(),
  5091. ErrMsg: res2.ErrMsg,
  5092. Status: 1,
  5093. PatientId: id,
  5094. RecordTime: recordDateTime,
  5095. Stage: 3,
  5096. }
  5097. service.CreateErrMsgLog(errlog)
  5098. c.ServeSuccessJSON(map[string]interface{}{
  5099. "failed_code": -10,
  5100. "msg": res2.ErrMsg,
  5101. })
  5102. return
  5103. } else {
  5104. c.ServeSuccessJSON(map[string]interface{}{
  5105. "msg": "上传成功",
  5106. })
  5107. return
  5108. }
  5109. }
  5110. func (c *HisApiController) Get4105() {
  5111. }
  5112. func (c *HisApiController) Post5302() {
  5113. patient_id, _ := c.GetInt64("id")
  5114. admin_user_id, _ := c.GetInt64("admin_user_id")
  5115. p, _ := service.GetHisPatientById(patient_id)
  5116. adminUser := c.GetAdminUserInfo()
  5117. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5118. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5119. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5120. }
  5121. func (c *HisApiController) Get4104() {
  5122. }
  5123. type Output struct {
  5124. CertNo string `json:"certno"`
  5125. PsnName string `json:"psn_name"`
  5126. CardNo string `json:"card_no"`
  5127. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5128. CardSN string `json:"card_sn"`
  5129. PsnCertType string `json:"psn_cert_type"`
  5130. MdtrtCertNo string `json:"mdtrt_cert_no"`
  5131. MdtrtCertType string `json:"mdtrt_cert_type"`
  5132. QRCode string `json:"qrCode"`
  5133. EcToken string `json:"ecToken"`
  5134. }
  5135. type AHResponse struct {
  5136. Body AHBody `json:"body"`
  5137. Code int `json:"code"`
  5138. CSBCode int `json:"csbCode"`
  5139. Message string `json:"message"`
  5140. RequestID string `json:"requestId"`
  5141. State struct{} `json:"state"`
  5142. }
  5143. type AHBody struct {
  5144. ErrMsg string `json:"err_msg"`
  5145. InfRefMsgID string `json:"inf_refmsgid"`
  5146. InfCode int `json:"infcode"`
  5147. Output struct {
  5148. Result []struct {
  5149. BasMednFlag string `json:"bas_medn_flag"`
  5150. ChldMedcFlag string `json:"chld_medc_flag"`
  5151. ChrgitmLv string `json:"chrgitm_lv"`
  5152. Cnt float64 `json:"cnt"`
  5153. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5154. DrtReimFlag string `json:"drt_reim_flag"`
  5155. FeedetlSn string `json:"feedetl_sn"`
  5156. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5157. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5158. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5159. ListSpItemFlag string `json:"list_sp_item_flag"`
  5160. LmtUsedFlag string `json:"lmt_used_flag"`
  5161. MedChrgitmType string `json:"med_chrgitm_type"`
  5162. Memo string `json:"memo"`
  5163. OverlmtAmt float64 `json:"overlmt_amt"`
  5164. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5165. Pric float64 `json:"pric"`
  5166. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5167. SelfpayProp float64 `json:"selfpay_prop"`
  5168. } `json:"result"`
  5169. } `json:"output"`
  5170. }
  5171. type Response struct {
  5172. Output Output `json:"output"`
  5173. Infcode int `json:"infcode"`
  5174. InfRefMsgID string `json:"inf_refmsgid"`
  5175. RefMsgTime string `json:"refmsg_time"`
  5176. RespondTime string `json:"respond_time"`
  5177. ErrMsg string `json:"err_msg"`
  5178. WarnMsg string `json:"warn_msg"`
  5179. SignType string `json:"signtype"`
  5180. CAInfo string `json:"cainfo"`
  5181. }
  5182. func (c *HisApiController) Getquerydata() {
  5183. query_type, _ := c.GetInt64("type")
  5184. refd_setl_flag := c.GetString("refd_setl_flag")
  5185. med_type := c.GetString("med_type")
  5186. //admin_user_id,_ := c.GetInt64("admin_user_id")
  5187. cert_no := c.GetString("cert_no")
  5188. psn_no := c.GetString("psn_no")
  5189. start_time := c.GetString("start_time")
  5190. end_time := c.GetString("end_time")
  5191. page, _ := c.GetInt64("page")
  5192. limit, _ := c.GetInt64("limit")
  5193. var bp models.BusinessParams5262
  5194. bp.RefdSetlFlag = refd_setl_flag
  5195. bp.MedType = med_type
  5196. bp.Certno = cert_no
  5197. bp.Psnno = psn_no
  5198. bp.QBegntime = start_time
  5199. bp.QEndtime = end_time
  5200. if query_type == 1 { //本地
  5201. Post5262(c, bp, page, limit)
  5202. } else { //异地
  5203. Post5267(c, bp, page, limit)
  5204. }
  5205. }
  5206. func (c *HisApiController) Drugscheck() {
  5207. admin_user_id, _ := c.GetInt64("admin_user_id")
  5208. adminUser := c.GetAdminUserInfo()
  5209. var queryResult []QueryResult
  5210. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  5211. for _, item := range drugs {
  5212. result := QueryResult{
  5213. ID: item.ID,
  5214. Name: item.DrugName,
  5215. Code: item.MedicalInsuranceNumber,
  5216. List_type_code: "101",
  5217. }
  5218. queryResult = append(queryResult, result)
  5219. }
  5220. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5221. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5222. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5223. for _, item := range queryResult {
  5224. 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)
  5225. }
  5226. }
  5227. func (c *HisApiController) Goodcheck() {
  5228. admin_user_id, _ := c.GetInt64("admin_user_id")
  5229. adminUser := c.GetAdminUserInfo()
  5230. var queryResult []QueryResult
  5231. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  5232. for _, item := range goods {
  5233. result := QueryResult{
  5234. ID: item.ID,
  5235. Name: item.GoodName,
  5236. Code: item.SocialSecurityDirectoryCode,
  5237. List_type_code: "301",
  5238. }
  5239. queryResult = append(queryResult, result)
  5240. }
  5241. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5242. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5243. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5244. for _, item := range queryResult {
  5245. 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)
  5246. //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)
  5247. }
  5248. }
  5249. func (c *HisApiController) Projectcheck() {
  5250. admin_user_id, _ := c.GetInt64("admin_user_id")
  5251. adminUser := c.GetAdminUserInfo()
  5252. var queryResult []QueryResult
  5253. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  5254. for _, item := range projects {
  5255. result := QueryResult{
  5256. ID: item.ID,
  5257. Name: item.ProjectName,
  5258. Code: item.MedicalCode,
  5259. List_type_code: "201",
  5260. }
  5261. queryResult = append(queryResult, result)
  5262. }
  5263. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5264. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5265. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5266. for _, item := range queryResult {
  5267. 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)
  5268. }
  5269. }
  5270. //func (c *HisApiController)CancleDia(){
  5271. //
  5272. // id, _ := c.GetInt64("id")
  5273. // record_time := c.GetString("record_time")
  5274. // his_patient_id, _ := c.GetInt64("his_patient_id")
  5275. //
  5276. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5277. //
  5278. // diagnosis_id := c.GetString("diagnosis")
  5279. // sick_type, _ := c.GetInt64("sick_type")
  5280. // reg_type, _ := c.GetInt64("p_type")
  5281. // begin_time := c.GetString("begin_time")
  5282. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  5283. //
  5284. //
  5285. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  5286. //
  5287. // fmt.Println(acct_used_flag)
  5288. //
  5289. //
  5290. // timeLayout := "2006-01-02"
  5291. // loc, _ := time.LoadLocation("Local")
  5292. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5293. // if err != nil {
  5294. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5295. // return
  5296. // }
  5297. // recordDateTime := theTime.Unix()
  5298. // adminUser := c.GetAdminUserInfo()
  5299. //
  5300. //
  5301. //
  5302. //
  5303. //
  5304. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5305. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5306. // var patientPrescription models.HisPrescriptionInfo
  5307. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5308. // if patientPrescription.ID == 0 {
  5309. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5310. // }
  5311. // //if patientPrescription.Do
  5312. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5313. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5314. //
  5315. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5316. //
  5317. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  5318. //
  5319. // var config []*models.HisXtDiagnoseConfig
  5320. // for _, item := range diagnosis_ids {
  5321. // id, _ := strconv.ParseInt(item, 10, 64)
  5322. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  5323. // config = append(config, &diagnosisConfig)
  5324. // }
  5325. //
  5326. // sickConfig, _ := service.FindSickById(sick_type)
  5327. //
  5328. //
  5329. // data := make(map[string]interface{})
  5330. // client := &http.Client{}
  5331. // data["psn_no"] = his.PsnNo
  5332. // data["mdtrt_id"] = his.Number
  5333. // data["doctor"] = roles.UserName
  5334. // data["department"] = department.Name
  5335. // data["org_name"] = miConfig.OrgName
  5336. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  5337. // data["doctor_id"] = doctor_info.DoctorNumber
  5338. // data["new_doctor_name"] = doctor_info.UserName
  5339. // data["fixmedins_code"] = miConfig.Code
  5340. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5341. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5342. // data["secret_key"] = miConfig.SecretKey
  5343. // data["sick_code"] = sickConfig.CountryCode
  5344. // data["sick_name"] = sickConfig.ClassName
  5345. // data["url"] = miConfig.Url
  5346. // data["ak"] = miConfig.AccessKey
  5347. // data["begin_time"] = begin_time
  5348. // data["cainfo"] = miConfig.Cainfo
  5349. // data["is_vaild"] = "0"
  5350. //
  5351. // data["dept"] = strconv.FormatInt(department.ID, 10)
  5352. // data["config"] = config
  5353. // bytesData, _ := json.Marshal(data)
  5354. //
  5355. // var req *http.Request
  5356. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  5357. // resp, _ := client.Do(req)
  5358. // defer resp.Body.Close()
  5359. // body, ioErr := ioutil.ReadAll(resp.Body)
  5360. // if ioErr != nil {
  5361. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5362. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5363. // return
  5364. // }
  5365. // var respJSON map[string]interface{}
  5366. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5367. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5368. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5369. // return
  5370. // }
  5371. //
  5372. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5373. // userJSONBytes, _ := json.Marshal(respJSON)
  5374. // fmt.Println("log")
  5375. // fmt.Println(string(userJSONBytes))
  5376. //
  5377. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5378. // utils.ErrorLog("解析失败:%v", err)
  5379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5380. // return
  5381. // }
  5382. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  5383. // res2.Output = ressix10265.Output
  5384. // res2.ErrMsg = ressix10265.ErrMsg
  5385. // res2.Cainfo = ressix10265.Cainfo
  5386. // res2.WarnMsg = ressix10265.WarnMsg
  5387. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5388. // res2.Infcode = infocode
  5389. //
  5390. //}
  5391. func (c *HisApiController) Get4102() {
  5392. order_id, _ := c.GetInt64("order_id")
  5393. admin_user_id, _ := c.GetInt64("admin_user_id")
  5394. stas_type := c.GetString("stas_type")
  5395. order, _ := service.GetHisOrderByIDTwo(order_id)
  5396. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5397. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5398. var pp models.PublicParams
  5399. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5400. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5401. pp.FixmedinsName = miConfig.OrgName
  5402. pp.FixmedinsCode = miConfig.Code
  5403. pp.RequestUrl = miConfig.Url
  5404. pp.Cainfo = miConfig.Cainfo
  5405. pp.SecretKey = miConfig.SecretKey
  5406. pp.AccessKey = miConfig.AccessKey
  5407. pp.OpterName = curRoles.UserName
  5408. if miConfig.MdtrtareaAdmvs == "350500" {
  5409. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5410. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  5411. saveLog(result, request, "4102", "清单确认")
  5412. var dat map[string]interface{}
  5413. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5414. fmt.Println(dat)
  5415. } else {
  5416. fmt.Println(err)
  5417. }
  5418. var empty ResultFourteen
  5419. userJSONBytes, _ := json.Marshal(dat)
  5420. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5421. utils.ErrorLog("解析失败:%v", err)
  5422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5423. return
  5424. }
  5425. if empty.Infcode == 0 {
  5426. c.ServeSuccessJSON(map[string]interface{}{
  5427. "msg": "确认成功",
  5428. })
  5429. return
  5430. }
  5431. } else {
  5432. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5433. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  5434. result3, request3 := service.Jxyb4105(pp)
  5435. saveLog(result, request, "4102", "清单确认")
  5436. saveLog(result2, request2, "4103", "清单确认")
  5437. saveLog(result3, request3, "4105", "清单统计")
  5438. var dat map[string]interface{}
  5439. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5440. fmt.Println(dat)
  5441. } else {
  5442. fmt.Println(err)
  5443. }
  5444. var empty ResultFourteen
  5445. userJSONBytes, _ := json.Marshal(dat)
  5446. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5447. utils.ErrorLog("解析失败:%v", err)
  5448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5449. return
  5450. }
  5451. if empty.Infcode == 0 {
  5452. c.ServeSuccessJSON(map[string]interface{}{
  5453. "msg": "确认成功",
  5454. })
  5455. return
  5456. }
  5457. }
  5458. }
  5459. // 对账权限查询
  5460. func (c *HisApiController) Get3260() {
  5461. admin_user_id, _ := c.GetInt64("admin_user_id")
  5462. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5463. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5464. var api string
  5465. var res models.JSResult3260
  5466. if miConfig.MdtrtareaAdmvs == "320921" {
  5467. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5468. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5469. } else {
  5470. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5471. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5472. }
  5473. resp, requestErr := http.Get(api)
  5474. if requestErr != nil {
  5475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5476. return
  5477. }
  5478. body, ioErr := ioutil.ReadAll(resp.Body)
  5479. if ioErr != nil {
  5480. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5482. return
  5483. }
  5484. var respJSON map[string]interface{}
  5485. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5486. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5488. return
  5489. }
  5490. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5491. result, _ := json.Marshal(respJSON)
  5492. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5493. utils.ErrorLog("解析失败:%v", err)
  5494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5495. return
  5496. }
  5497. if res.Infcode == "0" {
  5498. c.ServeSuccessJSON(map[string]interface{}{
  5499. "result": res.Output.Data,
  5500. })
  5501. } else {
  5502. c.ServeSuccessJSON(map[string]interface{}{
  5503. "failed_code": -10,
  5504. "msg": res.ErrMsg,
  5505. })
  5506. return
  5507. }
  5508. }
  5509. func (c *HisApiController) Get3261() {
  5510. admin_user_id, _ := c.GetInt64("admin_user_id")
  5511. //month := c.GetString("month")
  5512. startTime := c.GetString("start_time")
  5513. //endTime, _ := c.GetString("end_time")
  5514. times := strings.Split(startTime, "-")
  5515. stmt_mon := times[0] + times[1]
  5516. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5517. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5518. var api string
  5519. var res models.JSResult3261
  5520. //var res10265 Result5301For10265
  5521. if miConfig.MdtrtareaAdmvs == "320921" {
  5522. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5523. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  5524. } else {
  5525. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5526. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  5527. }
  5528. resp, requestErr := http.Get(api)
  5529. if requestErr != nil {
  5530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5531. return
  5532. }
  5533. body, ioErr := ioutil.ReadAll(resp.Body)
  5534. if ioErr != nil {
  5535. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5537. return
  5538. }
  5539. var respJSON map[string]interface{}
  5540. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5541. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5543. return
  5544. }
  5545. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5546. result, _ := json.Marshal(respJSON)
  5547. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5548. utils.ErrorLog("解析失败:%v", err)
  5549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5550. return
  5551. }
  5552. if res.Infcode == "0" {
  5553. c.ServeSuccessJSON(map[string]interface{}{
  5554. "result": res.Output,
  5555. })
  5556. } else {
  5557. c.ServeSuccessJSON(map[string]interface{}{
  5558. "failed_code": -10,
  5559. "msg": res.ErrMsg,
  5560. })
  5561. return
  5562. }
  5563. }
  5564. type TempFun struct {
  5565. FundKey string
  5566. FundCode string
  5567. }
  5568. func (c *HisApiController) Get3262() {
  5569. admin_user_id, _ := c.GetInt64("admin_user_id")
  5570. startTime := c.GetString("start_time")
  5571. endTime := c.GetString("end_time")
  5572. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5573. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5574. //timeLayout := "2006-01-02"
  5575. //loc, _ := time.LoadLocation("Local")
  5576. //var theStartTIme int64
  5577. //if len(startTime) > 0 {
  5578. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  5579. // if err != nil {
  5580. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5581. // return
  5582. // }
  5583. // theStartTIme = theTime.Unix()
  5584. //}
  5585. //var theEndtTIme int64
  5586. //if len(endTime) > 0 {
  5587. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  5588. // if err != nil {
  5589. // utils.ErrorLog(err.Error())
  5590. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5591. // return
  5592. // }
  5593. // theEndtTIme = theTime.Unix()
  5594. //}
  5595. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  5596. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  5597. for _, team := range datas {
  5598. fmt.Println(team.PsnTime)
  5599. for _, team_two := range datas_two {
  5600. fmt.Println(team_two.PsnTime)
  5601. if team.FundKey == team_two.FundKey {
  5602. fmt.Println(team_two.PsnTime)
  5603. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  5604. fmt.Println(team.PsnTime)
  5605. }
  5606. }
  5607. }
  5608. fmt.Println("1111")
  5609. fmt.Println(datas)
  5610. fmt.Println("1111")
  5611. var twos []models.FixMonRecDetailFileInTwo
  5612. for _, team := range datas {
  5613. var two models.FixMonRecDetailFileInTwo
  5614. two.MedType = team.MedType
  5615. two.Insutype = team.Insutype
  5616. two.PsnType = team.PsnType
  5617. two.MedType = team.MedType
  5618. two.FixBlngAdmdvs = "999999"
  5619. two.InsuAdmdvs = "555555"
  5620. two.PsnTime = team.PsnTime
  5621. two.PsnCnt = team.PsnCnt
  5622. two.FundKey = team.FundKey
  5623. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  5624. fps, _ := strconv.ParseFloat(team.Fund, 64)
  5625. ia, _ := strconv.ParseFloat(team.Amt, 64)
  5626. two.MedfeeSumAmt = ms
  5627. two.InscpAmt = ia
  5628. two.FundPaySumAmt = fps
  5629. twos = append(twos, two)
  5630. }
  5631. //startTime := c.GetString("start_time")
  5632. //endTime, _ := c.GetString("end_time")
  5633. times := strings.Split(startTime, "-")
  5634. stmt_mon := times[0] + times[1]
  5635. var funs []models.FundDetail
  5636. for _, item := range datas {
  5637. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  5638. funs = append(funs, fun...)
  5639. }
  5640. var funInfos []models.Fund
  5641. //for _, item := range funs {
  5642. // var rf []models.FundInfo
  5643. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  5644. // for _, subitem := range rf {
  5645. // var fund models.Fund
  5646. // fund.FundCode = subitem.FundPayType
  5647. // fund.FundName = subitem.FundPayTypeName
  5648. // fund.FundAmt = subitem.FundPayAmt
  5649. // fund.FundKey = item.FundKey
  5650. // fund.InsuAdmdvs = "555555"
  5651. // fund.FixBlngAdmdvs = "999999"
  5652. // funInfos = append(funInfos, fund)
  5653. // }
  5654. //}
  5655. var tempFuns []TempFun
  5656. for _, funInfo := range funInfos {
  5657. var tempFun TempFun
  5658. tempFun.FundKey = funInfo.FundKey
  5659. tempFun.FundCode = funInfo.FundCode
  5660. tempFuns = append(tempFuns, tempFun)
  5661. }
  5662. tempFuns = RemoveRepeatedFunElement(tempFuns)
  5663. fmt.Println(tempFuns)
  5664. var funInfosTwo []models.Fund
  5665. decimal.DivisionPrecision = 2
  5666. for _, item := range tempFuns {
  5667. var fund models.Fund
  5668. for _, subItem := range funInfos {
  5669. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  5670. fund.FundKey = subItem.FundKey
  5671. fund.InsuAdmdvs = subItem.InsuAdmdvs
  5672. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  5673. fund.FundName = subItem.FundName
  5674. fund.FundCode = subItem.FundCode
  5675. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  5676. }
  5677. }
  5678. funInfosTwo = append(funInfosTwo, fund)
  5679. }
  5680. fmt.Println("funInfosTwo")
  5681. fmt.Println(funInfosTwo)
  5682. var upld_btch string
  5683. var empty models.JSResultEmpty
  5684. data := make(map[string]interface{})
  5685. data["org_name"] = miConfig.OrgName
  5686. data["doctor"] = curRoles.UserName
  5687. data["doctor_name"] = curRoles.UserName
  5688. data["fixmedins_code"] = miConfig.Code
  5689. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5690. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5691. data["secret_key"] = miConfig.SecretKey
  5692. data["url"] = miConfig.Url
  5693. data["ak"] = miConfig.AccessKey
  5694. data["cainfo"] = miConfig.Cainfo
  5695. data["datas"] = twos
  5696. data["fund"] = funInfosTwo
  5697. fmt.Println(twos)
  5698. month := time.Unix(1557042972, 0).Format("1")
  5699. year := time.Now().Format("2006")
  5700. month = time.Now().Format("01")
  5701. day := time.Now().Format("02")
  5702. hour := time.Now().Format("15")
  5703. min := time.Now().Format("04")
  5704. sec := time.Now().Format("05")
  5705. fix_fill_date := year + month + day + hour + min + sec
  5706. data["fix_fill_dept"] = miConfig.OrgName
  5707. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  5708. data["fix_fill_psn"] = curRoles.UserName
  5709. data["fix_fill_date"] = fix_fill_date
  5710. data["stmt_loc"] = "2"
  5711. data["setl_mon"] = stmt_mon
  5712. upld_btch = "0"
  5713. data["upld_btch"] = upld_btch
  5714. //fmt.Println(data)
  5715. client := &http.Client{}
  5716. bytesData, _ := json.Marshal(data)
  5717. var req *http.Request
  5718. if miConfig.MdtrtareaAdmvs == "320921" {
  5719. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  5720. } else {
  5721. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  5722. }
  5723. resp, _ := client.Do(req)
  5724. defer resp.Body.Close()
  5725. body, ioErr := ioutil.ReadAll(resp.Body)
  5726. if ioErr != nil {
  5727. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5729. }
  5730. var respJSON map[string]interface{}
  5731. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5732. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5734. }
  5735. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5736. //fmt.Println(respJSON)
  5737. result, _ := json.Marshal(respJSON)
  5738. //fmt.Println(result)
  5739. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  5740. utils.ErrorLog("解析失败:%v", err)
  5741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5742. }
  5743. if empty.Infcode != "0" {
  5744. c.ServeSuccessJSON(map[string]interface{}{
  5745. "failed_code": -10,
  5746. "msg": empty.ErrMsg,
  5747. })
  5748. return
  5749. } else {
  5750. c.ServeSuccessJSON(map[string]interface{}{
  5751. "msg": "上传成功",
  5752. })
  5753. return
  5754. }
  5755. }
  5756. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  5757. newArr = make([]TempFun, 0)
  5758. for i := 0; i < len(arr); i++ {
  5759. repeat := false
  5760. for j := i + 1; j < len(arr); j++ {
  5761. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  5762. repeat = true
  5763. break
  5764. }
  5765. }
  5766. if !repeat {
  5767. newArr = append(newArr, arr[i])
  5768. }
  5769. }
  5770. return
  5771. }
  5772. func (c *HisApiController) Get3263() {
  5773. admin_user_id, _ := c.GetInt64("admin_user_id")
  5774. startTime := c.GetString("start_time")
  5775. //endTime, _ := c.GetString("end_time")
  5776. times := strings.Split(startTime, "-")
  5777. setl_mon := times[0] + times[1]
  5778. upld_btch := "0"
  5779. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5780. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5781. var result3263 models.JSResult3263
  5782. data := make(map[string]interface{})
  5783. data["org_name"] = miConfig.OrgName
  5784. data["doctor"] = curRoles.UserName
  5785. data["doctor_name"] = curRoles.UserName
  5786. data["fixmedins_code"] = miConfig.Code
  5787. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5788. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5789. data["secret_key"] = miConfig.SecretKey
  5790. data["url"] = miConfig.Url
  5791. data["ak"] = miConfig.AccessKey
  5792. data["cainfo"] = miConfig.Cainfo
  5793. data["setl_mon"] = setl_mon
  5794. data["stmt_loc"] = "2"
  5795. data["upld_btch"] = upld_btch
  5796. client := &http.Client{}
  5797. bytesData, _ := json.Marshal(data)
  5798. var req *http.Request
  5799. if miConfig.MdtrtareaAdmvs == "320921" {
  5800. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  5801. } else {
  5802. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  5803. }
  5804. resp, _ := client.Do(req)
  5805. defer resp.Body.Close()
  5806. body, ioErr := ioutil.ReadAll(resp.Body)
  5807. if ioErr != nil {
  5808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5810. }
  5811. var respJSON map[string]interface{}
  5812. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5813. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5815. }
  5816. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5817. fmt.Println(respJSON)
  5818. result, _ := json.Marshal(respJSON)
  5819. fmt.Println(result)
  5820. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  5821. utils.ErrorLog("解析失败:%v", err)
  5822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5823. }
  5824. if result3263.Infcode != "0" {
  5825. c.ServeSuccessJSON(map[string]interface{}{
  5826. "failed_code": -10,
  5827. "msg": result3263.ErrMsg,
  5828. })
  5829. return
  5830. } else {
  5831. c.ServeSuccessJSON(map[string]interface{}{
  5832. "list": result3263.Output,
  5833. })
  5834. return
  5835. }
  5836. }
  5837. func (c *HisApiController) Get3264() {
  5838. admin_user_id, _ := c.GetInt64("admin_user_id")
  5839. startTime := c.GetString("start_time")
  5840. //endTime, _ := c.GetString("end_time")
  5841. times := strings.Split(startTime, "-")
  5842. setl_mon := times[0] + times[1]
  5843. upld_btch := "0"
  5844. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5845. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5846. //solidify_id := []
  5847. var result3263 models.JSResult3263
  5848. data := make(map[string]interface{})
  5849. data["org_name"] = miConfig.OrgName
  5850. data["doctor"] = curRoles.UserName
  5851. data["doctor_name"] = curRoles.UserName
  5852. data["fixmedins_code"] = miConfig.Code
  5853. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5854. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5855. data["secret_key"] = miConfig.SecretKey
  5856. data["url"] = miConfig.Url
  5857. data["ak"] = miConfig.AccessKey
  5858. data["cainfo"] = miConfig.Cainfo
  5859. data["setl_mon"] = setl_mon
  5860. data["stmt_loc"] = "2"
  5861. data["upld_btch"] = upld_btch
  5862. client := &http.Client{}
  5863. bytesData, _ := json.Marshal(data)
  5864. var req3263 *http.Request
  5865. if miConfig.MdtrtareaAdmvs == "320921" {
  5866. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  5867. } else {
  5868. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  5869. }
  5870. resp, _ := client.Do(req3263)
  5871. defer resp.Body.Close()
  5872. body, ioErr := ioutil.ReadAll(resp.Body)
  5873. if ioErr != nil {
  5874. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5876. }
  5877. var respJSON3263 map[string]interface{}
  5878. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  5879. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5881. }
  5882. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5883. fmt.Println(respJSON3263)
  5884. result, _ := json.Marshal(respJSON3263)
  5885. fmt.Println(result)
  5886. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  5887. utils.ErrorLog("解析失败:%v", err)
  5888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5889. }
  5890. var ids []string
  5891. for _, item := range result3263.Output {
  5892. ids = append(ids, item.SolidifyID)
  5893. }
  5894. var empty models.JSResultEmpty
  5895. data2 := make(map[string]interface{})
  5896. data2["org_name"] = miConfig.OrgName
  5897. data2["doctor"] = curRoles.UserName
  5898. data2["doctor_name"] = curRoles.UserName
  5899. data2["fixmedins_code"] = miConfig.Code
  5900. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5901. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5902. data2["secret_key"] = miConfig.SecretKey
  5903. data2["url"] = miConfig.Url
  5904. data2["ak"] = miConfig.AccessKey
  5905. data2["cainfo"] = miConfig.Cainfo
  5906. data2["setl_mon"] = setl_mon
  5907. data2["stmt_loc"] = "2"
  5908. data2["upld_btch"] = upld_btch
  5909. data2["solidify_id"] = ids
  5910. client2 := &http.Client{}
  5911. bytesData2, _ := json.Marshal(data2)
  5912. var req *http.Request
  5913. if miConfig.MdtrtareaAdmvs == "320921" {
  5914. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  5915. } else {
  5916. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  5917. }
  5918. resp2, _ := client2.Do(req)
  5919. defer resp.Body.Close()
  5920. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  5921. if ioErr2 != nil {
  5922. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  5923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5924. }
  5925. var respJSON map[string]interface{}
  5926. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  5927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5929. }
  5930. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5931. fmt.Println(respJSON)
  5932. result2, _ := json.Marshal(respJSON)
  5933. fmt.Println(result2)
  5934. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  5935. utils.ErrorLog("解析失败:%v", err)
  5936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5937. }
  5938. if empty.Infcode != "0" {
  5939. c.ServeSuccessJSON(map[string]interface{}{
  5940. "failed_code": -10,
  5941. "msg": empty.ErrMsg,
  5942. })
  5943. return
  5944. } else {
  5945. c.ServeSuccessJSON(map[string]interface{}{
  5946. "msg": "",
  5947. })
  5948. return
  5949. }
  5950. }
  5951. func (c *HisApiController) Get3265() {
  5952. admin_user_id, _ := c.GetInt64("admin_user_id")
  5953. startTime := c.GetString("start_time")
  5954. //endTime, _ := c.GetString("end_time")
  5955. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5956. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5957. times := strings.Split(startTime, "-")
  5958. setl_mon := times[0] + times[1]
  5959. var upld_btch string
  5960. upld_btch = "0"
  5961. //var empty models.JSResultEmpty
  5962. var result3265 models.JSResult3264
  5963. var result3263 models.JSResult3263
  5964. data2 := make(map[string]interface{})
  5965. data2["org_name"] = miConfig.OrgName
  5966. data2["doctor"] = curRoles.UserName
  5967. data2["doctor_name"] = curRoles.UserName
  5968. data2["fixmedins_code"] = miConfig.Code
  5969. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5970. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5971. data2["secret_key"] = miConfig.SecretKey
  5972. data2["url"] = miConfig.Url
  5973. data2["ak"] = miConfig.AccessKey
  5974. data2["cainfo"] = miConfig.Cainfo
  5975. data2["setl_mon"] = setl_mon
  5976. data2["stmt_loc"] = "2"
  5977. data2["upld_btch"] = upld_btch
  5978. client2 := &http.Client{}
  5979. bytesData2, _ := json.Marshal(data2)
  5980. var req3263 *http.Request
  5981. if miConfig.MdtrtareaAdmvs == "320921" {
  5982. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  5983. } else {
  5984. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  5985. }
  5986. resp2, _ := client2.Do(req3263)
  5987. defer resp2.Body.Close()
  5988. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  5989. if ioErr2 != nil {
  5990. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  5991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5992. }
  5993. var respJSON3263 map[string]interface{}
  5994. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  5995. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5997. }
  5998. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5999. fmt.Println(respJSON3263)
  6000. result2, _ := json.Marshal(respJSON3263)
  6001. fmt.Println(result2)
  6002. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6003. utils.ErrorLog("解析失败:%v", err)
  6004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6005. }
  6006. var ids []string
  6007. for _, item := range result3263.Output {
  6008. ids = append(ids, item.SolidifyID)
  6009. }
  6010. data := make(map[string]interface{})
  6011. data["org_name"] = miConfig.OrgName
  6012. data["doctor"] = curRoles.UserName
  6013. data["doctor_name"] = curRoles.UserName
  6014. data["fixmedins_code"] = miConfig.Code
  6015. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6016. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6017. data["secret_key"] = miConfig.SecretKey
  6018. data["url"] = miConfig.Url
  6019. data["ak"] = miConfig.AccessKey
  6020. data["cainfo"] = miConfig.Cainfo
  6021. data["setl_mon"] = setl_mon
  6022. data["solidify_id"] = ids
  6023. month := time.Unix(1557042972, 0).Format("1")
  6024. year := time.Now().Format("2006")
  6025. month = time.Now().Format("01")
  6026. day := time.Now().Format("02")
  6027. hour := time.Now().Format("15")
  6028. min := time.Now().Format("04")
  6029. sec := time.Now().Format("05")
  6030. fix_fill_date := year + month + day + hour + min + sec
  6031. data["fix_fill_dept"] = miConfig.OrgName
  6032. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6033. data["fix_fill_psn"] = curRoles.UserName
  6034. data["fix_fill_date"] = fix_fill_date
  6035. data["stmt_loc"] = "2"
  6036. data["upld_btch"] = upld_btch
  6037. client := &http.Client{}
  6038. bytesData, _ := json.Marshal(data)
  6039. var req *http.Request
  6040. if miConfig.MdtrtareaAdmvs == "320921" {
  6041. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6042. } else {
  6043. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6044. }
  6045. resp, _ := client.Do(req)
  6046. defer resp.Body.Close()
  6047. body, ioErr := ioutil.ReadAll(resp.Body)
  6048. if ioErr != nil {
  6049. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6051. }
  6052. var respJSON map[string]interface{}
  6053. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6056. }
  6057. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6058. fmt.Println(respJSON)
  6059. result, _ := json.Marshal(respJSON)
  6060. fmt.Println(result)
  6061. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6062. utils.ErrorLog("解析失败:%v", err)
  6063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6064. }
  6065. if result3265.Infcode != "0" {
  6066. c.ServeSuccessJSON(map[string]interface{}{
  6067. "failed_code": -10,
  6068. "msg": result3265.ErrMsg,
  6069. })
  6070. return
  6071. } else {
  6072. c.ServeSuccessJSON(map[string]interface{}{
  6073. "info": result3265.Output,
  6074. })
  6075. return
  6076. }
  6077. }
  6078. func (c *HisApiController) Get3266() {
  6079. admin_user_id, _ := c.GetInt64("admin_user_id")
  6080. startTime := c.GetString("start_time")
  6081. //endTime, _ := c.GetString("end_time")
  6082. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6083. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6084. times := strings.Split(startTime, "-")
  6085. stmt_mon := times[0] + times[1]
  6086. var upld_btch string
  6087. //var empty models.JSResultEmpty
  6088. var result3265 models.JSResult3264
  6089. data := make(map[string]interface{})
  6090. data["org_name"] = miConfig.OrgName
  6091. data["doctor"] = curRoles.UserName
  6092. data["doctor_name"] = curRoles.UserName
  6093. data["fixmedins_code"] = miConfig.Code
  6094. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6095. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6096. data["secret_key"] = miConfig.SecretKey
  6097. data["url"] = miConfig.Url
  6098. data["ak"] = miConfig.AccessKey
  6099. data["cainfo"] = miConfig.Cainfo
  6100. data["setl_mon"] = stmt_mon
  6101. month := time.Unix(1557042972, 0).Format("1")
  6102. year := time.Now().Format("2006")
  6103. month = time.Now().Format("01")
  6104. day := time.Now().Format("02")
  6105. hour := time.Now().Format("15")
  6106. min := time.Now().Format("04")
  6107. sec := time.Now().Format("05")
  6108. fix_fill_date := year + month + day + hour + min + sec
  6109. data["fix_fill_dept"] = miConfig.OrgName
  6110. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6111. data["fix_fill_psn"] = curRoles.UserName
  6112. data["fix_fill_date"] = fix_fill_date
  6113. data["stmt_loc"] = "2"
  6114. upld_btch = "0"
  6115. data["upld_btch"] = upld_btch
  6116. client := &http.Client{}
  6117. bytesData, _ := json.Marshal(data)
  6118. var req *http.Request
  6119. if miConfig.MdtrtareaAdmvs == "320921" {
  6120. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6121. } else {
  6122. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  6123. }
  6124. resp, _ := client.Do(req)
  6125. defer resp.Body.Close()
  6126. body, ioErr := ioutil.ReadAll(resp.Body)
  6127. if ioErr != nil {
  6128. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6130. }
  6131. var respJSON map[string]interface{}
  6132. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6133. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6135. }
  6136. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6137. fmt.Println(respJSON)
  6138. result, _ := json.Marshal(respJSON)
  6139. fmt.Println(result)
  6140. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6141. utils.ErrorLog("解析失败:%v", err)
  6142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6143. }
  6144. if result3265.Infcode != "0" {
  6145. c.ServeSuccessJSON(map[string]interface{}{
  6146. "failed_code": -10,
  6147. "msg": result3265.ErrMsg,
  6148. })
  6149. return
  6150. } else {
  6151. c.ServeSuccessJSON(map[string]interface{}{
  6152. "info": result3265.Output,
  6153. })
  6154. return
  6155. }
  6156. }
  6157. func (c *HisApiController) Get3267() {
  6158. admin_user_id, _ := c.GetInt64("admin_user_id")
  6159. startTime := c.GetString("start_time")
  6160. //endTime, _ := c.GetString("end_time")
  6161. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6162. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6163. times := strings.Split(startTime, "-")
  6164. setl_mon := times[0] + times[1]
  6165. var upld_btch string
  6166. //var empty models.JSResultEmpty
  6167. var result3265 models.JSResult3264
  6168. upld_btch = "0"
  6169. data := make(map[string]interface{})
  6170. data["org_name"] = miConfig.OrgName
  6171. data["doctor"] = curRoles.UserName
  6172. data["doctor_name"] = curRoles.UserName
  6173. data["fixmedins_code"] = miConfig.Code
  6174. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6175. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6176. data["secret_key"] = miConfig.SecretKey
  6177. data["url"] = miConfig.Url
  6178. data["ak"] = miConfig.AccessKey
  6179. data["cainfo"] = miConfig.Cainfo
  6180. data["setl_mon"] = setl_mon
  6181. data["stmt_loc"] = "2"
  6182. data["upld_btch"] = upld_btch
  6183. client := &http.Client{}
  6184. bytesData, _ := json.Marshal(data)
  6185. var req *http.Request
  6186. if miConfig.MdtrtareaAdmvs == "320921" {
  6187. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6188. } else {
  6189. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  6190. }
  6191. resp, _ := client.Do(req)
  6192. defer resp.Body.Close()
  6193. body, ioErr := ioutil.ReadAll(resp.Body)
  6194. if ioErr != nil {
  6195. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6197. }
  6198. var respJSON map[string]interface{}
  6199. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6202. }
  6203. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6204. fmt.Println(respJSON)
  6205. result, _ := json.Marshal(respJSON)
  6206. fmt.Println(result)
  6207. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6208. utils.ErrorLog("解析失败:%v", err)
  6209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6210. }
  6211. if result3265.Infcode != "0" {
  6212. c.ServeSuccessJSON(map[string]interface{}{
  6213. "failed_code": -10,
  6214. "msg": result3265.ErrMsg,
  6215. })
  6216. return
  6217. } else {
  6218. c.ServeSuccessJSON(map[string]interface{}{
  6219. "info": result3265.Output.Data,
  6220. })
  6221. return
  6222. }
  6223. }
  6224. func (c *HisApiController) Get3268() {
  6225. admin_user_id, _ := c.GetInt64("admin_user_id")
  6226. startTime := c.GetString("start_time")
  6227. endTime := c.GetString("end_time")
  6228. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6229. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6230. times := strings.Split(startTime, "-")
  6231. setl_mon := times[0] + times[1]
  6232. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6233. var twos []models.FixMonRecDetailFileInTwo
  6234. var funs []models.FundDetail
  6235. for _, item := range datas {
  6236. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6237. funs = append(funs, fun...)
  6238. }
  6239. var funInfos []models.Fund
  6240. //for _, item := range funs {
  6241. // var rf []models.FundInfo
  6242. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6243. // for _, subitem := range rf {
  6244. // var fund models.Fund
  6245. // fund.FundCode = subitem.FundPayType
  6246. // fund.FundName = subitem.FundPayTypeName
  6247. // fund.FundAmt = subitem.FundPayAmt
  6248. // fund.FundKey = item.FundKey
  6249. // fund.InsuAdmdvs = "555555"
  6250. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  6251. // funInfos = append(funInfos, fund)
  6252. // }
  6253. //}
  6254. for _, team := range datas {
  6255. var two models.FixMonRecDetailFileInTwo
  6256. two.SetlDate = time.Now().Format("2006-01-02")
  6257. two.MedType = team.MedType
  6258. two.Insutype = team.Insutype
  6259. two.PsnType = team.PsnType
  6260. two.MedType = team.MedType
  6261. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  6262. two.InsuAdmdvs = team.InsuAdmdvs
  6263. two.PsnTime = team.PsnTime
  6264. two.PsnCnt = team.PsnCnt
  6265. two.FundKey = team.FundKey
  6266. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6267. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6268. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6269. two.MedfeeSumAmt = ms
  6270. two.InscpAmt = ia
  6271. two.FundPaySumAmt = fps
  6272. twos = append(twos, two)
  6273. }
  6274. var upld_btch string
  6275. upld_btch = "0"
  6276. var empty models.JSResultEmpty
  6277. data := make(map[string]interface{})
  6278. data["org_name"] = miConfig.OrgName
  6279. data["doctor"] = curRoles.UserName
  6280. data["doctor_name"] = curRoles.UserName
  6281. data["fixmedins_code"] = miConfig.Code
  6282. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6283. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6284. data["secret_key"] = miConfig.SecretKey
  6285. data["url"] = miConfig.Url
  6286. data["ak"] = miConfig.AccessKey
  6287. data["cainfo"] = miConfig.Cainfo
  6288. data["datas"] = twos
  6289. data["fund"] = funInfos
  6290. data["setl_mon"] = setl_mon
  6291. month := time.Unix(1557042972, 0).Format("1")
  6292. year := time.Now().Format("2006")
  6293. month = time.Now().Format("01")
  6294. day := time.Now().Format("02")
  6295. hour := time.Now().Format("15")
  6296. min := time.Now().Format("04")
  6297. sec := time.Now().Format("05")
  6298. fix_fill_date := year + month + day + hour + min + sec
  6299. data["fix_fill_dept"] = miConfig.OrgName
  6300. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6301. data["fix_fill_psn"] = curRoles.UserName
  6302. data["fix_fill_date"] = fix_fill_date
  6303. data["stmt_loc"] = "2"
  6304. data["upld_btch"] = upld_btch
  6305. client := &http.Client{}
  6306. bytesData, _ := json.Marshal(data)
  6307. var req *http.Request
  6308. if miConfig.MdtrtareaAdmvs == "320921" {
  6309. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6310. } else {
  6311. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6312. }
  6313. resp, _ := client.Do(req)
  6314. defer resp.Body.Close()
  6315. body, ioErr := ioutil.ReadAll(resp.Body)
  6316. if ioErr != nil {
  6317. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6319. }
  6320. var respJSON map[string]interface{}
  6321. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6322. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6324. }
  6325. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6326. fmt.Println(respJSON)
  6327. result, _ := json.Marshal(respJSON)
  6328. fmt.Println(result)
  6329. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6330. utils.ErrorLog("解析失败:%v", err)
  6331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6332. }
  6333. if empty.Infcode != "0" {
  6334. c.ServeSuccessJSON(map[string]interface{}{
  6335. "failed_code": -10,
  6336. "msg": empty.ErrMsg,
  6337. })
  6338. return
  6339. } else {
  6340. c.ServeSuccessJSON(map[string]interface{}{
  6341. "msg": "上传成功",
  6342. })
  6343. return
  6344. }
  6345. }
  6346. func (c *HisApiController) Get3269() {
  6347. admin_user_id, _ := c.GetInt64("admin_user_id")
  6348. startTime := c.GetString("start_time")
  6349. //endTime, _ := c.GetString("end_time")
  6350. times := strings.Split(startTime, "-")
  6351. setl_mon := times[0] + times[1]
  6352. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6353. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6354. var result3263 models.JSResult3263
  6355. data := make(map[string]interface{})
  6356. data["org_name"] = miConfig.OrgName
  6357. data["doctor"] = curRoles.UserName
  6358. data["doctor_name"] = curRoles.UserName
  6359. data["fixmedins_code"] = miConfig.Code
  6360. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6361. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6362. data["secret_key"] = miConfig.SecretKey
  6363. data["url"] = miConfig.Url
  6364. data["ak"] = miConfig.AccessKey
  6365. data["cainfo"] = miConfig.Cainfo
  6366. data["setl_mon"] = setl_mon
  6367. data["stmt_loc"] = "2"
  6368. client := &http.Client{}
  6369. bytesData, _ := json.Marshal(data)
  6370. var req *http.Request
  6371. if miConfig.MdtrtareaAdmvs == "320921" {
  6372. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6373. } else {
  6374. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6375. }
  6376. resp, _ := client.Do(req)
  6377. defer resp.Body.Close()
  6378. body, ioErr := ioutil.ReadAll(resp.Body)
  6379. if ioErr != nil {
  6380. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6382. }
  6383. var respJSON map[string]interface{}
  6384. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6385. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6387. }
  6388. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6389. fmt.Println(respJSON)
  6390. result, _ := json.Marshal(respJSON)
  6391. fmt.Println(result)
  6392. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6393. utils.ErrorLog("解析失败:%v", err)
  6394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6395. }
  6396. if result3263.Infcode != "0" {
  6397. c.ServeSuccessJSON(map[string]interface{}{
  6398. "failed_code": -10,
  6399. "msg": result3263.ErrMsg,
  6400. })
  6401. return
  6402. } else {
  6403. c.ServeSuccessJSON(map[string]interface{}{
  6404. "msg": "上传成功",
  6405. })
  6406. return
  6407. }
  6408. }
  6409. func (c *HisApiController) Get3270() {
  6410. admin_user_id, _ := c.GetInt64("admin_user_id")
  6411. startTime := c.GetString("start_time")
  6412. //endTime, _ := c.GetString("end_time")
  6413. times := strings.Split(startTime, "-")
  6414. setl_mon := times[0] + times[1]
  6415. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6416. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6417. var result3263 models.JSResult3263
  6418. data2 := make(map[string]interface{})
  6419. data2["org_name"] = miConfig.OrgName
  6420. data2["doctor"] = curRoles.UserName
  6421. data2["doctor_name"] = curRoles.UserName
  6422. data2["fixmedins_code"] = miConfig.Code
  6423. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6424. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6425. data2["secret_key"] = miConfig.SecretKey
  6426. data2["url"] = miConfig.Url
  6427. data2["ak"] = miConfig.AccessKey
  6428. data2["cainfo"] = miConfig.Cainfo
  6429. data2["setl_mon"] = setl_mon
  6430. data2["stmt_loc"] = "2"
  6431. client2 := &http.Client{}
  6432. bytesData2, _ := json.Marshal(data2)
  6433. var req3263 *http.Request
  6434. if miConfig.MdtrtareaAdmvs == "320921" {
  6435. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6436. } else {
  6437. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6438. }
  6439. resp2, _ := client2.Do(req3263)
  6440. defer resp2.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 respJSON3263 map[string]interface{}
  6447. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6448. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6450. }
  6451. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6452. fmt.Println(respJSON3263)
  6453. result2, _ := json.Marshal(respJSON3263)
  6454. fmt.Println(result2)
  6455. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6456. utils.ErrorLog("解析失败:%v", err)
  6457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6458. }
  6459. var ids []string
  6460. for _, item := range result3263.Output {
  6461. ids = append(ids, item.SolidifyID)
  6462. }
  6463. var result3264 models.JSResult3264
  6464. data := make(map[string]interface{})
  6465. data["org_name"] = miConfig.OrgName
  6466. data["doctor"] = curRoles.UserName
  6467. data["doctor_name"] = curRoles.UserName
  6468. data["fixmedins_code"] = miConfig.Code
  6469. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6470. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6471. data["secret_key"] = miConfig.SecretKey
  6472. data["url"] = miConfig.Url
  6473. data["ak"] = miConfig.AccessKey
  6474. data["cainfo"] = miConfig.Cainfo
  6475. data["setl_mon"] = setl_mon
  6476. data["stmt_loc"] = "2"
  6477. data["solidify_id"] = ids
  6478. client := &http.Client{}
  6479. bytesData, _ := json.Marshal(data)
  6480. var req *http.Request
  6481. if miConfig.MdtrtareaAdmvs == "320921" {
  6482. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  6483. } else {
  6484. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  6485. }
  6486. resp, _ := client.Do(req)
  6487. defer resp.Body.Close()
  6488. body, ioErr := ioutil.ReadAll(resp.Body)
  6489. if ioErr != nil {
  6490. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6492. }
  6493. var respJSON map[string]interface{}
  6494. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6495. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6497. }
  6498. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6499. fmt.Println(respJSON)
  6500. result, _ := json.Marshal(respJSON)
  6501. fmt.Println(result)
  6502. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  6503. utils.ErrorLog("解析失败:%v", err)
  6504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6505. }
  6506. if result3264.Infcode != "0" {
  6507. c.ServeSuccessJSON(map[string]interface{}{
  6508. "failed_code": -10,
  6509. "msg": result3264.ErrMsg,
  6510. })
  6511. return
  6512. } else {
  6513. c.ServeSuccessJSON(map[string]interface{}{
  6514. "info": result3264.Output,
  6515. })
  6516. return
  6517. }
  6518. }
  6519. func (c *HisApiController) Get3271() {
  6520. admin_user_id, _ := c.GetInt64("admin_user_id")
  6521. startTime := c.GetString("start_time")
  6522. //endTime, _ := c.GetString("end_time")
  6523. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6524. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6525. times := strings.Split(startTime, "-")
  6526. setl_mon := times[0] + times[1]
  6527. //var empty models.JSResultEmpty
  6528. var result3265 models.JSResult3264
  6529. var result3263 models.JSResult3263
  6530. data2 := make(map[string]interface{})
  6531. data2["org_name"] = miConfig.OrgName
  6532. data2["doctor"] = curRoles.UserName
  6533. data2["doctor_name"] = curRoles.UserName
  6534. data2["fixmedins_code"] = miConfig.Code
  6535. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6536. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6537. data2["secret_key"] = miConfig.SecretKey
  6538. data2["url"] = miConfig.Url
  6539. data2["ak"] = miConfig.AccessKey
  6540. data2["cainfo"] = miConfig.Cainfo
  6541. data2["setl_mon"] = setl_mon
  6542. data2["stmt_loc"] = "2"
  6543. client2 := &http.Client{}
  6544. bytesData2, _ := json.Marshal(data2)
  6545. var req3263 *http.Request
  6546. if miConfig.MdtrtareaAdmvs == "320921" {
  6547. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6548. } else {
  6549. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6550. }
  6551. resp2, _ := client2.Do(req3263)
  6552. defer resp2.Body.Close()
  6553. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6554. if ioErr2 != nil {
  6555. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6557. }
  6558. var respJSON3263 map[string]interface{}
  6559. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6560. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6562. }
  6563. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6564. fmt.Println(respJSON3263)
  6565. result2, _ := json.Marshal(respJSON3263)
  6566. fmt.Println(result2)
  6567. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6568. utils.ErrorLog("解析失败:%v", err)
  6569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6570. }
  6571. var ids []string
  6572. for _, item := range result3263.Output {
  6573. ids = append(ids, item.SolidifyID)
  6574. }
  6575. data := make(map[string]interface{})
  6576. data["org_name"] = miConfig.OrgName
  6577. data["doctor"] = curRoles.UserName
  6578. data["doctor_name"] = curRoles.UserName
  6579. data["fixmedins_code"] = miConfig.Code
  6580. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6581. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6582. data["secret_key"] = miConfig.SecretKey
  6583. data["url"] = miConfig.Url
  6584. data["ak"] = miConfig.AccessKey
  6585. data["cainfo"] = miConfig.Cainfo
  6586. data["setl_mon"] = setl_mon
  6587. data["solidify_id"] = ids
  6588. month := time.Unix(1557042972, 0).Format("1")
  6589. year := time.Now().Format("2006")
  6590. month = time.Now().Format("01")
  6591. day := time.Now().Format("02")
  6592. hour := time.Now().Format("15")
  6593. min := time.Now().Format("04")
  6594. sec := time.Now().Format("05")
  6595. fix_fill_date := year + month + day + hour + min + sec
  6596. data["fix_fill_dept"] = miConfig.OrgName
  6597. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6598. data["fix_fill_psn"] = curRoles.UserName
  6599. data["fix_fill_date"] = fix_fill_date
  6600. data["stmt_loc"] = "2"
  6601. client := &http.Client{}
  6602. bytesData, _ := json.Marshal(data)
  6603. var req *http.Request
  6604. if miConfig.MdtrtareaAdmvs == "320921" {
  6605. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  6606. } else {
  6607. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  6608. }
  6609. resp, _ := client.Do(req)
  6610. defer resp.Body.Close()
  6611. body, ioErr := ioutil.ReadAll(resp.Body)
  6612. if ioErr != nil {
  6613. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6615. }
  6616. var respJSON map[string]interface{}
  6617. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6620. }
  6621. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6622. fmt.Println(respJSON)
  6623. result, _ := json.Marshal(respJSON)
  6624. fmt.Println(result)
  6625. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6626. utils.ErrorLog("解析失败:%v", err)
  6627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6628. }
  6629. if result3265.Infcode != "0" {
  6630. c.ServeSuccessJSON(map[string]interface{}{
  6631. "failed_code": -10,
  6632. "msg": result3265.ErrMsg,
  6633. })
  6634. return
  6635. } else {
  6636. c.ServeSuccessJSON(map[string]interface{}{
  6637. "info": result3265.Output.Data,
  6638. })
  6639. return
  6640. }
  6641. }
  6642. func (c *HisApiController) Get3272() {
  6643. admin_user_id, _ := c.GetInt64("admin_user_id")
  6644. startTime := c.GetString("start_time")
  6645. //endTime, _ := c.GetString("end_time")
  6646. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6647. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6648. times := strings.Split(startTime, "-")
  6649. setl_mon := times[0] + times[1]
  6650. var upld_btch string
  6651. //var empty models.JSResultEmpty
  6652. var result3265 models.JSResult3264
  6653. data := make(map[string]interface{})
  6654. data["org_name"] = miConfig.OrgName
  6655. data["doctor"] = curRoles.UserName
  6656. data["doctor_name"] = curRoles.UserName
  6657. data["fixmedins_code"] = miConfig.Code
  6658. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6659. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6660. data["secret_key"] = miConfig.SecretKey
  6661. data["url"] = miConfig.Url
  6662. data["ak"] = miConfig.AccessKey
  6663. data["cainfo"] = miConfig.Cainfo
  6664. data["setl_mon"] = setl_mon
  6665. month := time.Unix(1557042972, 0).Format("1")
  6666. year := time.Now().Format("2006")
  6667. month = time.Now().Format("01")
  6668. day := time.Now().Format("02")
  6669. hour := time.Now().Format("15")
  6670. min := time.Now().Format("04")
  6671. sec := time.Now().Format("05")
  6672. fix_fill_date := year + month + day + hour + min + sec
  6673. data["fix_fill_dept"] = miConfig.OrgName
  6674. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6675. data["fix_fill_psn"] = curRoles.UserName
  6676. data["fix_fill_date"] = fix_fill_date
  6677. data["stmt_loc"] = "2"
  6678. data["upld_btch"] = upld_btch
  6679. client := &http.Client{}
  6680. bytesData, _ := json.Marshal(data)
  6681. var req *http.Request
  6682. if miConfig.MdtrtareaAdmvs == "320921" {
  6683. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  6684. } else {
  6685. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  6686. }
  6687. resp, _ := client.Do(req)
  6688. defer resp.Body.Close()
  6689. body, ioErr := ioutil.ReadAll(resp.Body)
  6690. if ioErr != nil {
  6691. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6693. }
  6694. var respJSON map[string]interface{}
  6695. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6696. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6698. }
  6699. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6700. fmt.Println(respJSON)
  6701. result, _ := json.Marshal(respJSON)
  6702. fmt.Println(result)
  6703. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6704. utils.ErrorLog("解析失败:%v", err)
  6705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6706. }
  6707. if result3265.Infcode != "0" {
  6708. c.ServeSuccessJSON(map[string]interface{}{
  6709. "failed_code": -10,
  6710. "msg": result3265.ErrMsg,
  6711. })
  6712. return
  6713. } else {
  6714. c.ServeSuccessJSON(map[string]interface{}{
  6715. "info": result3265.Output,
  6716. })
  6717. return
  6718. }
  6719. }
  6720. func (c *HisApiController) Get3273() {
  6721. admin_user_id, _ := c.GetInt64("admin_user_id")
  6722. startTime := c.GetString("start_time")
  6723. //endTime, _ := c.GetString("end_time")
  6724. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6725. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6726. times := strings.Split(startTime, "-")
  6727. setl_mon := times[0] + times[1]
  6728. var result3265 models.JSResult3264
  6729. data := make(map[string]interface{})
  6730. data["org_name"] = miConfig.OrgName
  6731. data["doctor"] = curRoles.UserName
  6732. data["doctor_name"] = curRoles.UserName
  6733. data["fixmedins_code"] = miConfig.Code
  6734. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6735. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6736. data["secret_key"] = miConfig.SecretKey
  6737. data["url"] = miConfig.Url
  6738. data["ak"] = miConfig.AccessKey
  6739. data["cainfo"] = miConfig.Cainfo
  6740. data["setl_mon"] = setl_mon
  6741. data["stmt_loc"] = "2"
  6742. client := &http.Client{}
  6743. bytesData, _ := json.Marshal(data)
  6744. var req *http.Request
  6745. if miConfig.MdtrtareaAdmvs == "320921" {
  6746. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  6747. } else {
  6748. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  6749. }
  6750. resp, _ := client.Do(req)
  6751. defer resp.Body.Close()
  6752. body, ioErr := ioutil.ReadAll(resp.Body)
  6753. if ioErr != nil {
  6754. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6756. }
  6757. var respJSON map[string]interface{}
  6758. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6761. }
  6762. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6763. fmt.Println(respJSON)
  6764. result, _ := json.Marshal(respJSON)
  6765. fmt.Println(result)
  6766. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6767. utils.ErrorLog("解析失败:%v", err)
  6768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6769. }
  6770. if result3265.Infcode != "0" {
  6771. c.ServeSuccessJSON(map[string]interface{}{
  6772. "failed_code": -10,
  6773. "msg": result3265.ErrMsg,
  6774. })
  6775. return
  6776. } else {
  6777. c.ServeSuccessJSON(map[string]interface{}{
  6778. "info": result3265.Output.Data,
  6779. })
  6780. return
  6781. }
  6782. }
  6783. func (c *HisApiController) Get3274() {
  6784. //if miConfig.MdtrtareaAdmvs == "320921" {
  6785. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6786. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6787. // "&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
  6788. //
  6789. //} else {
  6790. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6791. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6792. // "&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
  6793. //
  6794. //}
  6795. }
  6796. func (c *HisApiController) Get3275() {
  6797. //if miConfig.MdtrtareaAdmvs == "320921" {
  6798. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6799. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6800. // "&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
  6801. //
  6802. //} else {
  6803. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6804. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6805. // "&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
  6806. //
  6807. //}
  6808. }
  6809. func (c *HisApiController) Get3276() {
  6810. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6811. //month := c.GetString("month")
  6812. //
  6813. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6814. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6815. //var api string
  6816. //var res Result5301
  6817. //
  6818. //if miConfig.MdtrtareaAdmvs == "320921" {
  6819. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6820. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  6821. //} else {
  6822. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6823. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  6824. //}
  6825. //
  6826. //resp, requestErr := http.Get(api)
  6827. //if requestErr != nil {
  6828. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6829. // return
  6830. //}
  6831. //
  6832. //body, ioErr := ioutil.ReadAll(resp.Body)
  6833. //if ioErr != nil {
  6834. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6835. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6836. // return
  6837. //}
  6838. //var respJSON map[string]interface{}
  6839. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6840. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6841. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6842. // return
  6843. //}
  6844. //
  6845. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6846. //result, _ := json.Marshal(respJSON)
  6847. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6848. // utils.ErrorLog("解析失败:%v", err)
  6849. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6850. // return
  6851. //}
  6852. }
  6853. func (c *HisApiController) Get3277() {
  6854. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6855. //month := c.GetString("month")
  6856. //
  6857. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6858. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6859. //var api string
  6860. //var res Result5301
  6861. //
  6862. //if miConfig.MdtrtareaAdmvs == "320921" {
  6863. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6864. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  6865. //} else {
  6866. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6867. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  6868. //}
  6869. //
  6870. //resp, requestErr := http.Get(api)
  6871. //if requestErr != nil {
  6872. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6873. // return
  6874. //}
  6875. //
  6876. //body, ioErr := ioutil.ReadAll(resp.Body)
  6877. //if ioErr != nil {
  6878. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6879. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6880. // return
  6881. //}
  6882. //var respJSON map[string]interface{}
  6883. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6884. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6885. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6886. // return
  6887. //}
  6888. //
  6889. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6890. //result, _ := json.Marshal(respJSON)
  6891. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6892. // utils.ErrorLog("解析失败:%v", err)
  6893. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6894. // return
  6895. //}
  6896. }
  6897. func (c *HisApiController) GetCFYLJG001() {
  6898. admin_user_id, _ := c.GetInt64("admin_user_id")
  6899. patient_id, _ := c.GetInt64("patient_id")
  6900. his_patient_id, _ := c.GetInt64("his_patient_id")
  6901. record_time := c.GetString("record_time")
  6902. admin_user_id = 3626
  6903. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6904. psn, _ := service.GetPsnByPatientId(patient_id)
  6905. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6906. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6907. var cFYLJG001 models.CFYLJG001
  6908. timeLayout := "2006-01-02"
  6909. loc, _ := time.LoadLocation("Local")
  6910. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6911. if err != nil {
  6912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6913. return
  6914. }
  6915. recordDateTime := theTime.Unix()
  6916. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  6917. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  6918. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  6919. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  6920. //dept, _ := service.GetDepartMentDetail(info.Departments)
  6921. for _, item := range prescriptions {
  6922. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  6923. if his.IdCardType == 1 {
  6924. bas := strings.Split(psn.CardInfo, "|")
  6925. basNumber := bas[1]
  6926. fmt.Println(basNumber)
  6927. card_sn := bas[3]
  6928. card_no := bas[2]
  6929. cFYLJG001.MdtrtCertType = "03"
  6930. cFYLJG001.CardSn = card_sn
  6931. cFYLJG001.MdtrtCertNo = card_no
  6932. cFYLJG001.EcToken = ""
  6933. cFYLJG001.AuthNo = ""
  6934. } else if his.IdCardType == 2 {
  6935. cFYLJG001.MdtrtCertType = "02"
  6936. cFYLJG001.CardSn = ""
  6937. cFYLJG001.MdtrtCertNo = his.IdCardNo
  6938. cFYLJG001.EcToken = ""
  6939. cFYLJG001.AuthNo = ""
  6940. } else if his.IdCardType == 4 {
  6941. cFYLJG001.MdtrtCertType = "01"
  6942. cFYLJG001.CardSn = ""
  6943. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  6944. cFYLJG001.EcToken = psn.VerifyNumber
  6945. cFYLJG001.AuthNo = ""
  6946. }
  6947. cFYLJG001.BizTypeCode = "01"
  6948. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  6949. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  6950. cFYLJG001.RxTypeCode = "1"
  6951. tempTime := time.Unix(item.PreTime, 0)
  6952. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  6953. cFYLJG001.PrscTime = timeFormatOne
  6954. var count float64
  6955. if item.Type == 1 {
  6956. for _, sumItem := range item.HisDoctorAdviceInfo {
  6957. count = count + sumItem.PrescribingNumber
  6958. }
  6959. }
  6960. cFYLJG001.RxDrugCnt = count
  6961. cFYLJG001.ValiDays = "5"
  6962. ts := time.Unix(item.PreTime, 0)
  6963. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  6964. tempTime3 := time.Unix(record_time2, 0)
  6965. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  6966. cFYLJG001.ValiEndTime = timeFormat3
  6967. cFYLJG001.RxCotnFlag = "0"
  6968. for _, subItem := range item.HisDoctorAdviceInfo {
  6969. var drug models.RxDrug
  6970. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  6971. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  6972. drug.RxItemTypeCode = "11"
  6973. drug.DrugDosform = "乳膏剂" //TODO
  6974. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  6975. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6976. }
  6977. drug.MedcWayDscr = subItem.DeliveryWay
  6978. tempTime2 := time.Unix(subItem.StartTime, 0)
  6979. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  6980. drug.MedcBegntime = timeFormatTwo
  6981. if subItem.Day > 0 {
  6982. ts := time.Unix(subItem.StartTime, 0)
  6983. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  6984. tempTime4 := time.Unix(record_time, 0)
  6985. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  6986. drug.MedcEndtime = timeFormat5
  6987. } else {
  6988. tempTime2 := time.Unix(subItem.StartTime, 0)
  6989. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  6990. drug.MedcEndtime = timeFormatTwo
  6991. }
  6992. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  6993. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  6994. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  6995. drug.DrugCnt = subItem.PrescribingNumber
  6996. drug.DrugDosunt = subItem.PrescribingNumberUnit
  6997. drug.DrugGenname = subItem.AdviceName
  6998. drug.MedcWayCodg = subItem.DeliveryWay
  6999. //drug.DrugTotlcnt = subItem.PrescribingNumber
  7000. drug.SinDoscnt = subItem.SingleDose
  7001. drug.SinDosunt = subItem.SingleDoseUnit
  7002. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7003. drug.UsedFrquName = subItem.ExecutionFrequency
  7004. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7005. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7006. drug.HospApprFlag = "1"
  7007. cFYLJG001.List = append(cFYLJG001.List, drug)
  7008. }
  7009. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7010. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  7011. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7012. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7013. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7014. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7015. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7016. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7017. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7018. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7019. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7020. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7021. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7022. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7023. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7024. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7025. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7026. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7027. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7028. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7029. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7030. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7031. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7032. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7033. tempTime2 := time.Now().Unix()
  7034. tempTime6 := time.Unix(tempTime2, 0)
  7035. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7036. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7037. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  7038. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7039. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  7040. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  7041. //memo := make(map[string]interface{})
  7042. //inputData := make(map[string]interface{}, 0)
  7043. //type MyData struct {
  7044. // Insutype string `json:"insutype"`
  7045. //}
  7046. //
  7047. // data := MyData{
  7048. // Insutype: his.Insutype,
  7049. //}
  7050. //
  7051. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7052. var config []*models.HisXtDiagnoseConfig
  7053. for _, item := range diagnosis_ids {
  7054. id, _ := strconv.ParseInt(item, 10, 64)
  7055. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7056. config = append(config, &diagnosisConfig)
  7057. }
  7058. for index, subitem := range config {
  7059. if index == 0 {
  7060. var dia models.DiseInfo
  7061. dia.DiagType = "1"
  7062. dia.MaindiagFlag = "1"
  7063. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7064. dia.DiagCode = subitem.CountryCode
  7065. dia.DiagName = subitem.ClassName
  7066. dia.DiagDept = "肾内科"
  7067. dia.DiagDrNo = doctor.DoctorNumber
  7068. dia.DiagDrName = doctor.UserName
  7069. tempTime3 := time.Unix(item.PreTime, 0)
  7070. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7071. dia.DiagTime = timeFormatTwo
  7072. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7073. } else {
  7074. var dia models.DiseInfo
  7075. dia.DiagType = "1"
  7076. dia.MaindiagFlag = "0"
  7077. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7078. dia.DiagCode = subitem.CountryCode
  7079. dia.DiagName = subitem.ClassName
  7080. dia.DiagDept = "肾内科"
  7081. dia.DiagDrNo = doctor.DoctorNumber
  7082. dia.DiagDrName = doctor.UserName
  7083. tempTime3 := time.Unix(item.PreTime, 0)
  7084. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7085. dia.DiagTime = timeFormatTwo
  7086. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7087. }
  7088. }
  7089. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  7090. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  7091. var res ResultCFYLJG001
  7092. var respJSON2 map[string]interface{}
  7093. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7094. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7096. return
  7097. }
  7098. userJSONBytes2, _ := json.Marshal(respJSON2)
  7099. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7100. utils.ErrorLog("解析失败:%v", err)
  7101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7102. return
  7103. }
  7104. if res.Infcode == -1 {
  7105. c.ServeSuccessJSON(map[string]interface{}{
  7106. "failed_code": -10,
  7107. "msg": res.ErrMsg,
  7108. })
  7109. return
  7110. } else {
  7111. var flow models.HisPrescriptionFlow
  7112. flow.Ctime = time.Now().Unix()
  7113. flow.SignDigest = ""
  7114. flow.RxTraceCode = res.Output.RxTraceCode
  7115. flow.HiRxno = res.Output.HiRxno
  7116. flow.MID = his.Number
  7117. flow.Status = 1
  7118. flow.DCode = doctor_info.DoctorNumber
  7119. flow.OriginalRxFile = ""
  7120. flow.OriginalValue = ""
  7121. flow.SignCertDn = ""
  7122. flow.UserOrgId = 10454
  7123. flow.SignCertSn = ""
  7124. flow.Mtime = time.Now().Unix()
  7125. service.Createflow(&flow)
  7126. c.ServeSuccessJSON(map[string]interface{}{
  7127. "msg": "上传成功",
  7128. })
  7129. }
  7130. }
  7131. }
  7132. func (c *HisApiController) GetCFYLJG002() {
  7133. admin_user_id, _ := c.GetInt64("admin_user_id")
  7134. his_patient_id, _ := c.GetInt64("his_patient_id")
  7135. record_time := c.GetString("record_time")
  7136. admin_user_id = 3626
  7137. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7138. //id, _ := c.GetInt64("id")
  7139. admin_user_id = 3626
  7140. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7141. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7142. flow, _ := service.Getflowtwo(his.Number)
  7143. //his, _ := service.GetHisPatientByNumber(flow.MID)
  7144. //record_time := c.GetString("record_time")
  7145. patient_id, _ := c.GetInt64("patient_id")
  7146. //patient_id = 23834
  7147. //record_time = "2023-09-18"
  7148. timeLayout := "2006-01-02"
  7149. loc, _ := time.LoadLocation("Local")
  7150. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7151. if err != nil {
  7152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7153. return
  7154. }
  7155. recordDateTime := theTime.Unix()
  7156. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7157. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7158. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7159. dept, _ := service.GetDepartMentDetail(info.Departments)
  7160. inputData := make(map[string]interface{})
  7161. inputData["rxTraceCode"] = flow.RxTraceCode
  7162. inputData["hiRxno"] = flow.HiRxno
  7163. inputData["mdtrtId"] = flow.MID
  7164. inputData["patnName"] = his.PsnName
  7165. inputData["psnCertType"] = his.PsnCertType
  7166. inputData["certno"] = his.Certno
  7167. inputData["fixmedinsName"] = miConfig.OrgName
  7168. inputData["fixmedinsCode"] = miConfig.Code
  7169. inputData["drCode"] = doctor_info.DoctorNumber
  7170. inputData["prscDrName"] = doctor_info.UserName
  7171. inputData["pharDeptName"] = dept.Name
  7172. inputData["pharDeptCode"] = dept.Number
  7173. inputData["pharProfttlCodg"] = dept.Name
  7174. inputData["pharProfttlName"] = ""
  7175. inputData["pharCode"] = "HY440309002107"
  7176. inputData["pharCertType"] = "01"
  7177. inputData["pharCertno"] = "430482199408260023"
  7178. inputData["pharName"] = "彭斯遥"
  7179. inputData["pharPracCertNo"] = ""
  7180. tempTime2 := time.Unix(info.Ctime, 0)
  7181. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7182. inputData["pharChkTime"] = timeFormatTwo
  7183. bytesData, _ := json.Marshal(inputData)
  7184. fmt.Println(string(bytesData))
  7185. encoded := base64.StdEncoding.EncodeToString(bytesData)
  7186. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  7187. if err != nil {
  7188. fmt.Println("Error reading PDF file:", err)
  7189. return
  7190. }
  7191. // 将 PDF 文件内容进行 Base64 编码
  7192. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  7193. fmt.Println(err)
  7194. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7195. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  7196. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7197. var res2 Result002
  7198. var respJSON2 map[string]interface{}
  7199. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7202. return
  7203. }
  7204. userJSONBytes2, _ := json.Marshal(respJSON2)
  7205. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7206. utils.ErrorLog("解析失败:%v", err)
  7207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7208. return
  7209. }
  7210. if res2.Infcode == 0 {
  7211. flow.Ctime = time.Now().Unix()
  7212. flow.SignDigest = res2.Output.SignDigest
  7213. flow.RxFile = res2.Output.RxFile
  7214. flow.MID = his.Number
  7215. flow.Status = 1
  7216. flow.DCode = doctor_info.DoctorNumber
  7217. flow.OriginalRxFile = rx_encoded
  7218. flow.OriginalValue = encoded
  7219. flow.SignCertDn = res2.Output.SignCertDn
  7220. flow.SignCertSn = res2.Output.SignCertSn
  7221. flow.Mtime = time.Now().Unix()
  7222. service.Saveflow(flow)
  7223. c.ServeSuccessJSON(map[string]interface{}{
  7224. "msg": "预签名成功",
  7225. })
  7226. } else {
  7227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7228. return
  7229. }
  7230. }
  7231. func (c *HisApiController) GetCFYLJG003() {
  7232. admin_user_id, _ := c.GetInt64("admin_user_id")
  7233. his_patient_id, _ := c.GetInt64("his_patient_id")
  7234. record_time := c.GetString("record_time")
  7235. admin_user_id = 3626
  7236. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7237. //id, _ := c.GetInt64("id")
  7238. admin_user_id = 3626
  7239. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7240. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7241. flow, _ := service.Getflowtwo(his.Number)
  7242. //id = 3
  7243. patient_id, _ := c.GetInt64("patient_id")
  7244. //patient_id = 23834
  7245. //record_time = "2023-09-18"
  7246. timeLayout := "2006-01-02"
  7247. loc, _ := time.LoadLocation("Local")
  7248. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7249. if err != nil {
  7250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7251. return
  7252. }
  7253. recordDateTime := theTime.Unix()
  7254. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7255. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7256. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7257. dept, _ := service.GetDepartMentDetail(info.Departments)
  7258. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  7259. var cFYLJG003 models.CFYLJG003
  7260. cFYLJG003.RxTraceCode = flow.RxTraceCode
  7261. cFYLJG003.HiRxno = flow.HiRxno
  7262. cFYLJG003.MdtrtID = flow.MID
  7263. cFYLJG003.PatnName = his.Name
  7264. cFYLJG003.Certno = his.Certno
  7265. cFYLJG003.FixmedinsName = miConfig.OrgName
  7266. cFYLJG003.FixmedinsCode = miConfig.Code
  7267. cFYLJG003.DrCode = doctor_info.DoctorNumber
  7268. cFYLJG003.PrscDrName = doctor_info.UserName
  7269. cFYLJG003.PharDeptName = dept.Name
  7270. cFYLJG003.PharDeptCode = dept.Number
  7271. cFYLJG003.PharCode = "HY440309002107"
  7272. cFYLJG003.PharCertType = "01"
  7273. cFYLJG003.PharCertno = "430482199408260023"
  7274. cFYLJG003.PharName = "彭斯遥"
  7275. cFYLJG003.PsnCertType = "01"
  7276. cFYLJG003.RxFile = flow.RxFile
  7277. cFYLJG003.SignDigest = flow.SignDigest
  7278. cFYLJG003.FixmedinsCode = miConfig.Code
  7279. cFYLJG003.PsnCertType = "01"
  7280. cFYLJG003.PharProfttlCodg = dept.Name
  7281. //inputData["pharProfttlCodg"] =dept.Name
  7282. tempTime2 := time.Unix(info.Ctime, 0)
  7283. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7284. cFYLJG003.PharChkTime = timeFormatTwo
  7285. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7286. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  7287. var res ResultCFYLJG003
  7288. var respJSON2 map[string]interface{}
  7289. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7290. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7292. return
  7293. }
  7294. userJSONBytes2, _ := json.Marshal(respJSON2)
  7295. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7296. utils.ErrorLog("解析失败:%v", err)
  7297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7298. return
  7299. }
  7300. if res.Infcode == -1 {
  7301. c.ServeSuccessJSON(map[string]interface{}{
  7302. "failed_code": -10,
  7303. "msg": res.ErrMsg,
  7304. })
  7305. return
  7306. } else {
  7307. c.ServeSuccessJSON(map[string]interface{}{
  7308. "info": res.Output,
  7309. })
  7310. }
  7311. }
  7312. func (c *HisApiController) GetCFYLJG004() {
  7313. admin_user_id, _ := c.GetInt64("admin_user_id")
  7314. his_patient_id, _ := c.GetInt64("his_patient_id")
  7315. record_time := c.GetString("record_time")
  7316. admin_user_id = 3626
  7317. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7318. //id, _ := c.GetInt64("id")
  7319. admin_user_id = 3626
  7320. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7321. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7322. flow, _ := service.Getflowtwo(his.Number)
  7323. //id = 3
  7324. patient_id, _ := c.GetInt64("patient_id")
  7325. //patient_id = 23834
  7326. //record_time = "2023-09-18"
  7327. timeLayout := "2006-01-02"
  7328. loc, _ := time.LoadLocation("Local")
  7329. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7330. if err != nil {
  7331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7332. return
  7333. }
  7334. recordDateTime := theTime.Unix()
  7335. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7336. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7337. var cFYLJG004 models.CFYLJG004
  7338. cFYLJG004.HiRxno = flow.HiRxno
  7339. cFYLJG004.FixmedinsCode = miConfig.Code
  7340. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  7341. cFYLJG004.UndoDrCertType = "01"
  7342. cFYLJG004.UndoRea = "撤销处方"
  7343. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  7344. cFYLJG004.UndoDrName = doctor_info.UserName
  7345. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  7346. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  7347. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  7348. var res ResultCFYLJG004
  7349. var respJSON2 map[string]interface{}
  7350. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7351. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7353. return
  7354. }
  7355. userJSONBytes2, _ := json.Marshal(respJSON2)
  7356. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7357. utils.ErrorLog("解析失败:%v", err)
  7358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7359. return
  7360. }
  7361. if res.Infcode == -1 {
  7362. c.ServeSuccessJSON(map[string]interface{}{
  7363. "failed_code": -10,
  7364. "msg": res.ErrMsg,
  7365. })
  7366. return
  7367. } else {
  7368. flow.Status = 0
  7369. service.Saveflow(flow)
  7370. c.ServeSuccessJSON(map[string]interface{}{
  7371. "msg": "撤销成功",
  7372. })
  7373. return
  7374. }
  7375. }
  7376. func (c *HisApiController) GetCFYLJG005() {
  7377. admin_user_id, _ := c.GetInt64("admin_user_id")
  7378. his_patient_id, _ := c.GetInt64("his_patient_id")
  7379. //record_time := c.GetString("record_time")
  7380. admin_user_id = 3626
  7381. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7382. //id, _ := c.GetInt64("id")
  7383. admin_user_id = 3626
  7384. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7385. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7386. flow, _ := service.Getflowtwo(his.Number)
  7387. //id = 3
  7388. var cFYLJG005 models.CFYLJG005
  7389. //patient_id, _ := c.GetInt64("patient_id")
  7390. cFYLJG005.HiRxno = flow.HiRxno
  7391. cFYLJG005.MdtrtID = flow.MID
  7392. cFYLJG005.EcToken = ""
  7393. cFYLJG005.PsnName = his.Name
  7394. cFYLJG005.PsnCertType = "01"
  7395. cFYLJG005.Certno = his.IdCardNo
  7396. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7397. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7398. var res ResultCFYLJG005
  7399. var respJSON2 map[string]interface{}
  7400. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7401. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7403. return
  7404. }
  7405. userJSONBytes2, _ := json.Marshal(respJSON2)
  7406. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7407. utils.ErrorLog("解析失败:%v", err)
  7408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7409. return
  7410. }
  7411. if res.Infcode == -1 {
  7412. c.ServeSuccessJSON(map[string]interface{}{
  7413. "failed_code": -10,
  7414. "msg": res.ErrMsg,
  7415. })
  7416. return
  7417. } else {
  7418. c.ServeSuccessJSON(map[string]interface{}{
  7419. "info": res.Output,
  7420. })
  7421. return
  7422. }
  7423. }
  7424. func (c *HisApiController) GetCFYLJG006() {
  7425. admin_user_id, _ := c.GetInt64("admin_user_id")
  7426. his_patient_id, _ := c.GetInt64("his_patient_id")
  7427. admin_user_id = 3626
  7428. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7429. //id, _ := c.GetInt64("id")
  7430. admin_user_id = 3626
  7431. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7432. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7433. flow, _ := service.Getflowtwo(his.Number)
  7434. //id = 3
  7435. patient_id, _ := c.GetInt64("patient_id")
  7436. var cFYLJG006 models.CFYLJG006
  7437. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  7438. cFYLJG006.HiRxno = flow.HiRxno
  7439. cFYLJG006.MdtrtID = flow.MID
  7440. cFYLJG006.PsnName = patient.Name
  7441. cFYLJG006.PsnCertType = "01"
  7442. cFYLJG006.Certno = patient.IdCardNo
  7443. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  7444. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  7445. var res ResultCFYLJG006
  7446. var respJSON2 map[string]interface{}
  7447. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7448. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7450. return
  7451. }
  7452. userJSONBytes2, _ := json.Marshal(respJSON2)
  7453. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7454. utils.ErrorLog("解析失败:%v", err)
  7455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7456. return
  7457. }
  7458. if res.Infcode == -1 {
  7459. c.ServeSuccessJSON(map[string]interface{}{
  7460. "failed_code": -10,
  7461. "msg": res.ErrMsg,
  7462. })
  7463. return
  7464. } else {
  7465. c.ServeSuccessJSON(map[string]interface{}{
  7466. "info": res.Output,
  7467. })
  7468. return
  7469. }
  7470. }
  7471. func (c *HisApiController) GetCFYLJG007() {
  7472. admin_user_id, _ := c.GetInt64("admin_user_id")
  7473. his_patient_id, _ := c.GetInt64("his_patient_id")
  7474. admin_user_id = 3626
  7475. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7476. //id, _ := c.GetInt64("id")
  7477. admin_user_id = 3626
  7478. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7479. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7480. flow, _ := service.Getflowtwo(his.Number)
  7481. //id = 3
  7482. patient_id, _ := c.GetInt64("patient_id")
  7483. var cFYLJG007 models.CFYLJG007
  7484. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  7485. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7486. cFYLJG007.HiRxno = flow.HiRxno
  7487. cFYLJG007.MdtrtID = flow.MID
  7488. cFYLJG007.PsnNo = his.PsnNo
  7489. cFYLJG007.PsnCertType = "01"
  7490. cFYLJG007.Certno = patient.IdCardNo
  7491. cFYLJG007.PsnName = patient.Name
  7492. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  7493. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  7494. var res ResultCFYLJG007
  7495. var respJSON2 map[string]interface{}
  7496. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7497. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7499. return
  7500. }
  7501. userJSONBytes2, _ := json.Marshal(respJSON2)
  7502. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7503. utils.ErrorLog("解析失败:%v", err)
  7504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7505. return
  7506. }
  7507. if res.Infcode == -1 {
  7508. c.ServeSuccessJSON(map[string]interface{}{
  7509. "failed_code": -10,
  7510. "msg": res.ErrMsg,
  7511. })
  7512. return
  7513. } else {
  7514. c.ServeSuccessJSON(map[string]interface{}{
  7515. "info": res,
  7516. })
  7517. return
  7518. }
  7519. }
  7520. func (c *HisApiController) GetCFYLJG008() {
  7521. admin_user_id, _ := c.GetInt64("admin_user_id")
  7522. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7523. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7524. var cFYLJG008 models.CFYLJG008
  7525. //id, _ := c.GetInt64("id")
  7526. patient_id, _ := c.GetInt64("patient_id")
  7527. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7528. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7529. //id = 3
  7530. //flow, _ := service.Getflow(id)
  7531. //his, _ := service.GetHisPatientByNumber(flow.MID)
  7532. //
  7533. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7534. //patient_id, _ := c.GetInt64("patient_id")
  7535. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7536. record_time := c.GetString("record_time")
  7537. admin_user_id = 3626
  7538. patient_id = 19424
  7539. //his_patient_id = 263947
  7540. record_time = "2023-08-29"
  7541. timeLayout := "2006-01-02"
  7542. loc, _ := time.LoadLocation("Local")
  7543. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7544. if err != nil {
  7545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7546. return
  7547. }
  7548. recordDateTime := theTime.Unix()
  7549. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7550. cFYLJG008.FixmedinsName = ""
  7551. cFYLJG008.Lat = ""
  7552. cFYLJG008.Lng = ""
  7553. cFYLJG008.OrderType = "1"
  7554. cFYLJG008.PoolareaNo = ""
  7555. cFYLJG008.Lng = ""
  7556. cFYLJG008.PageNum = 1
  7557. cFYLJG008.PageSize = 10
  7558. var MPI models.MedinsProdInvChgDDTO
  7559. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  7560. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  7561. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  7562. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  7563. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  7564. var res ResultCFYLJG008
  7565. var respJSON2 map[string]interface{}
  7566. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7569. return
  7570. }
  7571. userJSONBytes2, _ := json.Marshal(respJSON2)
  7572. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7573. utils.ErrorLog("解析失败:%v", err)
  7574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7575. return
  7576. }
  7577. if res.Infcode == -1 {
  7578. c.ServeSuccessJSON(map[string]interface{}{
  7579. "failed_code": -10,
  7580. "msg": res.ErrMsg,
  7581. })
  7582. return
  7583. } else {
  7584. c.ServeSuccessJSON(map[string]interface{}{
  7585. "info": res.Output,
  7586. })
  7587. return
  7588. }
  7589. }
  7590. func (c *HisApiController) GetBL4201A() {
  7591. order_id, _ := c.GetInt64("order_id")
  7592. admin_user_id, _ := c.GetInt64("admin_user_id")
  7593. order, _ := service.GetHisOrderByIDTwo(order_id)
  7594. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7595. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  7596. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  7597. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7598. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7599. department, _ := service.GetDepartMentDetail(his.Departments)
  7600. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  7601. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  7602. if order.ID == 0 {
  7603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  7604. return
  7605. }
  7606. var struct4201A models.Struct4201A
  7607. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  7608. for _, items := range order_info {
  7609. memo := make(map[string]interface{})
  7610. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  7611. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  7612. fsiOPFLD.MedType = "14"
  7613. fsiOPFLD.BkkpSn = items.FeedetlSn
  7614. fsiOPFLD.FixmedinsCode = miConfig.Code
  7615. fsiOPFLD.FixmedinsName = miConfig.OrgName
  7616. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  7617. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  7618. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  7619. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7620. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  7621. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7622. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7623. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7624. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7625. fsiOPFLD.BilgDeptName = department.Name
  7626. fsiOPFLD.BilgDeptCodg = department.Number
  7627. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7628. fsiOPFLD.BilgDrName = doctor.UserName
  7629. fsiOPFLD.MedChrgitmType = "09"
  7630. memo["hosp_appr_flag"] = "1"
  7631. memo["invoice_no"] = order.MdtrtId
  7632. memo["memo"] = "自费"
  7633. bytesData, _ := json.Marshal(memo)
  7634. fsiOPFLD.Memo = string(bytesData)
  7635. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7636. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  7637. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  7638. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7639. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7640. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7641. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  7642. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  7643. fsiOPFLD.BilgDeptName = department.Name
  7644. fsiOPFLD.BilgDeptCodg = department.Number
  7645. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7646. fsiOPFLD.BilgDrName = doctor.UserName
  7647. switch items.HisPrescriptionProject.HisProject.CostClassify {
  7648. case 0:
  7649. break
  7650. case 1:
  7651. fsiOPFLD.MedChrgitmType = "14"
  7652. break
  7653. case 2:
  7654. fsiOPFLD.MedChrgitmType = "05"
  7655. break
  7656. case 3:
  7657. fsiOPFLD.MedChrgitmType = "03"
  7658. break
  7659. case 4:
  7660. fsiOPFLD.MedChrgitmType = "03"
  7661. break
  7662. case 5:
  7663. fsiOPFLD.MedChrgitmType = "08"
  7664. break
  7665. case 6:
  7666. fsiOPFLD.MedChrgitmType = "14"
  7667. break
  7668. case 7:
  7669. fsiOPFLD.MedChrgitmType = "14"
  7670. break
  7671. case 8:
  7672. fsiOPFLD.MedChrgitmType = "03"
  7673. break
  7674. case 9:
  7675. fsiOPFLD.MedChrgitmType = "14"
  7676. break
  7677. case 10:
  7678. fsiOPFLD.MedChrgitmType = "14"
  7679. break
  7680. case 11:
  7681. fsiOPFLD.MedChrgitmType = "06"
  7682. break
  7683. case 12:
  7684. fsiOPFLD.MedChrgitmType = "12"
  7685. break
  7686. case 13:
  7687. fsiOPFLD.MedChrgitmType = "01"
  7688. break
  7689. case 14:
  7690. fsiOPFLD.MedChrgitmType = "04"
  7691. break
  7692. case 15:
  7693. fsiOPFLD.MedChrgitmType = "14"
  7694. break
  7695. }
  7696. memo["hosp_appr_flag"] = "1"
  7697. memo["invoice_no"] = order.MdtrtId
  7698. memo["memo"] = "自费"
  7699. bytesData, _ := json.Marshal(memo)
  7700. fsiOPFLD.Memo = string(bytesData)
  7701. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7702. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  7703. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7704. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7705. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7706. fsiOPFLD.BilgDeptName = department.Name
  7707. fsiOPFLD.BilgDeptCodg = department.Number
  7708. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7709. fsiOPFLD.BilgDrName = doctor.UserName
  7710. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  7711. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  7712. fsiOPFLD.MedChrgitmType = "08"
  7713. memo["hosp_appr_flag"] = "1"
  7714. memo["invoice_no"] = order.MdtrtId
  7715. memo["memo"] = "自费"
  7716. bytesData, _ := json.Marshal(memo)
  7717. fsiOPFLD.Memo = string(bytesData)
  7718. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7719. }
  7720. }
  7721. }
  7722. for _, items := range order_info_two {
  7723. memo := make(map[string]interface{})
  7724. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  7725. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  7726. fsiOPFLD.MedType = "14"
  7727. fsiOPFLD.BkkpSn = items.FeedetlSn
  7728. fsiOPFLD.FixmedinsCode = miConfig.Code
  7729. fsiOPFLD.FixmedinsName = miConfig.OrgName
  7730. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  7731. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  7732. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  7733. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7734. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  7735. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7736. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7737. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7738. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7739. fsiOPFLD.BilgDeptName = department.Name
  7740. fsiOPFLD.BilgDeptCodg = department.Number
  7741. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7742. fsiOPFLD.BilgDrName = doctor.UserName
  7743. fsiOPFLD.MedChrgitmType = "09"
  7744. memo["hosp_appr_flag"] = "1"
  7745. memo["invoice_no"] = order.MdtrtId
  7746. memo["memo"] = "自费"
  7747. bytesData, _ := json.Marshal(memo)
  7748. fsiOPFLD.Memo = string(bytesData)
  7749. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7750. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  7751. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  7752. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7753. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7754. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  7755. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  7756. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7757. fsiOPFLD.BilgDeptName = department.Name
  7758. fsiOPFLD.BilgDeptCodg = department.Number
  7759. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7760. fsiOPFLD.BilgDrName = doctor.UserName
  7761. switch items.HisPrescriptionProject.HisProject.CostClassify {
  7762. case 0:
  7763. break
  7764. case 1:
  7765. fsiOPFLD.MedChrgitmType = "14"
  7766. break
  7767. case 2:
  7768. fsiOPFLD.MedChrgitmType = "05"
  7769. break
  7770. case 3:
  7771. fsiOPFLD.MedChrgitmType = "03"
  7772. break
  7773. case 4:
  7774. fsiOPFLD.MedChrgitmType = "03"
  7775. break
  7776. case 5:
  7777. fsiOPFLD.MedChrgitmType = "08"
  7778. break
  7779. case 6:
  7780. fsiOPFLD.MedChrgitmType = "14"
  7781. break
  7782. case 7:
  7783. fsiOPFLD.MedChrgitmType = "14"
  7784. break
  7785. case 8:
  7786. fsiOPFLD.MedChrgitmType = "03"
  7787. break
  7788. case 9:
  7789. fsiOPFLD.MedChrgitmType = "14"
  7790. break
  7791. case 10:
  7792. fsiOPFLD.MedChrgitmType = "14"
  7793. break
  7794. case 11:
  7795. fsiOPFLD.MedChrgitmType = "06"
  7796. break
  7797. case 12:
  7798. fsiOPFLD.MedChrgitmType = "12"
  7799. break
  7800. case 13:
  7801. fsiOPFLD.MedChrgitmType = "01"
  7802. break
  7803. case 14:
  7804. fsiOPFLD.MedChrgitmType = "04"
  7805. break
  7806. case 15:
  7807. fsiOPFLD.MedChrgitmType = "14"
  7808. break
  7809. }
  7810. memo["hosp_appr_flag"] = "1"
  7811. memo["invoice_no"] = order.MdtrtId
  7812. memo["memo"] = "自费"
  7813. bytesData, _ := json.Marshal(memo)
  7814. fsiOPFLD.Memo = string(bytesData)
  7815. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7816. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  7817. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7818. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7819. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7820. fsiOPFLD.BilgDeptName = department.Name
  7821. fsiOPFLD.BilgDeptCodg = department.Number
  7822. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7823. fsiOPFLD.BilgDrName = doctor.UserName
  7824. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  7825. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  7826. fsiOPFLD.MedChrgitmType = "08"
  7827. memo["hosp_appr_flag"] = "1"
  7828. memo["invoice_no"] = order.MdtrtId
  7829. memo["memo"] = "自费"
  7830. bytesData, _ := json.Marshal(memo)
  7831. fsiOPFLD.Memo = string(bytesData)
  7832. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7833. }
  7834. }
  7835. }
  7836. fmt.Println(fsiOPFLDs)
  7837. struct4201A.Fopfd = fsiOPFLDs
  7838. fmt.Println(struct4201A.Fopfd)
  7839. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  7840. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  7841. var res2 ResultSix
  7842. var respJSON2 map[string]interface{}
  7843. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7844. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7846. return
  7847. }
  7848. userJSONBytes2, _ := json.Marshal(respJSON2)
  7849. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7850. utils.ErrorLog("解析失败:%v", err)
  7851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7852. return
  7853. }
  7854. if res2.Infcode != 0 {
  7855. c.ServeSuccessJSON(map[string]interface{}{
  7856. "failed_code": -10,
  7857. "msg": res2.ErrMsg,
  7858. })
  7859. return
  7860. } else {
  7861. order.IsUploadOrderInfo = 1
  7862. service.UpdateOrder(order)
  7863. c.ServeSuccessJSON(map[string]interface{}{
  7864. "msg": "上传成功",
  7865. })
  7866. }
  7867. }
  7868. func (c *HisApiController) Get2505() {
  7869. admin_user_id, _ := c.GetInt64("admin_user_id")
  7870. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  7871. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7872. 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)
  7873. }
  7874. func (c *HisApiController) Get4201A() {
  7875. order_id, _ := c.GetInt64("order_id")
  7876. admin_user_id, _ := c.GetInt64("admin_user_id")
  7877. order, _ := service.GetHisOrderByIDTwo(order_id)
  7878. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7879. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  7880. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  7881. //order_info = append(order_info, order_info_two...)
  7882. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7883. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7884. department, _ := service.GetDepartMentDetail(his.Departments)
  7885. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  7886. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  7887. if order.ID == 0 {
  7888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  7889. return
  7890. }
  7891. var struct4201A models.Struct4201A
  7892. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  7893. for _, items := range order_info {
  7894. memo := make(map[string]interface{})
  7895. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  7896. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  7897. fsiOPFLD.MedType = "14"
  7898. fsiOPFLD.BkkpSn = items.FeedetlSn
  7899. fsiOPFLD.FixmedinsCode = miConfig.Code
  7900. fsiOPFLD.FixmedinsName = miConfig.OrgName
  7901. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  7902. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  7903. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  7904. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7905. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  7906. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7907. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7908. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7909. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7910. fsiOPFLD.BilgDeptName = department.Name
  7911. fsiOPFLD.BilgDeptCodg = department.Number
  7912. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7913. fsiOPFLD.BilgDrName = doctor.UserName
  7914. fsiOPFLD.MedChrgitmType = "09"
  7915. memo["hosp_appr_flag"] = "1"
  7916. memo["invoice_no"] = order.MdtrtId
  7917. memo["memo"] = "自费"
  7918. bytesData, _ := json.Marshal(memo)
  7919. fsiOPFLD.Memo = string(bytesData)
  7920. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7921. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  7922. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  7923. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7924. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7925. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7926. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  7927. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  7928. fsiOPFLD.BilgDeptName = department.Name
  7929. fsiOPFLD.BilgDeptCodg = department.Number
  7930. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7931. fsiOPFLD.BilgDrName = doctor.UserName
  7932. switch items.HisPrescriptionProject.HisProject.CostClassify {
  7933. case 0:
  7934. break
  7935. case 1:
  7936. fsiOPFLD.MedChrgitmType = "14"
  7937. break
  7938. case 2:
  7939. fsiOPFLD.MedChrgitmType = "05"
  7940. break
  7941. case 3:
  7942. fsiOPFLD.MedChrgitmType = "03"
  7943. break
  7944. case 4:
  7945. fsiOPFLD.MedChrgitmType = "03"
  7946. break
  7947. case 5:
  7948. fsiOPFLD.MedChrgitmType = "08"
  7949. break
  7950. case 6:
  7951. fsiOPFLD.MedChrgitmType = "14"
  7952. break
  7953. case 7:
  7954. fsiOPFLD.MedChrgitmType = "14"
  7955. break
  7956. case 8:
  7957. fsiOPFLD.MedChrgitmType = "03"
  7958. break
  7959. case 9:
  7960. fsiOPFLD.MedChrgitmType = "14"
  7961. break
  7962. case 10:
  7963. fsiOPFLD.MedChrgitmType = "14"
  7964. break
  7965. case 11:
  7966. fsiOPFLD.MedChrgitmType = "06"
  7967. break
  7968. case 12:
  7969. fsiOPFLD.MedChrgitmType = "12"
  7970. break
  7971. case 13:
  7972. fsiOPFLD.MedChrgitmType = "01"
  7973. break
  7974. case 14:
  7975. fsiOPFLD.MedChrgitmType = "04"
  7976. break
  7977. case 15:
  7978. fsiOPFLD.MedChrgitmType = "14"
  7979. break
  7980. }
  7981. memo["hosp_appr_flag"] = "1"
  7982. memo["invoice_no"] = order.MdtrtId
  7983. memo["memo"] = "自费"
  7984. bytesData, _ := json.Marshal(memo)
  7985. fsiOPFLD.Memo = string(bytesData)
  7986. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7987. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  7988. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7989. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7990. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7991. fsiOPFLD.BilgDeptName = department.Name
  7992. fsiOPFLD.BilgDeptCodg = department.Number
  7993. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7994. fsiOPFLD.BilgDrName = doctor.UserName
  7995. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  7996. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  7997. fsiOPFLD.MedChrgitmType = "08"
  7998. memo["hosp_appr_flag"] = "1"
  7999. memo["invoice_no"] = order.MdtrtId
  8000. memo["memo"] = "自费"
  8001. bytesData, _ := json.Marshal(memo)
  8002. fsiOPFLD.Memo = string(bytesData)
  8003. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8004. }
  8005. }
  8006. }
  8007. for _, items := range order_info_two {
  8008. memo := make(map[string]interface{})
  8009. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8010. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8011. fsiOPFLD.MedType = "14"
  8012. fsiOPFLD.BkkpSn = items.FeedetlSn
  8013. fsiOPFLD.FixmedinsCode = miConfig.Code
  8014. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8015. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8016. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8017. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8018. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8019. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8020. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8021. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8022. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8023. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8024. fsiOPFLD.BilgDeptName = department.Name
  8025. fsiOPFLD.BilgDeptCodg = department.Number
  8026. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8027. fsiOPFLD.BilgDrName = doctor.UserName
  8028. fsiOPFLD.MedChrgitmType = "09"
  8029. memo["hosp_appr_flag"] = "1"
  8030. memo["invoice_no"] = order.MdtrtId
  8031. memo["memo"] = "自费"
  8032. bytesData, _ := json.Marshal(memo)
  8033. fsiOPFLD.Memo = string(bytesData)
  8034. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8035. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8036. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8037. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8038. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8039. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8040. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8041. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8042. fsiOPFLD.BilgDeptName = department.Name
  8043. fsiOPFLD.BilgDeptCodg = department.Number
  8044. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8045. fsiOPFLD.BilgDrName = doctor.UserName
  8046. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8047. case 0:
  8048. break
  8049. case 1:
  8050. fsiOPFLD.MedChrgitmType = "14"
  8051. break
  8052. case 2:
  8053. fsiOPFLD.MedChrgitmType = "05"
  8054. break
  8055. case 3:
  8056. fsiOPFLD.MedChrgitmType = "03"
  8057. break
  8058. case 4:
  8059. fsiOPFLD.MedChrgitmType = "03"
  8060. break
  8061. case 5:
  8062. fsiOPFLD.MedChrgitmType = "08"
  8063. break
  8064. case 6:
  8065. fsiOPFLD.MedChrgitmType = "14"
  8066. break
  8067. case 7:
  8068. fsiOPFLD.MedChrgitmType = "14"
  8069. break
  8070. case 8:
  8071. fsiOPFLD.MedChrgitmType = "03"
  8072. break
  8073. case 9:
  8074. fsiOPFLD.MedChrgitmType = "14"
  8075. break
  8076. case 10:
  8077. fsiOPFLD.MedChrgitmType = "14"
  8078. break
  8079. case 11:
  8080. fsiOPFLD.MedChrgitmType = "06"
  8081. break
  8082. case 12:
  8083. fsiOPFLD.MedChrgitmType = "12"
  8084. break
  8085. case 13:
  8086. fsiOPFLD.MedChrgitmType = "01"
  8087. break
  8088. case 14:
  8089. fsiOPFLD.MedChrgitmType = "04"
  8090. break
  8091. case 15:
  8092. fsiOPFLD.MedChrgitmType = "14"
  8093. break
  8094. }
  8095. memo["hosp_appr_flag"] = "1"
  8096. memo["invoice_no"] = order.MdtrtId
  8097. memo["memo"] = "自费"
  8098. bytesData, _ := json.Marshal(memo)
  8099. fsiOPFLD.Memo = string(bytesData)
  8100. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8101. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8102. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8103. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8104. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8105. fsiOPFLD.BilgDeptName = department.Name
  8106. fsiOPFLD.BilgDeptCodg = department.Number
  8107. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8108. fsiOPFLD.BilgDrName = doctor.UserName
  8109. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8110. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8111. fsiOPFLD.MedChrgitmType = "08"
  8112. memo["hosp_appr_flag"] = "1"
  8113. memo["invoice_no"] = order.MdtrtId
  8114. memo["memo"] = "自费"
  8115. bytesData, _ := json.Marshal(memo)
  8116. fsiOPFLD.Memo = string(bytesData)
  8117. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8118. }
  8119. }
  8120. }
  8121. fmt.Println(fsiOPFLDs)
  8122. struct4201A.Fopfd = fsiOPFLDs
  8123. fmt.Println(struct4201A.Fopfd)
  8124. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  8125. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  8126. var res2 ResultSix
  8127. var respJSON2 map[string]interface{}
  8128. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8129. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8131. return
  8132. }
  8133. userJSONBytes2, _ := json.Marshal(respJSON2)
  8134. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8135. utils.ErrorLog("解析失败:%v", err)
  8136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8137. return
  8138. }
  8139. if res2.Infcode != 0 {
  8140. c.ServeSuccessJSON(map[string]interface{}{
  8141. "failed_code": -10,
  8142. "msg": res2.ErrMsg,
  8143. })
  8144. return
  8145. } else {
  8146. order.IsUploadOrderInfo = 1
  8147. service.UpdateOrder(order)
  8148. c.ServeSuccessJSON(map[string]interface{}{
  8149. "msg": "上传成功",
  8150. })
  8151. }
  8152. }
  8153. func (c *HisApiController) Get4202() {
  8154. order_id, _ := c.GetInt64("order_id")
  8155. admin_user_id, _ := c.GetInt64("admin_user_id")
  8156. order, _ := service.GetHisOrderByIDTwo(order_id)
  8157. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8158. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8159. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8160. if order.ID == 0 {
  8161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8162. return
  8163. }
  8164. var struct4202 models.Struct4202
  8165. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8166. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8167. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8168. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8169. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8170. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8171. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  8172. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  8173. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8174. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8175. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8176. var config []*models.HisXtDiagnoseConfig
  8177. for _, item := range diagnosis_ids {
  8178. id, _ := strconv.ParseInt(item, 10, 64)
  8179. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8180. config = append(config, &diagnosisConfig)
  8181. }
  8182. var tempDiaginfos []models.OwnPayPatnDiagListD
  8183. for index, item := range config {
  8184. if index == 0 {
  8185. var tempDiaginfo models.OwnPayPatnDiagListD
  8186. tempDiaginfo.InoutDiagType = "1"
  8187. tempDiaginfo.DiagCode = item.CountryCode
  8188. tempDiaginfo.DiagName = item.CountryContentName
  8189. tempDiaginfo.DiagType = "1"
  8190. tempDiaginfo.DiagSrtNo = "1"
  8191. tempDiaginfo.MaindiagFlag = "1"
  8192. tempDiaginfo.ValiFlag = "1"
  8193. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8194. } else {
  8195. var tempDiaginfo models.OwnPayPatnDiagListD
  8196. tempDiaginfo.DiagCode = item.CountryCode
  8197. tempDiaginfo.DiagName = item.CountryContentName
  8198. tempDiaginfo.DiagType = "2"
  8199. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8200. tempDiaginfo.MaindiagFlag = "0"
  8201. tempDiaginfo.ValiFlag = "1"
  8202. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8203. }
  8204. }
  8205. struct4202.ODiagListD = tempDiaginfos
  8206. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  8207. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  8208. var res2 ResultSix
  8209. var respJSON2 map[string]interface{}
  8210. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8211. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8213. return
  8214. }
  8215. userJSONBytes2, _ := json.Marshal(respJSON2)
  8216. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8217. utils.ErrorLog("解析失败:%v", err)
  8218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8219. return
  8220. }
  8221. if res2.Infcode != 0 {
  8222. c.ServeSuccessJSON(map[string]interface{}{
  8223. "failed_code": -10,
  8224. "msg": res2.ErrMsg,
  8225. })
  8226. return
  8227. } else {
  8228. order.IsUploadDiagnose = 1
  8229. service.UpdateOrder(order)
  8230. c.ServeSuccessJSON(map[string]interface{}{
  8231. "msg": "上传成功",
  8232. })
  8233. }
  8234. }
  8235. func (c *HisApiController) Get4203() {
  8236. admin_user_id, _ := c.GetInt64("admin_user_id")
  8237. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8238. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8239. order_id, _ := c.GetInt64("order_id")
  8240. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8241. number := ""
  8242. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8243. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8244. if his.ID == 0 {
  8245. number = hospital.Number
  8246. } else {
  8247. number = his.Number
  8248. }
  8249. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  8250. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  8251. var res2 ResultSix
  8252. var respJSON2 map[string]interface{}
  8253. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8254. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8256. return
  8257. }
  8258. userJSONBytes2, _ := json.Marshal(respJSON2)
  8259. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8260. utils.ErrorLog("解析失败:%v", err)
  8261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8262. return
  8263. }
  8264. if res2.Infcode != 0 {
  8265. c.ServeSuccessJSON(map[string]interface{}{
  8266. "failed_code": -10,
  8267. "msg": res2.ErrMsg,
  8268. })
  8269. return
  8270. } else {
  8271. order.IsUploadSuccess = 1
  8272. service.UpdateOrderTwo(order)
  8273. c.ServeSuccessJSON(map[string]interface{}{
  8274. "msg": "上传成功",
  8275. })
  8276. }
  8277. }
  8278. func (c *HisApiController) Get4205() {
  8279. order_id, _ := c.GetInt64("order_id")
  8280. admin_user_id, _ := c.GetInt64("admin_user_id")
  8281. fapiao_code := c.GetString("fapiao_code")
  8282. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8283. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8284. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8285. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8286. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  8287. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8288. //order_info = append(order_info, order_info_two...)
  8289. department, _ := service.GetDepartMentDetail(his.Departments)
  8290. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8291. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8292. if order.ID == 0 {
  8293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8294. return
  8295. }
  8296. var struct4201A models.Struct4201A
  8297. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8298. for _, items := range order_info {
  8299. memo := make(map[string]interface{})
  8300. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8301. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8302. fsiOPFLD.MedType = pre.MedType
  8303. fsiOPFLD.FixmedinsCode = miConfig.Code
  8304. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8305. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8306. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8307. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8308. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8309. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8310. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8311. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  8312. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8313. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8314. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8315. fsiOPFLD.BilgDeptName = department.Name
  8316. fsiOPFLD.BilgDeptCodg = department.Number
  8317. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8318. fsiOPFLD.BilgDrName = doctor.UserName
  8319. fsiOPFLD.MedChrgitmType = "09"
  8320. memo["hosp_appr_flag"] = "1"
  8321. memo["invoice_no"] = fapiao_code
  8322. memo["memo"] = "自费"
  8323. bytesData, _ := json.Marshal(memo)
  8324. fsiOPFLD.Memo = string(bytesData)
  8325. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8326. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8327. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8328. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8329. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8330. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8331. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8332. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8333. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8334. fsiOPFLD.BilgDeptName = department.Name
  8335. fsiOPFLD.BilgDeptCodg = department.Number
  8336. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8337. fsiOPFLD.BilgDrName = doctor.UserName
  8338. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8339. case 0:
  8340. break
  8341. case 1:
  8342. fsiOPFLD.MedChrgitmType = "14"
  8343. break
  8344. case 2:
  8345. fsiOPFLD.MedChrgitmType = "05"
  8346. break
  8347. case 3:
  8348. fsiOPFLD.MedChrgitmType = "03"
  8349. break
  8350. case 4:
  8351. fsiOPFLD.MedChrgitmType = "03"
  8352. break
  8353. case 5:
  8354. fsiOPFLD.MedChrgitmType = "08"
  8355. break
  8356. case 6:
  8357. fsiOPFLD.MedChrgitmType = "14"
  8358. break
  8359. case 7:
  8360. fsiOPFLD.MedChrgitmType = "14"
  8361. break
  8362. case 8:
  8363. fsiOPFLD.MedChrgitmType = "03"
  8364. break
  8365. case 9:
  8366. fsiOPFLD.MedChrgitmType = "14"
  8367. break
  8368. case 10:
  8369. fsiOPFLD.MedChrgitmType = "14"
  8370. break
  8371. case 11:
  8372. fsiOPFLD.MedChrgitmType = "06"
  8373. break
  8374. case 12:
  8375. fsiOPFLD.MedChrgitmType = "12"
  8376. break
  8377. case 13:
  8378. fsiOPFLD.MedChrgitmType = "01"
  8379. break
  8380. case 14:
  8381. fsiOPFLD.MedChrgitmType = "04"
  8382. break
  8383. case 15:
  8384. fsiOPFLD.MedChrgitmType = "14"
  8385. break
  8386. }
  8387. memo["hosp_appr_flag"] = "1"
  8388. memo["invoice_no"] = fapiao_code
  8389. memo["memo"] = "自费"
  8390. bytesData, _ := json.Marshal(memo)
  8391. fsiOPFLD.Memo = string(bytesData)
  8392. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8393. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8394. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8395. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8396. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8397. fsiOPFLD.BilgDeptName = department.Name
  8398. fsiOPFLD.BilgDeptCodg = department.Number
  8399. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8400. fsiOPFLD.BilgDrName = doctor.UserName
  8401. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8402. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8403. fsiOPFLD.MedChrgitmType = "08"
  8404. memo["hosp_appr_flag"] = "1"
  8405. memo["invoice_no"] = fapiao_code
  8406. memo["memo"] = "自费"
  8407. bytesData, _ := json.Marshal(memo)
  8408. fsiOPFLD.Memo = string(bytesData)
  8409. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8410. }
  8411. }
  8412. }
  8413. for _, items := range order_info_two {
  8414. memo := make(map[string]interface{})
  8415. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8416. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8417. fsiOPFLD.MedType = pre.MedType
  8418. fsiOPFLD.BkkpSn = items.FeedetlSn
  8419. fsiOPFLD.FixmedinsCode = miConfig.Code
  8420. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8421. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8422. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8423. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8424. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8425. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8426. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8427. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8428. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8429. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8430. fsiOPFLD.BilgDeptName = department.Name
  8431. fsiOPFLD.BilgDeptCodg = department.Number
  8432. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8433. fsiOPFLD.BilgDrName = doctor.UserName
  8434. fsiOPFLD.MedChrgitmType = "09"
  8435. memo["hosp_appr_flag"] = "1"
  8436. memo["invoice_no"] = fapiao_code
  8437. memo["memo"] = "自费"
  8438. bytesData, _ := json.Marshal(memo)
  8439. fsiOPFLD.Memo = string(bytesData)
  8440. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8441. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8442. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8443. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8444. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8445. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8446. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8447. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8448. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8449. fsiOPFLD.BilgDeptName = department.Name
  8450. fsiOPFLD.BilgDeptCodg = department.Number
  8451. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8452. fsiOPFLD.BilgDrName = doctor.UserName
  8453. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8454. case 0:
  8455. break
  8456. case 1:
  8457. fsiOPFLD.MedChrgitmType = "14"
  8458. break
  8459. case 2:
  8460. fsiOPFLD.MedChrgitmType = "05"
  8461. break
  8462. case 3:
  8463. fsiOPFLD.MedChrgitmType = "03"
  8464. break
  8465. case 4:
  8466. fsiOPFLD.MedChrgitmType = "03"
  8467. break
  8468. case 5:
  8469. fsiOPFLD.MedChrgitmType = "08"
  8470. break
  8471. case 6:
  8472. fsiOPFLD.MedChrgitmType = "14"
  8473. break
  8474. case 7:
  8475. fsiOPFLD.MedChrgitmType = "14"
  8476. break
  8477. case 8:
  8478. fsiOPFLD.MedChrgitmType = "03"
  8479. break
  8480. case 9:
  8481. fsiOPFLD.MedChrgitmType = "14"
  8482. break
  8483. case 10:
  8484. fsiOPFLD.MedChrgitmType = "14"
  8485. break
  8486. case 11:
  8487. fsiOPFLD.MedChrgitmType = "06"
  8488. break
  8489. case 12:
  8490. fsiOPFLD.MedChrgitmType = "12"
  8491. break
  8492. case 13:
  8493. fsiOPFLD.MedChrgitmType = "01"
  8494. break
  8495. case 14:
  8496. fsiOPFLD.MedChrgitmType = "04"
  8497. break
  8498. case 15:
  8499. fsiOPFLD.MedChrgitmType = "14"
  8500. break
  8501. }
  8502. memo["hosp_appr_flag"] = "1"
  8503. memo["invoice_no"] = fapiao_code
  8504. memo["memo"] = "自费"
  8505. bytesData, _ := json.Marshal(memo)
  8506. fsiOPFLD.Memo = string(bytesData)
  8507. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8508. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8509. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8510. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8511. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8512. fsiOPFLD.BilgDeptName = department.Name
  8513. fsiOPFLD.BilgDeptCodg = department.Number
  8514. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8515. fsiOPFLD.BilgDrName = doctor.UserName
  8516. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8517. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8518. fsiOPFLD.MedChrgitmType = "08"
  8519. memo["hosp_appr_flag"] = "1"
  8520. memo["invoice_no"] = fapiao_code
  8521. memo["memo"] = "自费"
  8522. bytesData, _ := json.Marshal(memo)
  8523. fsiOPFLD.Memo = string(bytesData)
  8524. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8525. }
  8526. }
  8527. }
  8528. fmt.Println(fsiOPFLDs)
  8529. struct4201A.Fopfd = fsiOPFLDs
  8530. fmt.Println(struct4201A.Fopfd)
  8531. var struct4202 models.Struct4202
  8532. timeLayout := "2006-01-02 15:04:05"
  8533. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  8534. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8535. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8536. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8537. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8538. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8539. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8540. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  8541. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  8542. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8543. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8544. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8545. var config []*models.HisXtDiagnoseConfig
  8546. for _, item := range diagnosis_ids {
  8547. id, _ := strconv.ParseInt(item, 10, 64)
  8548. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8549. config = append(config, &diagnosisConfig)
  8550. }
  8551. var tempDiaginfos []models.OwnPayPatnDiagListD
  8552. for index, item := range config {
  8553. if index == 0 {
  8554. var tempDiaginfo models.OwnPayPatnDiagListD
  8555. tempDiaginfo.InoutDiagType = "1"
  8556. tempDiaginfo.DiagCode = item.CountryCode
  8557. tempDiaginfo.DiagName = item.CountryContentName
  8558. tempDiaginfo.DiagType = "1"
  8559. tempDiaginfo.DiagSrtNo = "1"
  8560. tempDiaginfo.MaindiagFlag = "1"
  8561. tempDiaginfo.ValiFlag = "1"
  8562. tempDiaginfo.DiagDrName = doctor.UserName
  8563. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  8564. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  8565. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8566. } else {
  8567. var tempDiaginfo models.OwnPayPatnDiagListD
  8568. tempDiaginfo.DiagCode = item.CountryCode
  8569. tempDiaginfo.DiagName = item.CountryContentName
  8570. tempDiaginfo.DiagType = "2"
  8571. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8572. tempDiaginfo.MaindiagFlag = "0"
  8573. tempDiaginfo.ValiFlag = "1"
  8574. tempDiaginfo.DiagDrName = doctor.UserName
  8575. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  8576. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  8577. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8578. }
  8579. }
  8580. struct4202.ODiagListD = tempDiaginfos
  8581. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  8582. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  8583. var res2 ResultSix
  8584. var respJSON2 map[string]interface{}
  8585. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8586. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8588. return
  8589. }
  8590. userJSONBytes2, _ := json.Marshal(respJSON2)
  8591. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8592. utils.ErrorLog("解析失败:%v", err)
  8593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8594. return
  8595. }
  8596. if res2.Infcode != 0 {
  8597. c.ServeSuccessJSON(map[string]interface{}{
  8598. "failed_code": -10,
  8599. "msg": res2.ErrMsg,
  8600. })
  8601. return
  8602. } else {
  8603. order.IsUploadDiagnose = 1
  8604. order.IsUploadOrderInfo = 1
  8605. service.UpdateOrderTwo(order)
  8606. c.ServeSuccessJSON(map[string]interface{}{
  8607. "msg": "上传成功",
  8608. })
  8609. }
  8610. }
  8611. func (c *HisApiController) Get4207() {
  8612. admin_user_id, _ := c.GetInt64("admin_user_id")
  8613. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8614. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8615. order_id, _ := c.GetInt64("order_id")
  8616. order, _ := service.GetHisOrderByIDTwo(order_id)
  8617. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8618. var struct4207 models.Struct4207
  8619. struct4207.PageNum = "1"
  8620. struct4207.PageSize = "1000"
  8621. struct4207.FixmedinsCode = miConfig.Code
  8622. struct4207.FixmedinsMdtrtID = order.Number
  8623. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  8624. saveLog(result, requestLog, "4207", "查询")
  8625. var res2 ResultSix
  8626. var respJSON2 map[string]interface{}
  8627. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8630. return
  8631. }
  8632. userJSONBytes2, _ := json.Marshal(respJSON2)
  8633. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8634. utils.ErrorLog("解析失败:%v", err)
  8635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8636. return
  8637. }
  8638. if res2.Infcode != 0 {
  8639. c.ServeSuccessJSON(map[string]interface{}{
  8640. "failed_code": -10,
  8641. "msg": res2.ErrMsg,
  8642. })
  8643. return
  8644. } else {
  8645. c.ServeSuccessJSON(map[string]interface{}{
  8646. "msg": "查询成功",
  8647. })
  8648. }
  8649. }
  8650. func (c *HisApiController) Get4208() {
  8651. admin_user_id, _ := c.GetInt64("admin_user_id")
  8652. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8653. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8654. order_id, _ := c.GetInt64("order_id")
  8655. order, _ := service.GetHisOrderByIDTwo(order_id)
  8656. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8657. var struct4208 models.Struct4208
  8658. struct4208.PageNum = "1"
  8659. struct4208.PageSize = "1000"
  8660. struct4208.PsnCertType = "01"
  8661. struct4208.Certno = his.Certno
  8662. struct4208.MedType = order.MedType
  8663. struct4208.PsnName = his.Name
  8664. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  8665. saveLog(result, requestLog, "4208", "查询")
  8666. var res2 ResultSix
  8667. var respJSON2 map[string]interface{}
  8668. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8669. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8671. return
  8672. }
  8673. userJSONBytes2, _ := json.Marshal(respJSON2)
  8674. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8675. utils.ErrorLog("解析失败:%v", err)
  8676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8677. return
  8678. }
  8679. if res2.Infcode != 0 {
  8680. c.ServeSuccessJSON(map[string]interface{}{
  8681. "failed_code": -10,
  8682. "msg": res2.ErrMsg,
  8683. })
  8684. return
  8685. } else {
  8686. c.ServeSuccessJSON(map[string]interface{}{
  8687. "msg": "查询成功",
  8688. })
  8689. }
  8690. }
  8691. func (c *HisApiController) Get4209() {
  8692. admin_user_id, _ := c.GetInt64("admin_user_id")
  8693. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8694. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8695. order_id, _ := c.GetInt64("order_id")
  8696. order, _ := service.GetHisOrderByIDTwo(order_id)
  8697. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8698. var struct4209 models.Struct4209
  8699. struct4209.FixmedinsMdtrtID = order.Number
  8700. struct4209.FixmedinsCode = miConfig.Code
  8701. struct4209.PageSize = "1000"
  8702. struct4209.PageNum = "1"
  8703. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  8704. saveLog(result, requestLog, "4209", "查询")
  8705. var res2 ResultSix
  8706. var respJSON2 map[string]interface{}
  8707. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8708. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8710. return
  8711. }
  8712. userJSONBytes2, _ := json.Marshal(respJSON2)
  8713. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8714. utils.ErrorLog("解析失败:%v", err)
  8715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8716. return
  8717. }
  8718. if res2.Infcode != 0 {
  8719. c.ServeSuccessJSON(map[string]interface{}{
  8720. "failed_code": -10,
  8721. "msg": res2.ErrMsg,
  8722. })
  8723. return
  8724. } else {
  8725. c.ServeSuccessJSON(map[string]interface{}{
  8726. "msg": "查询成功",
  8727. })
  8728. }
  8729. }
  8730. type Result3101 struct {
  8731. Infcode string `json:"infcode"`
  8732. InfRefmsgid string `json:"inf_refmsgid"`
  8733. RefmsgTime string `json:"refmsg_time"`
  8734. RespondTime string `json:"respond_time"`
  8735. Enctype string `json:"enctype"`
  8736. Signtype string `json:"signtype"`
  8737. ErrMsg string `json:"err_msg"`
  8738. Output struct {
  8739. Result []struct {
  8740. JudgeResultDetailDtos []struct {
  8741. VolaItemType string `json:"vola_item_type"`
  8742. MdtrtID string `json:"mdtrt_id"`
  8743. JrdID string `json:"jrd_id"`
  8744. PatnID string `json:"patn_id"`
  8745. RxID string `json:"rx_id"`
  8746. VolaAmt interface{} `json:"vola_amt"`
  8747. } `json:"judge_result_detail_dtos"`
  8748. RuleID string `json:"rule_id"`
  8749. VolaEvid string `json:"vola_evid"`
  8750. MdtrtID string `json:"mdtrt_id"`
  8751. RuleName string `json:"rule_name"`
  8752. VolaAmtStas string `json:"vola_amt_stas"`
  8753. JrID string `json:"jr_id"`
  8754. PatnID string `json:"patn_id"`
  8755. SevDeg string `json:"sev_deg"`
  8756. VolaAmt float64 `json:"vola_amt"`
  8757. VolaBhvrType string `json:"vola_bhvr_type"`
  8758. VolaCont string `json:"vola_cont"`
  8759. } `json:"result"`
  8760. } `json:"output"`
  8761. }
  8762. type Resultgd3101 struct {
  8763. Infcode int64 `json:"infcode"`
  8764. InfRefmsgid string `json:"inf_refmsgid"`
  8765. RefmsgTime string `json:"refmsg_time"`
  8766. RespondTime string `json:"respond_time"`
  8767. Enctype string `json:"enctype"`
  8768. Signtype string `json:"signtype"`
  8769. ErrMsg string `json:"err_msg"`
  8770. Output struct {
  8771. Result []struct {
  8772. JudgeResultDetailDtos []struct {
  8773. VolaItemType string `json:"vola_item_type"`
  8774. MdtrtID string `json:"mdtrt_id"`
  8775. JrdID string `json:"jrd_id"`
  8776. PatnID string `json:"patn_id"`
  8777. RxID string `json:"rx_id"`
  8778. VolaAmt interface{} `json:"vola_amt"`
  8779. } `json:"judge_result_detail_dtos"`
  8780. RuleID string `json:"rule_id"`
  8781. VolaEvid string `json:"vola_evid"`
  8782. MdtrtID string `json:"mdtrt_id"`
  8783. RuleName string `json:"rule_name"`
  8784. VolaAmtStas string `json:"vola_amt_stas"`
  8785. JrID string `json:"jr_id"`
  8786. PatnID string `json:"patn_id"`
  8787. SevDeg string `json:"sev_deg"`
  8788. VolaAmt float64 `json:"vola_amt"`
  8789. VolaBhvrType string `json:"vola_bhvr_type"`
  8790. VolaCont string `json:"vola_cont"`
  8791. } `json:"result"`
  8792. } `json:"output"`
  8793. }
  8794. func (c *HisApiController) ReadEleToken() {
  8795. admin_user_id, _ := c.GetInt64("admin_user_id")
  8796. his_patient_id, _ := c.GetInt64("his_patient_id")
  8797. adminUser := c.GetAdminUserInfo()
  8798. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8799. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8800. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8801. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8802. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  8803. if len(tokens) > 0 {
  8804. c.ServeSuccessJSON(map[string]interface{}{
  8805. "msg": "读取成功",
  8806. })
  8807. } else {
  8808. c.ServeSuccessJSON(map[string]interface{}{
  8809. "failed_code": -10,
  8810. "msg": "读取失败",
  8811. })
  8812. }
  8813. } else if miConfig.MdtrtareaAdmvs == "341203" {
  8814. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  8815. if len(tokens) > 0 {
  8816. c.ServeSuccessJSON(map[string]interface{}{
  8817. "msg": "读取成功",
  8818. })
  8819. } else {
  8820. c.ServeSuccessJSON(map[string]interface{}{
  8821. "failed_code": -10,
  8822. "msg": "读取失败",
  8823. })
  8824. }
  8825. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8826. var api string
  8827. 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 +
  8828. "&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"
  8829. resp, requestErr := http.Get(api)
  8830. if requestErr != nil {
  8831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8832. }
  8833. body, ioErr := ioutil.ReadAll(resp.Body)
  8834. if ioErr != nil {
  8835. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8837. }
  8838. var respJSON map[string]interface{}
  8839. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8840. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8842. return
  8843. }
  8844. var status string
  8845. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8846. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8847. var token string
  8848. var res ResultTwo //1101结果
  8849. var res10265 ResultTwo10265 //1101结果
  8850. if status == "0" { //读卡成功
  8851. var card_info string //卡信息
  8852. var busi_card_info string
  8853. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8854. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8855. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8856. fmt.Println(card_info)
  8857. fmt.Println(busi_card_info)
  8858. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8859. result, _ := json.Marshal(respJSON)
  8860. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8861. utils.ErrorLog("解析失败:%v", err)
  8862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8863. return
  8864. }
  8865. res.ErrMsg = res10265.ErrMsg
  8866. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8867. res.Infcode = infocode
  8868. res.Output = res10265.Output
  8869. res.InfRefmsgid = res10265.InfRefmsgid
  8870. if res.Infcode == 0 {
  8871. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8872. if err == gorm.ErrRecordNotFound {
  8873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8874. return
  8875. } else if err != nil {
  8876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8877. return
  8878. } else {
  8879. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8880. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8881. infoStr := string(Iinfos)
  8882. idetinfoStr := string(Idetinfos)
  8883. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  8884. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  8885. psn := &models.HisPsn{
  8886. PsnNo: res.Output.Baseinfo.PsnNo,
  8887. PatientId: patient.ID,
  8888. Certno: res.Output.Baseinfo.Certno,
  8889. Gend: res.Output.Baseinfo.Gend,
  8890. Naty: res.Output.Baseinfo.Naty,
  8891. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8892. PsnName: res.Output.Baseinfo.PsnName,
  8893. Age: float64(age),
  8894. Brdy: b,
  8895. Idetinfo: idetinfoStr,
  8896. Insuinfo: infoStr,
  8897. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8898. CardInfo: card_info,
  8899. VerifyNumber: token,
  8900. IdCardType: 4,
  8901. }
  8902. var rf []*ResultFive
  8903. json.Unmarshal([]byte(infoStr), &rf)
  8904. var insutypes []*ResultFive
  8905. var insutype string
  8906. var is390 int = 0
  8907. var is310 int = 0
  8908. for _, item := range rf {
  8909. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8910. insutypes = append(insutypes, item)
  8911. }
  8912. }
  8913. if len(insutypes) == 1 {
  8914. insutype = insutypes[0].Insutype
  8915. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8916. } else {
  8917. for _, i := range insutypes {
  8918. if i.Insutype == "390" {
  8919. is390 = 1
  8920. }
  8921. if i.Insutype == "310" {
  8922. is310 = 1
  8923. }
  8924. }
  8925. }
  8926. if is390 == 1 {
  8927. insutype = "390"
  8928. }
  8929. if is310 == 1 {
  8930. insutype = "310"
  8931. }
  8932. if len(insutypes) == 0 {
  8933. insutype = "310"
  8934. }
  8935. service.CreateHisPsn(psn)
  8936. c.ServeSuccessJSON(map[string]interface{}{
  8937. "patient": patient,
  8938. "number": token,
  8939. "insutype": insutype,
  8940. })
  8941. }
  8942. } else {
  8943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8944. return
  8945. }
  8946. } else { //读卡失败
  8947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8948. return
  8949. }
  8950. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8951. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  8952. if len(errMsg) == 0 {
  8953. type ELeData struct {
  8954. Data struct {
  8955. IdNo string `json:"idNo"`
  8956. IdType string `json:"idType"`
  8957. UserName string `json:"userName"`
  8958. EcToken string `json:"ecToken"`
  8959. InsuOrg string `json:"insuOrg"`
  8960. Gender string `json:"gender"`
  8961. Birthday string `json:"birthday"`
  8962. Nationality string `json:"nationality"`
  8963. Email string `json:"email"`
  8964. Extra string `json:"extra"`
  8965. } `json:"data"`
  8966. Code int `json:"code"`
  8967. Message string `json:"message"`
  8968. }
  8969. var ele ELeData
  8970. err := json.Unmarshal([]byte(outPutInfo), &ele)
  8971. if err != nil {
  8972. utils.ErrorLog("解析失败:%v", err)
  8973. }
  8974. token := ele.Data.EcToken
  8975. if len(token) > 0 {
  8976. psn := &models.HisPsn{
  8977. PsnNo: his.PsnNo,
  8978. Age: 0,
  8979. PatientId: his.PatientId,
  8980. Certno: his.Certno,
  8981. Brdy: his.Brdy,
  8982. Gend: his.Gend,
  8983. Naty: his.Naty,
  8984. PsnCertType: his.PsnCertType,
  8985. PsnName: his.PsnName,
  8986. Idetinfo: his.Idetinfo,
  8987. Insuinfo: his.Iinfo,
  8988. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8989. CardInfo: outPutInfo,
  8990. VerifyNumber: token,
  8991. }
  8992. service.CreateHisPsn(psn)
  8993. }
  8994. if len(token) > 0 {
  8995. c.ServeSuccessJSON(map[string]interface{}{
  8996. "msg": "读取成功",
  8997. })
  8998. } else {
  8999. c.ServeSuccessJSON(map[string]interface{}{
  9000. "failed_code": -10,
  9001. "msg": "读取失败",
  9002. })
  9003. }
  9004. }
  9005. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9006. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9007. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9008. type ELeData struct {
  9009. Data struct {
  9010. IdNo string `json:"idNo"`
  9011. IdType string `json:"idType"`
  9012. UserName string `json:"userName"`
  9013. EcToken string `json:"ecToken"`
  9014. InsuOrg string `json:"insuOrg"`
  9015. Gender string `json:"gender"`
  9016. Birthday string `json:"birthday"`
  9017. Nationality string `json:"nationality"`
  9018. Email string `json:"email"`
  9019. Extra string `json:"extra"`
  9020. } `json:"data"`
  9021. Code int `json:"code"`
  9022. Message string `json:"message"`
  9023. }
  9024. var ele ELeData
  9025. err := json.Unmarshal([]byte(result), &ele)
  9026. if err != nil {
  9027. utils.ErrorLog("解析失败:%v", err)
  9028. }
  9029. token := ele.Data.EcToken
  9030. token = Remove0000(token)
  9031. fmt.Println(ele.Data.UserName)
  9032. 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)
  9033. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9034. var res ResultTwo
  9035. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9036. utils.ErrorLog("解析失败:%v", err)
  9037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9038. return
  9039. }
  9040. if res.Infcode == 0 {
  9041. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9042. if err == gorm.ErrRecordNotFound {
  9043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9044. return
  9045. } else if err != nil {
  9046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9047. return
  9048. } else {
  9049. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9050. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9051. infoStr := string(Iinfos)
  9052. idetinfoStr := string(Idetinfos)
  9053. psn := &models.HisPsn{
  9054. PsnNo: res.Output.Baseinfo.PsnNo,
  9055. PatientId: patient.ID,
  9056. Certno: res.Output.Baseinfo.Certno,
  9057. Gend: res.Output.Baseinfo.Gend,
  9058. Naty: res.Output.Baseinfo.Naty,
  9059. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9060. PsnName: res.Output.Baseinfo.PsnName,
  9061. Idetinfo: idetinfoStr,
  9062. Insuinfo: infoStr,
  9063. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9064. CardInfo: "",
  9065. VerifyNumber: token,
  9066. }
  9067. service.CreateHisPsn(psn)
  9068. c.ServeSuccessJSON(map[string]interface{}{
  9069. "patient": patient,
  9070. "number": token,
  9071. })
  9072. }
  9073. } else {
  9074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9075. return
  9076. }
  9077. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9078. //if initFlag == 0 {
  9079. //c.TestGetJiangXiBasBaseInit()
  9080. //}
  9081. //if initEleFlag == 0 {
  9082. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9083. //}
  9084. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  9085. utils.ErrorLog("解析失败:%v", json_result)
  9086. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9087. type ELeData struct {
  9088. Data struct {
  9089. IdNo string `json:"idNo"`
  9090. IdType string `json:"idType"`
  9091. UserName string `json:"userName"`
  9092. EcToken string `json:"ecToken"`
  9093. InsuOrg string `json:"insuOrg"`
  9094. Gender string `json:"gender"`
  9095. Birthday string `json:"birthday"`
  9096. Nationality string `json:"nationality"`
  9097. Email string `json:"email"`
  9098. Extra string `json:"extra"`
  9099. } `json:"data"`
  9100. Code int `json:"code"`
  9101. Message string `json:"message"`
  9102. }
  9103. var ele ELeData
  9104. err := json.Unmarshal([]byte(json_result), &ele)
  9105. if err != nil {
  9106. utils.ErrorLog("解析失败:%v", err)
  9107. }
  9108. token := ele.Data.EcToken
  9109. token = Remove0000(token)
  9110. //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)
  9111. 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)
  9112. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9113. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9114. var res ResultTwo
  9115. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9116. utils.ErrorLog("解析失败:%v", err)
  9117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9118. return
  9119. }
  9120. if res.Infcode == 0 {
  9121. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9122. if err == gorm.ErrRecordNotFound {
  9123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9124. return
  9125. } else if err != nil {
  9126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9127. return
  9128. } else {
  9129. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9130. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9131. infoStr := string(Iinfos)
  9132. idetinfoStr := string(Idetinfos)
  9133. psn := &models.HisPsn{
  9134. PsnNo: res.Output.Baseinfo.PsnNo,
  9135. PatientId: patient.ID,
  9136. Certno: res.Output.Baseinfo.Certno,
  9137. Gend: res.Output.Baseinfo.Gend,
  9138. Naty: res.Output.Baseinfo.Naty,
  9139. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9140. PsnName: res.Output.Baseinfo.PsnName,
  9141. Idetinfo: idetinfoStr,
  9142. Insuinfo: infoStr,
  9143. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9144. CardInfo: "",
  9145. VerifyNumber: token,
  9146. InsuplcAdmdvs: ele.Data.InsuOrg,
  9147. }
  9148. service.CreateHisPsn(psn)
  9149. c.ServeSuccessJSON(map[string]interface{}{
  9150. "patient": patient,
  9151. "number": token,
  9152. })
  9153. }
  9154. } else {
  9155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9156. return
  9157. }
  9158. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9159. res := c.GetoleInfo()
  9160. if res.Infcode == 0 {
  9161. var result string
  9162. if res.Output.MdtrtCertType == "01" {
  9163. 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)
  9164. } else if res.Output.MdtrtCertType == "02" {
  9165. 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)
  9166. } else if res.Output.MdtrtCertType == "03" {
  9167. 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)
  9168. }
  9169. var dat map[string]interface{}
  9170. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9171. fmt.Println(dat)
  9172. } else {
  9173. fmt.Println(err)
  9174. }
  9175. userJSONBytes, _ := json.Marshal(dat)
  9176. var res2 ResultTwo
  9177. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9178. utils.ErrorLog("解析失败:%v", err)
  9179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9180. return
  9181. }
  9182. if res2.Infcode == 0 {
  9183. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9184. if err == gorm.ErrRecordNotFound {
  9185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9186. return
  9187. } else if err != nil {
  9188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9189. return
  9190. } else {
  9191. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9192. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9193. infoStr := string(Iinfos)
  9194. idetinfoStr := string(Idetinfos)
  9195. var rf []*ResultFive
  9196. json.Unmarshal([]byte(infoStr), &rf)
  9197. var insutypes []*ResultFive
  9198. var insutype string
  9199. var is390 int = 0
  9200. var is310 int = 0
  9201. //var insuplc_admdvs string
  9202. for _, item := range rf {
  9203. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9204. insutypes = append(insutypes, item)
  9205. }
  9206. }
  9207. if len(insutypes) == 1 {
  9208. insutype = insutypes[0].Insutype
  9209. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9210. } else {
  9211. for _, i := range insutypes {
  9212. if i.Insutype == "390" {
  9213. is390 = 1
  9214. }
  9215. if i.Insutype == "310" {
  9216. is310 = 1
  9217. }
  9218. }
  9219. }
  9220. if is390 == 1 {
  9221. insutype = "390"
  9222. }
  9223. if is310 == 1 {
  9224. insutype = "310"
  9225. }
  9226. if len(insutypes) == 0 {
  9227. insutype = "310"
  9228. }
  9229. psn := &models.HisPsn{
  9230. PsnNo: res2.Output.Baseinfo.PsnNo,
  9231. PatientId: patient.ID,
  9232. Certno: res2.Output.Baseinfo.Certno,
  9233. Gend: res2.Output.Baseinfo.Gend,
  9234. Naty: res2.Output.Baseinfo.Naty,
  9235. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9236. PsnName: res2.Output.Baseinfo.PsnName,
  9237. Idetinfo: idetinfoStr,
  9238. Insuinfo: infoStr,
  9239. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9240. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9241. VerifyNumber: res.Output.EcToken,
  9242. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9243. }
  9244. service.CreateHisPsn(psn)
  9245. c.ServeSuccessJSON(map[string]interface{}{
  9246. "patient": patient,
  9247. "number": res.Output.CardNo,
  9248. "insutype": insutype,
  9249. })
  9250. }
  9251. } else {
  9252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9253. return
  9254. }
  9255. } else {
  9256. c.ServeSuccessJSON(map[string]interface{}{
  9257. "failed_code": -10,
  9258. "msg": res.ErrMsg,
  9259. })
  9260. }
  9261. } else {
  9262. //if initFlag == 0 {
  9263. // c.TestGetBasBaseInit()
  9264. //}
  9265. //token := c.GetEleBaseInfo()
  9266. //token = Remove0000(token)
  9267. type ELeData struct {
  9268. Code string `json:"code"`
  9269. Data struct {
  9270. Aac002 string `json:"aac002"`
  9271. Aaz500 string `json:"aaz500"`
  9272. ActCardNo string `json:"actCardNo"`
  9273. Bab520 string `json:"bab520"`
  9274. Bkz543 string `json:"bkz543"`
  9275. BusinessType string `json:"businessType"`
  9276. CertfCodg string `json:"certfCodg"`
  9277. EcIndexNo string `json:"ecIndexNo"`
  9278. EcToken string `json:"ecToken"`
  9279. ID0000 string `json:"id0000"`
  9280. IDNo string `json:"idNo"`
  9281. IDType string `json:"idType"`
  9282. Idcode string `json:"idcode"`
  9283. IdentityToken string `json:"identity_token"`
  9284. InsuOrg string `json:"insuOrg"`
  9285. OfficeID string `json:"officeId"`
  9286. OfficeName string `json:"officeName"`
  9287. OperatorID string `json:"operatorId"`
  9288. OperatorName string `json:"operatorName"`
  9289. OrgID string `json:"orgId"`
  9290. UserName string `json:"userName"`
  9291. } `json:"data"`
  9292. Infno interface{} `json:"infno"`
  9293. Message string `json:"message"`
  9294. OrgID string `json:"orgId"`
  9295. TransType string `json:"transType"`
  9296. }
  9297. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9298. fmt.Println(result)
  9299. outPutInfo := Remove0000(result)
  9300. fmt.Println(outPutInfo)
  9301. var ele ELeData
  9302. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9303. if err != nil {
  9304. utils.ErrorLog("解析失败:%v", err)
  9305. }
  9306. token := ele.Data.EcToken
  9307. var result2 string
  9308. var requestLog2 string
  9309. if len(token) > 0 {
  9310. if strings.Contains(ele.Data.IDNo, "HKG") {
  9311. 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)
  9312. } else {
  9313. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  9314. }
  9315. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9316. var res ResultTwo
  9317. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9318. utils.ErrorLog("解析失败:%v", err)
  9319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9320. return
  9321. }
  9322. if res.Infcode == 0 {
  9323. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9324. if err == gorm.ErrRecordNotFound {
  9325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9326. return
  9327. } else if err != nil {
  9328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9329. return
  9330. } else {
  9331. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9332. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9333. infoStr := string(Iinfos)
  9334. idetinfoStr := string(Idetinfos)
  9335. psn := &models.HisPsn{
  9336. PsnNo: res.Output.Baseinfo.PsnNo,
  9337. PatientId: patient.ID,
  9338. Certno: res.Output.Baseinfo.Certno,
  9339. Gend: res.Output.Baseinfo.Gend,
  9340. Naty: res.Output.Baseinfo.Naty,
  9341. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9342. PsnName: res.Output.Baseinfo.PsnName,
  9343. Idetinfo: idetinfoStr,
  9344. Insuinfo: infoStr,
  9345. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9346. CardInfo: "",
  9347. VerifyNumber: token,
  9348. }
  9349. service.CreateHisPsn(psn)
  9350. c.ServeSuccessJSON(map[string]interface{}{
  9351. "msg": "读取成功",
  9352. })
  9353. }
  9354. } else {
  9355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9356. return
  9357. }
  9358. } else {
  9359. c.ServeSuccessJSON(map[string]interface{}{
  9360. "failed_code": -10,
  9361. "msg": "读取失败",
  9362. })
  9363. }
  9364. }
  9365. }
  9366. func (c *HisApiController) ReadEleFace() {
  9367. admin_user_id, _ := c.GetInt64("admin_user_id")
  9368. //his_patient_id, _ := c.GetInt64("his_patient_id")
  9369. adminUser := c.GetAdminUserInfo()
  9370. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9371. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9372. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9373. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9374. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9375. if len(tokens) > 0 {
  9376. c.ServeSuccessJSON(map[string]interface{}{
  9377. "msg": "读取成功",
  9378. })
  9379. } else {
  9380. c.ServeSuccessJSON(map[string]interface{}{
  9381. "failed_code": -10,
  9382. "msg": "读取失败",
  9383. })
  9384. }
  9385. }
  9386. }
  9387. func (c *HisApiController) Get9001() {
  9388. adminUser := c.GetAdminUserInfo()
  9389. admin_user_id, _ := c.GetInt64("admin_user_id")
  9390. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9391. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9392. if miConfig.MdtrtareaAdmvs == "350500" {
  9393. service.GetFjAuthorizationInfo(miConfig.Code)
  9394. } else if miConfig.MdtrtareaAdmvs == "131023" {
  9395. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9396. var dat map[string]interface{}
  9397. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9398. fmt.Println(dat)
  9399. } else {
  9400. fmt.Println(err)
  9401. }
  9402. userJSONBytes, _ := json.Marshal(dat)
  9403. var res models.Result9001
  9404. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9405. utils.ErrorLog("解析失败:%v", err)
  9406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9407. return
  9408. }
  9409. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9410. fmt.Println(miConfig.SecretKey)
  9411. var res models.Result9001Two
  9412. 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 +
  9413. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  9414. resp, requestErr := http.Get(api)
  9415. if requestErr != nil {
  9416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9417. return
  9418. }
  9419. body, ioErr := ioutil.ReadAll(resp.Body)
  9420. if ioErr != nil {
  9421. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9423. return
  9424. }
  9425. var respJSON map[string]interface{}
  9426. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9427. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9429. return
  9430. }
  9431. status := respJSON["data"].(map[string]interface{})["status"].(string)
  9432. if status == "0" {
  9433. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  9434. c.ServeSuccessJSON(map[string]interface{}{
  9435. "failed_code": -10,
  9436. "msg": err_msg,
  9437. })
  9438. return
  9439. }
  9440. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9441. result, _ := json.Marshal(respJSON)
  9442. fmt.Println("log")
  9443. fmt.Println(string(result))
  9444. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9445. utils.ErrorLog("解析失败:%v", err)
  9446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9447. return
  9448. }
  9449. if res.Infcode == 0 {
  9450. sign := models.HisSignIn{
  9451. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9452. SignNo: res.Output.Signinoutb.SignNo,
  9453. SignTime: "",
  9454. Ctime: time.Now().Unix(),
  9455. Mtime: time.Now().Unix(),
  9456. Status: 1,
  9457. InputLog: "",
  9458. OutputLog: "",
  9459. FixmedinsCode: miConfig.Code,
  9460. }
  9461. err := service.CreateSignIn(&sign)
  9462. if err == nil {
  9463. c.ServeSuccessJSON(map[string]interface{}{
  9464. "msg": "签到成功",
  9465. })
  9466. }
  9467. } else {
  9468. c.ServeSuccessJSON(map[string]interface{}{
  9469. "failed_code": -10,
  9470. "msg": res.ErrMsg,
  9471. })
  9472. return
  9473. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9474. //return
  9475. }
  9476. } else {
  9477. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  9478. var dat map[string]interface{}
  9479. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9480. fmt.Println(dat)
  9481. } else {
  9482. fmt.Println(err)
  9483. }
  9484. userJSONBytes, _ := json.Marshal(dat)
  9485. var res models.Result9001
  9486. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9487. utils.ErrorLog("解析失败:%v", err)
  9488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9489. return
  9490. }
  9491. if res.Infcode == 0 {
  9492. sign := models.HisSignIn{
  9493. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9494. SignNo: res.Output.Signinoutb.SignNo,
  9495. SignTime: res.Output.Signinoutb.SignTime,
  9496. Ctime: time.Now().Unix(),
  9497. Mtime: time.Now().Unix(),
  9498. Status: 1,
  9499. InputLog: "",
  9500. OutputLog: "",
  9501. FixmedinsCode: miConfig.Code,
  9502. }
  9503. err := service.CreateSignIn(&sign)
  9504. if err == nil {
  9505. c.ServeSuccessJSON(map[string]interface{}{
  9506. "msg": "签到成功",
  9507. })
  9508. }
  9509. }
  9510. }
  9511. }
  9512. 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) {
  9513. var res Result3101
  9514. adminUser := c.GetAdminUserInfo()
  9515. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9516. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9517. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9518. //record_time := c.GetString("record_time")
  9519. //trig_scen := c.GetString("trig_scen")
  9520. timeLayout := "2006-01-02"
  9521. loc, _ := time.LoadLocation("Local")
  9522. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9523. if err != nil {
  9524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9525. return res
  9526. }
  9527. recordDateTime := theTime.Unix()
  9528. var patientPrescription models.HisPrescriptionInfo
  9529. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9530. //if patientPrescription.ID == 0 {
  9531. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  9532. //}
  9533. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9534. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9535. //
  9536. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  9537. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9538. var pp models.PublicParams
  9539. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9540. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9541. pp.FixmedinsName = miConfig.OrgName
  9542. pp.FixmedinsCode = miConfig.Code
  9543. pp.RequestUrl = miConfig.Url
  9544. pp.Cainfo = miConfig.Cainfo
  9545. pp.SecretKey = miConfig.SecretKey
  9546. pp.AccessKey = miConfig.AccessKey
  9547. pp.OpterName = roles.UserName
  9548. var config []*models.HisXtDiagnoseConfig
  9549. for _, item := range diagnosis_ids {
  9550. id, _ := strconv.ParseInt(item, 10, 64)
  9551. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9552. config = append(config, &diagnosisConfig)
  9553. }
  9554. var pd models.PatientDtos
  9555. pd.PatnID = his.PsnNo
  9556. pd.PatnName = his.Name
  9557. pd.Gend = his.Gend
  9558. pd.Brdy = his.Brdy
  9559. pd.Poolarea = miConfig.MdtrtareaAdmvs
  9560. pd.CurrMdtrtID = his.Number
  9561. var fed models.FsiEncounterDtos
  9562. fed.MdtrtID = his.Number
  9563. fed.MedinsID = miConfig.Code
  9564. fed.MedinsName = miConfig.OrgName
  9565. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  9566. fed.MedMdtrtType = "1"
  9567. fed.MedinsType = "1"
  9568. fed.MedinsLv = "11"
  9569. tm := time.Unix(his.RecordDate, 0)
  9570. s_tm := tm.Format("2006-01-02 15:04:05")
  9571. fed.AdmDate = s_tm
  9572. fed.DscgDate = s_tm
  9573. fed.DscgMainDiseCodg = config[0].CountryCode
  9574. fed.DscgMainDiseName = config[0].CountryContentName
  9575. //诊断信息
  9576. var fdds []*models.FsiDiagnoseDtos
  9577. for index, item := range config {
  9578. if index == 0 {
  9579. var fdd models.FsiDiagnoseDtos
  9580. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9581. fdd.InoutDiseType = "1"
  9582. fdd.MaindiseFlag = "1"
  9583. fdd.DiseDate = s_tm
  9584. fdd.DiasSrtNo = "1"
  9585. fdd.DiseName = item.CountryContentName
  9586. fdd.DiseCodg = item.CountryCode
  9587. fdds = append(fdds, &fdd)
  9588. } else {
  9589. var fdd models.FsiDiagnoseDtos
  9590. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9591. fdd.InoutDiseType = "1"
  9592. fdd.MaindiseFlag = "1"
  9593. fdd.DiseDate = s_tm
  9594. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  9595. fdd.DiseName = item.CountryContentName
  9596. fdd.DiseCodg = item.CountryCode
  9597. fdds = append(fdds, &fdd)
  9598. }
  9599. }
  9600. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  9601. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  9602. fed.AdmDeptName = de.Name
  9603. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  9604. fed.DscgDeptName = de.Name
  9605. fed.MedMdtrtType = "1"
  9606. fed.MedType = "11"
  9607. //if his.Insutype == "390" {
  9608. // fed.MedType = "1402"
  9609. //} else {
  9610. // fed.MedType = "9933"
  9611. //}
  9612. var orders []*models.FsiOrderDtos
  9613. if trig_scen == "2" {
  9614. //处方医嘱信息
  9615. for _, item := range prescriptions {
  9616. for _, subItem := range item.HisDoctorAdviceInfo {
  9617. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9618. var order models.FsiOrderDtos
  9619. order.RxID = strconv.FormatInt(item.ID, 10)
  9620. order.Rxno = strconv.FormatInt(item.ID, 10)
  9621. order.LongDrordFlag = "0"
  9622. order.HilistType = "1"
  9623. order.ChrgType = "1"
  9624. order.DrordBhvr = "-"
  9625. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9626. order.HosplistName = subItem.BaseDrugLib.DrugName
  9627. order.HilistLv = "1"
  9628. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9629. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9630. order.HosplistName = subItem.BaseDrugLib.DrugName
  9631. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  9632. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9633. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  9634. order.OwnpayAmt = ""
  9635. order.SelfpayAmt = ""
  9636. order.Spec = ""
  9637. order.SpecUnt = ""
  9638. order.DrordBegnDate = s_tm
  9639. order.DrordStopDate = ""
  9640. order.DrordDrCodg = doctor_info.DoctorNumber
  9641. order.DrordDeptName = department.Name
  9642. order.DrordDeptCodg = department.Number
  9643. order.DrordDrName = doctor_info.UserName
  9644. order.DrordDrProfttl = "234"
  9645. order.CurrDrordFlag = "1"
  9646. orders = append(orders, &order)
  9647. }
  9648. }
  9649. for _, subItem := range item.HisPrescriptionProject {
  9650. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  9651. var order models.FsiOrderDtos
  9652. order.RxID = strconv.FormatInt(item.ID, 10)
  9653. order.Rxno = strconv.FormatInt(item.ID, 10)
  9654. order.LongDrordFlag = "0"
  9655. order.HilistType = "1"
  9656. order.ChrgType = "1"
  9657. order.DrordBhvr = "-"
  9658. order.HilistCode = subItem.HisProject.MedicalCode
  9659. order.HosplistName = subItem.HisProject.ProjectName
  9660. order.HilistLv = "1"
  9661. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9662. order.HosplistCode = subItem.HisProject.MedicalCode
  9663. order.HosplistName = subItem.HisProject.ProjectName
  9664. order.Cnt = subItem.Count
  9665. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9666. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9667. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  9668. order.OwnpayAmt = ""
  9669. order.SelfpayAmt = ""
  9670. order.Spec = ""
  9671. order.SpecUnt = ""
  9672. order.DrordBegnDate = s_tm
  9673. order.DrordStopDate = ""
  9674. order.DrordDrCodg = doctor_info.DoctorNumber
  9675. order.DrordDeptName = department.Name
  9676. order.DrordDeptCodg = department.Number
  9677. order.DrordDrName = doctor_info.UserName
  9678. order.DrordDrProfttl = "234"
  9679. order.CurrDrordFlag = "1"
  9680. orders = append(orders, &order)
  9681. }
  9682. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  9683. var order models.FsiOrderDtos
  9684. order.RxID = strconv.FormatInt(item.ID, 10)
  9685. order.Rxno = strconv.FormatInt(item.ID, 10)
  9686. order.LongDrordFlag = "0"
  9687. order.HilistType = "1"
  9688. order.ChrgType = "1"
  9689. order.DrordBhvr = "-"
  9690. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9691. order.HosplistName = subItem.GoodInfo.GoodName
  9692. order.HilistLv = "1"
  9693. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9694. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9695. order.HosplistName = subItem.GoodInfo.GoodName
  9696. order.Cnt = subItem.Count
  9697. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9698. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9699. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  9700. order.OwnpayAmt = ""
  9701. order.SelfpayAmt = ""
  9702. order.Spec = ""
  9703. order.SpecUnt = ""
  9704. order.DrordBegnDate = s_tm
  9705. order.DrordStopDate = ""
  9706. order.DrordDrCodg = doctor_info.DoctorNumber
  9707. order.DrordDeptName = department.Name
  9708. order.DrordDeptCodg = department.Number
  9709. order.DrordDrName = doctor_info.UserName
  9710. order.DrordDrProfttl = "234"
  9711. order.CurrDrordFlag = "1"
  9712. orders = append(orders, &order)
  9713. }
  9714. }
  9715. }
  9716. //处方医嘱信息
  9717. }
  9718. fed.MatnStas = "0"
  9719. fed.MedfeeSumamt = "0"
  9720. fed.OwnpayAmt = "0"
  9721. fed.SelfpayAmt = "0"
  9722. fed.AcctPayamt = "0"
  9723. fed.MaAmt = "0"
  9724. fed.HifpPayamt = "0"
  9725. fed.SetlTotlnum = "1"
  9726. fed.Insutype = his.Insutype
  9727. fed.ReimFlag = "0"
  9728. fed.OutSetlFlag = "0"
  9729. var fopd []*models.FsiOperationDtosData
  9730. data := make(map[string]interface{})
  9731. data["fed"] = fed
  9732. data["fdd"] = fdds
  9733. data["fod"] = orders
  9734. data["pd"] = pd
  9735. data["pp"] = pp
  9736. data["fopd"] = fopd
  9737. data["trig_scen"] = trig_scen
  9738. fmt.Println(data)
  9739. fmt.Println(fed)
  9740. fmt.Println(fdds)
  9741. fmt.Println(orders)
  9742. fmt.Println(pd)
  9743. fmt.Println(pp)
  9744. fmt.Println(fopd)
  9745. client := &http.Client{}
  9746. bytesData, _ := json.Marshal(data)
  9747. var req *http.Request
  9748. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9749. if miConfig.MdtrtareaAdmvs == "320921" {
  9750. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  9751. } else {
  9752. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  9753. }
  9754. resp, _ := client.Do(req)
  9755. defer resp.Body.Close()
  9756. body, ioErr := ioutil.ReadAll(resp.Body)
  9757. if ioErr != nil {
  9758. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9760. return res
  9761. }
  9762. var respJSON map[string]interface{}
  9763. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9764. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9766. return res
  9767. }
  9768. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  9769. fmt.Println(respJSON)
  9770. result, _ := json.Marshal(respJSON)
  9771. fmt.Println(result)
  9772. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9773. utils.ErrorLog("解析失败:%v", err)
  9774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9775. return res
  9776. }
  9777. return res
  9778. } else {
  9779. //if miConfig.MdtrtareaAdmvs == "441202" {
  9780. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  9781. saveLog(output, input, "3101", "事前")
  9782. if err := json.Unmarshal([]byte(output), &res); err != nil {
  9783. utils.ErrorLog("解析失败:%v", err)
  9784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9785. return
  9786. }
  9787. return res
  9788. //}
  9789. }
  9790. }
  9791. 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) {
  9792. adminUser := c.GetAdminUserInfo()
  9793. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9794. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9795. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9796. //record_time := c.GetString("record_time")
  9797. //trig_scen := c.GetString("trig_scen")
  9798. timeLayout := "2006-01-02"
  9799. loc, _ := time.LoadLocation("Local")
  9800. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9801. if err != nil {
  9802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9803. return res
  9804. }
  9805. recordDateTime := theTime.Unix()
  9806. var patientPrescription models.HisPrescriptionInfo
  9807. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9808. if patientPrescription.ID == 0 {
  9809. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  9810. }
  9811. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9812. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9813. //
  9814. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  9815. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9816. var pp models.PublicParams
  9817. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9818. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9819. pp.FixmedinsName = miConfig.OrgName
  9820. pp.FixmedinsCode = miConfig.Code
  9821. pp.RequestUrl = miConfig.Url
  9822. pp.Cainfo = miConfig.Cainfo
  9823. pp.SecretKey = miConfig.SecretKey
  9824. pp.AccessKey = miConfig.AccessKey
  9825. pp.OpterName = roles.UserName
  9826. var config []*models.HisXtDiagnoseConfig
  9827. for _, item := range diagnosis_ids {
  9828. id, _ := strconv.ParseInt(item, 10, 64)
  9829. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9830. config = append(config, &diagnosisConfig)
  9831. }
  9832. var pd models.PatientDtos
  9833. pd.PatnID = his.PsnNo
  9834. pd.PatnName = his.Name
  9835. pd.Gend = his.Gend
  9836. pd.Brdy = his.Brdy
  9837. pd.Poolarea = his.InsuplcAdmdvs
  9838. pd.CurrMdtrtID = his.Number
  9839. var fed models.FsiEncounterDtos
  9840. fed.MdtrtID = his.Number
  9841. fed.MedinsID = miConfig.Code
  9842. fed.MedinsName = miConfig.OrgName
  9843. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  9844. fed.MedMdtrtType = "1"
  9845. fed.MedinsType = "1"
  9846. fed.MedinsLv = "11"
  9847. tm := time.Unix(his.RecordDate, 0)
  9848. s_tm := tm.Format("2006-01-02 15:04:05")
  9849. fed.AdmDate = s_tm
  9850. fed.DscgDate = s_tm
  9851. fed.DscgMainDiseCodg = config[0].CountryCode
  9852. fed.DscgMainDiseName = config[0].CountryContentName
  9853. //诊断信息
  9854. var fdds []*models.FsiDiagnoseDtos
  9855. for index, item := range config {
  9856. if index == 0 {
  9857. var fdd models.FsiDiagnoseDtos
  9858. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9859. fdd.InoutDiseType = "1"
  9860. fdd.MaindiseFlag = "1"
  9861. fdd.DiseDate = s_tm
  9862. fdd.DiasSrtNo = "1"
  9863. fdd.DiseName = item.CountryContentName
  9864. fdd.DiseCodg = item.CountryCode
  9865. fdds = append(fdds, &fdd)
  9866. } else {
  9867. var fdd models.FsiDiagnoseDtos
  9868. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9869. fdd.InoutDiseType = "1"
  9870. fdd.MaindiseFlag = "1"
  9871. fdd.DiseDate = s_tm
  9872. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  9873. fdd.DiseName = item.CountryContentName
  9874. fdd.DiseCodg = item.CountryCode
  9875. fdds = append(fdds, &fdd)
  9876. }
  9877. }
  9878. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  9879. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  9880. fed.AdmDeptName = department.Name
  9881. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  9882. fed.DscgDeptName = department.Name
  9883. fed.MedMdtrtType = "1"
  9884. fed.MedType = "11"
  9885. //if his.Insutype == "390" {
  9886. // fed.MedType = "1402"
  9887. //} else {
  9888. // fed.MedType = "9933"
  9889. //}
  9890. var orders []*models.FsiOrderDtos
  9891. if trig_scen == "2" {
  9892. //处方医嘱信息
  9893. for _, item := range prescriptions {
  9894. for _, subItem := range item.HisDoctorAdviceInfo {
  9895. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9896. var order models.FsiOrderDtos
  9897. order.RxID = strconv.FormatInt(item.ID, 10)
  9898. order.Rxno = strconv.FormatInt(item.ID, 10)
  9899. order.LongDrordFlag = "0"
  9900. order.HilistType = "1"
  9901. order.ChrgType = "1"
  9902. order.DrordBhvr = "-"
  9903. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9904. order.HosplistName = subItem.BaseDrugLib.DrugName
  9905. order.HilistLv = "1"
  9906. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9907. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9908. order.HosplistName = subItem.BaseDrugLib.DrugName
  9909. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  9910. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9911. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  9912. order.OwnpayAmt = ""
  9913. order.SelfpayAmt = ""
  9914. order.Spec = ""
  9915. order.SpecUnt = ""
  9916. order.DrordBegnDate = s_tm
  9917. order.DrordStopDate = ""
  9918. order.DrordDrCodg = doctor_info.DoctorNumber
  9919. order.DrordDeptName = department.Name
  9920. order.DrordDeptCodg = department.Number
  9921. order.DrordDrName = doctor_info.UserName
  9922. order.DrordDrProfttl = "234"
  9923. order.CurrDrordFlag = "1"
  9924. orders = append(orders, &order)
  9925. }
  9926. }
  9927. for _, subItem := range item.HisPrescriptionProject {
  9928. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  9929. var order models.FsiOrderDtos
  9930. order.RxID = strconv.FormatInt(item.ID, 10)
  9931. order.Rxno = strconv.FormatInt(item.ID, 10)
  9932. order.LongDrordFlag = "0"
  9933. order.HilistType = "1"
  9934. order.ChrgType = "1"
  9935. order.DrordBhvr = "-"
  9936. order.HilistCode = subItem.HisProject.MedicalCode
  9937. order.HosplistName = subItem.HisProject.ProjectName
  9938. order.HilistLv = "1"
  9939. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9940. order.HosplistCode = subItem.HisProject.MedicalCode
  9941. order.HosplistName = subItem.HisProject.ProjectName
  9942. order.Cnt = subItem.Count
  9943. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9944. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9945. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  9946. order.OwnpayAmt = ""
  9947. order.SelfpayAmt = ""
  9948. order.Spec = ""
  9949. order.SpecUnt = ""
  9950. order.DrordBegnDate = s_tm
  9951. order.DrordStopDate = ""
  9952. order.DrordDrCodg = doctor_info.DoctorNumber
  9953. order.DrordDeptName = department.Name
  9954. order.DrordDeptCodg = department.Number
  9955. order.DrordDrName = doctor_info.UserName
  9956. order.DrordDrProfttl = "234"
  9957. order.CurrDrordFlag = "1"
  9958. orders = append(orders, &order)
  9959. }
  9960. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  9961. var order models.FsiOrderDtos
  9962. order.RxID = strconv.FormatInt(item.ID, 10)
  9963. order.Rxno = strconv.FormatInt(item.ID, 10)
  9964. order.LongDrordFlag = "0"
  9965. order.HilistType = "1"
  9966. order.ChrgType = "1"
  9967. order.DrordBhvr = "-"
  9968. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9969. order.HosplistName = subItem.GoodInfo.GoodName
  9970. order.HilistLv = "1"
  9971. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9972. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9973. order.HosplistName = subItem.GoodInfo.GoodName
  9974. order.Cnt = subItem.Count
  9975. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9976. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9977. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  9978. order.OwnpayAmt = ""
  9979. order.SelfpayAmt = ""
  9980. order.Spec = ""
  9981. order.SpecUnt = ""
  9982. order.DrordBegnDate = s_tm
  9983. order.DrordStopDate = ""
  9984. order.DrordDrCodg = doctor_info.DoctorNumber
  9985. order.DrordDeptName = department.Name
  9986. order.DrordDeptCodg = department.Number
  9987. order.DrordDrName = doctor_info.UserName
  9988. order.DrordDrProfttl = "234"
  9989. order.CurrDrordFlag = "1"
  9990. orders = append(orders, &order)
  9991. }
  9992. }
  9993. }
  9994. //处方医嘱信息
  9995. }
  9996. fed.MatnStas = "0"
  9997. fed.MedfeeSumamt = "0"
  9998. fed.OwnpayAmt = "0"
  9999. fed.SelfpayAmt = "0"
  10000. fed.AcctPayamt = "0"
  10001. fed.MaAmt = "0"
  10002. fed.HifpPayamt = "0"
  10003. fed.SetlTotlnum = "1"
  10004. fed.Insutype = his.Insutype
  10005. fed.ReimFlag = "0"
  10006. fed.OutSetlFlag = "0"
  10007. var fopd []*models.FsiOperationDtosData
  10008. data := make(map[string]interface{})
  10009. data["fed"] = fed
  10010. data["fdd"] = fdds
  10011. data["fod"] = orders
  10012. data["pd"] = pd
  10013. data["pp"] = pp
  10014. data["fopd"] = fopd
  10015. data["trig_scen"] = trig_scen
  10016. fmt.Println(data)
  10017. fmt.Println(fed)
  10018. fmt.Println(fdds)
  10019. fmt.Println(orders)
  10020. fmt.Println(pd)
  10021. fmt.Println(pp)
  10022. fmt.Println(fopd)
  10023. client := &http.Client{}
  10024. bytesData, _ := json.Marshal(data)
  10025. var req *http.Request
  10026. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10027. if miConfig.MdtrtareaAdmvs == "320921" {
  10028. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10029. } else {
  10030. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10031. }
  10032. resp, _ := client.Do(req)
  10033. defer resp.Body.Close()
  10034. body, ioErr := ioutil.ReadAll(resp.Body)
  10035. if ioErr != nil {
  10036. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10038. return res
  10039. }
  10040. var respJSON map[string]interface{}
  10041. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10042. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10044. return res
  10045. }
  10046. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10047. fmt.Println(respJSON)
  10048. result, _ := json.Marshal(respJSON)
  10049. fmt.Println(result)
  10050. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10051. utils.ErrorLog("解析失败:%v", err)
  10052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10053. return res
  10054. }
  10055. return res
  10056. } else {
  10057. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10058. saveLog(output, input, "3101", "事前")
  10059. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10060. utils.ErrorLog("解析失败:%v", err)
  10061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10062. return
  10063. }
  10064. return res
  10065. }
  10066. return res
  10067. }
  10068. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  10069. ////patient_id, _ := c.GetInt64("patient_id")
  10070. //order_id, _ := c.GetInt64("order_id")
  10071. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  10072. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  10073. //trig_scen := c.GetString("trig_scen")
  10074. adminUser := c.GetAdminUserInfo()
  10075. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10076. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10077. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10078. record_time := c.GetString("record_time")
  10079. order, _ := service.GetHisOrderByID(order_id)
  10080. psn_info, _ := service.GetPsnByPatientId(patient_id)
  10081. timeLayout := "2006-01-02"
  10082. loc, _ := time.LoadLocation("Local")
  10083. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10084. if err != nil {
  10085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10086. return
  10087. }
  10088. recordDateTime := theTime.Unix()
  10089. var patientPrescription models.HisPrescriptionInfo
  10090. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10091. if patientPrescription.ID == 0 {
  10092. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10093. }
  10094. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10095. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10096. //
  10097. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  10098. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10099. var pp models.PublicParams
  10100. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10101. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10102. pp.FixmedinsName = miConfig.OrgName
  10103. pp.FixmedinsCode = miConfig.Code
  10104. pp.RequestUrl = miConfig.Url
  10105. pp.Cainfo = miConfig.Cainfo
  10106. pp.SecretKey = miConfig.SecretKey
  10107. pp.AccessKey = miConfig.AccessKey
  10108. pp.OpterName = roles.UserName
  10109. var config []*models.HisXtDiagnoseConfig
  10110. for _, item := range diagnosis_ids {
  10111. id, _ := strconv.ParseInt(item, 10, 64)
  10112. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10113. config = append(config, &diagnosisConfig)
  10114. }
  10115. var pd models.PatientDtos
  10116. pd.PatnID = his.PsnNo
  10117. pd.PatnName = his.Name
  10118. pd.Gend = his.Gend
  10119. pd.Brdy = psn_info.Brdy
  10120. pd.Poolarea = his.InsuplcAdmdvs
  10121. pd.CurrMdtrtID = his.Number
  10122. var fed models.FsiEncounterDtos
  10123. fed.MdtrtID = his.Number
  10124. fed.MedinsID = miConfig.Code
  10125. fed.MedinsName = miConfig.OrgName
  10126. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10127. fed.MedMdtrtType = "1"
  10128. fed.MedinsType = "1"
  10129. fed.MedinsLv = "11"
  10130. tm := time.Unix(his.RecordDate, 0)
  10131. s_tm := tm.Format("2006-01-02 15:04:05")
  10132. fed.AdmDate = s_tm
  10133. fed.DscgDate = s_tm
  10134. fed.DscgMainDiseCodg = config[0].CountryCode
  10135. fed.DscgMainDiseName = config[0].CountryContentName
  10136. //诊断信息
  10137. var fdds []*models.FsiDiagnoseDtos
  10138. for index, item := range config {
  10139. if index == 0 {
  10140. var fdd models.FsiDiagnoseDtos
  10141. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10142. fdd.InoutDiseType = "1"
  10143. fdd.MaindiseFlag = "1"
  10144. fdd.DiseDate = s_tm
  10145. fdd.DiasSrtNo = "1"
  10146. fdd.DiseName = item.CountryContentName
  10147. fdd.DiseCodg = item.CountryCode
  10148. fdds = append(fdds, &fdd)
  10149. } else {
  10150. var fdd models.FsiDiagnoseDtos
  10151. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10152. fdd.InoutDiseType = "1"
  10153. fdd.MaindiseFlag = "1"
  10154. fdd.DiseDate = s_tm
  10155. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10156. fdd.DiseName = item.CountryContentName
  10157. fdd.DiseCodg = item.CountryCode
  10158. fdds = append(fdds, &fdd)
  10159. }
  10160. }
  10161. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10162. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10163. fed.AdmDeptName = department.Name
  10164. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10165. fed.DscgDeptName = department.Name
  10166. fed.MedType = order.MedType
  10167. //处方医嘱信息
  10168. var orders []*models.FsiOrderDtos
  10169. //for _, item := range prescriptions {
  10170. // for _, subItem := range item.HisDoctorAdviceInfo {
  10171. // var order models.FsiOrderDtos
  10172. // order.RxID = strconv.FormatInt(item.ID, 10)
  10173. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10174. // order.LongDrordFlag = "0"
  10175. // order.HilistType = "1"
  10176. // order.ChrgType = "1"
  10177. // order.DrordBhvr = "-"
  10178. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10179. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10180. // order.HilistLv = "1"
  10181. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10182. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10183. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10184. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  10185. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10186. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  10187. // order.OwnpayAmt = ""
  10188. // order.SelfpayAmt = ""
  10189. // order.Spec = ""
  10190. // order.SpecUnt = ""
  10191. // order.DrordBegnDate = s_tm
  10192. // order.DrordStopDate = ""
  10193. // order.DrordDrCodg = "1"
  10194. // order.DrordDeptName = department.Name
  10195. // order.DrordDrCodg = "1"
  10196. // order.DrordDrName = doctor_info.UserName
  10197. // order.DrordDrProfttl = ""
  10198. // order.CurrDrordFlag = "1"
  10199. // orders = append(orders, &order)
  10200. // }
  10201. // for _, subItem := range item.HisPrescriptionProject {
  10202. // if subItem.Type == 2 {
  10203. // var order models.FsiOrderDtos
  10204. // order.RxID = strconv.FormatInt(item.ID, 10)
  10205. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10206. // order.LongDrordFlag = "0"
  10207. // order.HilistType = "1"
  10208. // order.ChrgType = "1"
  10209. // order.DrordBhvr = "-"
  10210. // order.HilistCode = subItem.HisProject.MedicalCode
  10211. // order.HosplistName = subItem.HisProject.ProjectName
  10212. // order.HilistLv = "1"
  10213. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10214. // order.HosplistCode = subItem.HisProject.MedicalCode
  10215. // order.HosplistName = subItem.HisProject.ProjectName
  10216. // order.Cnt = subItem.Count
  10217. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10218. //
  10219. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10220. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10221. // order.OwnpayAmt = ""
  10222. // order.SelfpayAmt = ""
  10223. // order.Spec = ""
  10224. // order.SpecUnt = ""
  10225. // order.DrordBegnDate = s_tm
  10226. // order.DrordStopDate = ""
  10227. // order.DrordDrCodg = "1"
  10228. // order.DrordDeptName = department.Name
  10229. // order.DrordDrCodg = "1"
  10230. // order.DrordDrName = doctor_info.UserName
  10231. // order.DrordDrProfttl = ""
  10232. // order.CurrDrordFlag = "1"
  10233. // orders = append(orders, &order)
  10234. //
  10235. // }
  10236. // if subItem.Type == 3 {
  10237. //
  10238. // var order models.FsiOrderDtos
  10239. // order.RxID = strconv.FormatInt(item.ID, 10)
  10240. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10241. // order.LongDrordFlag = "0"
  10242. // order.HilistType = "1"
  10243. // order.ChrgType = "1"
  10244. // order.DrordBhvr = "-"
  10245. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10246. // order.HosplistName = subItem.GoodInfo.GoodName
  10247. // order.HilistLv = "1"
  10248. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10249. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10250. // order.HosplistName = subItem.GoodInfo.GoodName
  10251. // order.Cnt = subItem.Count
  10252. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10253. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10254. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10255. // order.OwnpayAmt = ""
  10256. // order.SelfpayAmt = ""
  10257. // order.Spec = ""
  10258. // order.SpecUnt = ""
  10259. // order.DrordBegnDate = s_tm
  10260. // order.DrordStopDate = ""
  10261. // order.DrordDrCodg = "1"
  10262. // order.DrordDeptName = department.Name
  10263. // order.DrordDrCodg = "1"
  10264. // order.DrordDrName = doctor_info.UserName
  10265. // order.DrordDrProfttl = ""
  10266. // order.CurrDrordFlag = "1"
  10267. // orders = append(orders, &order)
  10268. //
  10269. // }
  10270. // }
  10271. //}
  10272. for _, item := range prescriptions {
  10273. for _, subItem := range item.HisDoctorAdviceInfo {
  10274. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10275. var order models.FsiOrderDtos
  10276. order.RxID = strconv.FormatInt(item.ID, 10)
  10277. order.Rxno = strconv.FormatInt(item.ID, 10)
  10278. order.LongDrordFlag = "0"
  10279. order.HilistType = "1"
  10280. order.ChrgType = "1"
  10281. order.DrordBhvr = "-"
  10282. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10283. order.HosplistName = subItem.BaseDrugLib.DrugName
  10284. order.HilistLv = "1"
  10285. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10286. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10287. order.HosplistName = subItem.BaseDrugLib.DrugName
  10288. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10289. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10290. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10291. order.OwnpayAmt = ""
  10292. order.SelfpayAmt = ""
  10293. order.Spec = ""
  10294. order.SpecUnt = ""
  10295. order.DrordBegnDate = s_tm
  10296. order.DrordStopDate = ""
  10297. order.DrordDrCodg = doctor_info.DoctorNumber
  10298. order.DrordDeptName = department.Name
  10299. order.DrordDeptCodg = department.Number
  10300. order.DrordDrName = doctor_info.UserName
  10301. order.DrordDrProfttl = "234"
  10302. order.CurrDrordFlag = "1"
  10303. orders = append(orders, &order)
  10304. }
  10305. }
  10306. for _, subItem := range item.HisPrescriptionProject {
  10307. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10308. var order models.FsiOrderDtos
  10309. order.RxID = strconv.FormatInt(item.ID, 10)
  10310. order.Rxno = strconv.FormatInt(item.ID, 10)
  10311. order.LongDrordFlag = "0"
  10312. order.HilistType = "1"
  10313. order.ChrgType = "1"
  10314. order.DrordBhvr = "-"
  10315. order.HilistCode = subItem.HisProject.MedicalCode
  10316. order.HosplistName = subItem.HisProject.ProjectName
  10317. order.HilistLv = "1"
  10318. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10319. order.HosplistCode = subItem.HisProject.MedicalCode
  10320. order.HosplistName = subItem.HisProject.ProjectName
  10321. order.Cnt = subItem.Count
  10322. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10323. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10324. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10325. order.OwnpayAmt = ""
  10326. order.SelfpayAmt = ""
  10327. order.Spec = ""
  10328. order.SpecUnt = ""
  10329. order.DrordBegnDate = s_tm
  10330. order.DrordStopDate = ""
  10331. order.DrordDrCodg = doctor_info.DoctorNumber
  10332. order.DrordDeptName = department.Name
  10333. order.DrordDeptCodg = department.Number
  10334. order.DrordDrName = doctor_info.UserName
  10335. order.DrordDrProfttl = "234"
  10336. order.CurrDrordFlag = "1"
  10337. orders = append(orders, &order)
  10338. }
  10339. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10340. var order models.FsiOrderDtos
  10341. order.RxID = strconv.FormatInt(item.ID, 10)
  10342. order.Rxno = strconv.FormatInt(item.ID, 10)
  10343. order.LongDrordFlag = "0"
  10344. order.HilistType = "1"
  10345. order.ChrgType = "1"
  10346. order.DrordBhvr = "0"
  10347. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10348. order.HosplistName = subItem.GoodInfo.GoodName
  10349. order.HilistLv = "1"
  10350. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10351. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10352. order.HosplistName = subItem.GoodInfo.GoodName
  10353. order.Cnt = subItem.Count
  10354. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10355. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10356. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10357. order.OwnpayAmt = ""
  10358. order.SelfpayAmt = ""
  10359. order.Spec = ""
  10360. order.SpecUnt = ""
  10361. order.DrordBegnDate = s_tm
  10362. order.DrordStopDate = ""
  10363. order.DrordDrCodg = doctor_info.DoctorNumber
  10364. order.DrordDeptName = department.Name
  10365. order.DrordDeptCodg = department.Number
  10366. order.DrordDrName = doctor_info.UserName
  10367. order.DrordDrProfttl = "234"
  10368. order.CurrDrordFlag = "1"
  10369. orders = append(orders, &order)
  10370. }
  10371. }
  10372. }
  10373. //处方医嘱信息
  10374. fed.MatnStas = "0"
  10375. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  10376. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  10377. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  10378. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  10379. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  10380. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  10381. fed.SetlTotlnum = "1"
  10382. fed.Insutype = his.Insutype
  10383. fed.ReimFlag = "0"
  10384. fed.OutSetlFlag = "0"
  10385. var fopd []*models.FsiOperationDtosData
  10386. data := make(map[string]interface{})
  10387. data["fed"] = fed
  10388. data["fdd"] = fdds
  10389. data["fod"] = orders
  10390. data["pd"] = pd
  10391. data["pp"] = pp
  10392. data["fopd"] = fopd
  10393. data["trig_scen"] = trig_scen
  10394. client := &http.Client{}
  10395. bytesData, _ := json.Marshal(data)
  10396. var req *http.Request
  10397. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10398. if miConfig.MdtrtareaAdmvs == "320921" {
  10399. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  10400. } else {
  10401. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  10402. }
  10403. resp, _ := client.Do(req)
  10404. defer resp.Body.Close()
  10405. body, ioErr := ioutil.ReadAll(resp.Body)
  10406. if ioErr != nil {
  10407. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10409. return res
  10410. }
  10411. var respJSON map[string]interface{}
  10412. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10413. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10415. return res
  10416. }
  10417. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10418. result, _ := json.Marshal(respJSON)
  10419. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10420. utils.ErrorLog("解析失败:%v", err)
  10421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10422. return res
  10423. }
  10424. return res
  10425. } else {
  10426. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10427. saveLog(output, input, "3102", "事中")
  10428. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10429. utils.ErrorLog("解析失败:%v", err)
  10430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10431. return
  10432. }
  10433. return res
  10434. }
  10435. return res
  10436. }
  10437. 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) {
  10438. var res Resultgd3101
  10439. adminUser := c.GetAdminUserInfo()
  10440. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10441. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10442. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10443. //record_time := c.GetString("record_time")
  10444. //trig_scen := c.GetString("trig_scen")
  10445. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  10446. //psn_info, _ := service.GetPatientId(patient_id)
  10447. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  10448. timeLayout := "2006-01-02"
  10449. loc, _ := time.LoadLocation("Local")
  10450. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10451. if err != nil {
  10452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10453. return res
  10454. }
  10455. recordDateTime := theTime.Unix()
  10456. var patientPrescription models.HisPrescriptionInfo
  10457. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10458. //if patientPrescription.ID == 0 {
  10459. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10460. //}
  10461. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10462. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10463. //
  10464. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10465. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10466. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  10467. var pp models.PublicParams
  10468. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10469. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10470. pp.FixmedinsName = miConfig.OrgName
  10471. pp.FixmedinsCode = miConfig.Code
  10472. pp.RequestUrl = miConfig.Url
  10473. pp.Cainfo = miConfig.Cainfo
  10474. pp.SecretKey = miConfig.SecretKey
  10475. pp.AccessKey = miConfig.AccessKey
  10476. pp.OpterName = roles.UserName
  10477. var config []*models.HisXtDiagnoseConfig
  10478. for _, item := range diagnosis_ids {
  10479. id, _ := strconv.ParseInt(item, 10, 64)
  10480. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10481. config = append(config, &diagnosisConfig)
  10482. }
  10483. var pd models.PatientDtos
  10484. pd.PatnID = his.PsnNo
  10485. pd.PatnName = his.Name
  10486. pd.Gend = his.Gend
  10487. pd.Brdy = str
  10488. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10489. pd.CurrMdtrtID = his.Number
  10490. var fed models.FsiEncounterDtos
  10491. fed.MdtrtID = his.Number
  10492. fed.MedinsID = miConfig.Code
  10493. fed.MedinsName = miConfig.OrgName
  10494. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10495. fed.MedMdtrtType = "1"
  10496. fed.MedinsType = "1"
  10497. fed.MedinsLv = "11"
  10498. tm := time.Unix(his.RecordDate, 0)
  10499. s_tm := tm.Format("2006-01-02 15:04:05")
  10500. fed.AdmDate = s_tm
  10501. fed.DscgDate = s_tm
  10502. fed.DscgMainDiseCodg = config[0].CountryCode
  10503. fed.DscgMainDiseName = config[0].CountryContentName
  10504. //诊断信息
  10505. var fdds []*models.FsiDiagnoseDtos
  10506. for index, item := range config {
  10507. if index == 0 {
  10508. var fdd models.FsiDiagnoseDtos
  10509. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10510. fdd.InoutDiseType = "1"
  10511. fdd.MaindiseFlag = "1"
  10512. fdd.DiseDate = s_tm
  10513. fdd.DiasSrtNo = "1"
  10514. fdd.DiseName = item.CountryContentName
  10515. fdd.DiseCodg = item.CountryCode
  10516. fdds = append(fdds, &fdd)
  10517. } else {
  10518. var fdd models.FsiDiagnoseDtos
  10519. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10520. fdd.InoutDiseType = "1"
  10521. fdd.MaindiseFlag = "1"
  10522. fdd.DiseDate = s_tm
  10523. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10524. fdd.DiseName = item.CountryContentName
  10525. fdd.DiseCodg = item.CountryCode
  10526. fdds = append(fdds, &fdd)
  10527. }
  10528. }
  10529. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10530. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  10531. fed.AdmDeptName = de.Name
  10532. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  10533. fed.DscgDeptName = de.Name
  10534. fed.MedMdtrtType = "1"
  10535. fed.MedType = "11"
  10536. //if his.Insutype == "390" {
  10537. // fed.MedType = "1402"
  10538. //} else {
  10539. // fed.MedType = "9933"
  10540. //}
  10541. var orders []*models.FsiOrderDtos
  10542. if trig_scen == "2" {
  10543. //处方医嘱信息
  10544. for _, item := range prescriptions {
  10545. for _, subItem := range item.HisDoctorAdviceInfo {
  10546. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10547. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  10548. var order models.FsiOrderDtos
  10549. order.RxID = strconv.FormatInt(item.ID, 10)
  10550. order.Rxno = strconv.FormatInt(item.ID, 10)
  10551. order.LongDrordFlag = "0"
  10552. order.HilistType = "1"
  10553. order.ChrgType = "1"
  10554. order.DrordBhvr = "0"
  10555. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10556. order.HosplistName = subItem.BaseDrugLib.DrugName
  10557. order.HilistLv = "1"
  10558. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10559. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10560. order.HosplistName = subItem.BaseDrugLib.DrugName
  10561. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10562. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10563. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10564. order.OwnpayAmt = ""
  10565. order.SelfpayAmt = ""
  10566. order.Spec = spec
  10567. order.SpecUnt = subItem.PrescribingNumberUnit
  10568. order.DrordBegnDate = s_tm
  10569. order.DrordStopDate = ""
  10570. order.DrordDrCodg = doctor_info.DoctorNumber
  10571. order.DrordDeptName = department.Name
  10572. order.DrordDeptCodg = department.Number
  10573. order.DrordDrName = doctor_info.UserName
  10574. order.DrordDrProfttl = "234"
  10575. order.CurrDrordFlag = "1"
  10576. orders = append(orders, &order)
  10577. }
  10578. }
  10579. for _, subItem := range item.HisPrescriptionProject {
  10580. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10581. var order models.FsiOrderDtos
  10582. order.RxID = strconv.FormatInt(item.ID, 10)
  10583. order.Rxno = strconv.FormatInt(item.ID, 10)
  10584. order.LongDrordFlag = "0"
  10585. order.HilistType = "1"
  10586. order.ChrgType = "1"
  10587. order.DrordBhvr = "0"
  10588. order.HilistCode = subItem.HisProject.MedicalCode
  10589. order.HosplistName = subItem.HisProject.ProjectName
  10590. order.HilistLv = "1"
  10591. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10592. order.HosplistCode = subItem.HisProject.MedicalCode
  10593. order.HosplistName = subItem.HisProject.ProjectName
  10594. order.Cnt = subItem.Count
  10595. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10596. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10597. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10598. order.OwnpayAmt = ""
  10599. order.SelfpayAmt = ""
  10600. order.Spec = subItem.Unit
  10601. order.SpecUnt = subItem.Unit
  10602. order.DrordBegnDate = s_tm
  10603. order.DrordStopDate = ""
  10604. order.DrordDrCodg = doctor_info.DoctorNumber
  10605. order.DrordDeptName = department.Name
  10606. order.DrordDeptCodg = department.Number
  10607. order.DrordDrName = doctor_info.UserName
  10608. order.DrordDrProfttl = "234"
  10609. order.CurrDrordFlag = "1"
  10610. orders = append(orders, &order)
  10611. }
  10612. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10613. var order models.FsiOrderDtos
  10614. order.RxID = strconv.FormatInt(item.ID, 10)
  10615. order.Rxno = strconv.FormatInt(item.ID, 10)
  10616. order.LongDrordFlag = "0"
  10617. order.HilistType = "1"
  10618. order.ChrgType = "1"
  10619. order.DrordBhvr = "0"
  10620. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10621. order.HosplistName = subItem.GoodInfo.GoodName
  10622. order.HilistLv = "1"
  10623. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10624. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10625. order.HosplistName = subItem.GoodInfo.GoodName
  10626. order.Cnt = subItem.Count
  10627. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10628. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10629. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10630. order.OwnpayAmt = ""
  10631. order.SelfpayAmt = ""
  10632. order.Spec = subItem.GoodInfo.SpecificationName
  10633. order.SpecUnt = subItem.Unit
  10634. order.DrordBegnDate = s_tm
  10635. order.DrordStopDate = ""
  10636. order.DrordDrCodg = doctor_info.DoctorNumber
  10637. order.DrordDeptName = department.Name
  10638. order.DrordDeptCodg = department.Number
  10639. order.DrordDrName = doctor_info.UserName
  10640. order.DrordDrProfttl = "234"
  10641. order.CurrDrordFlag = "1"
  10642. orders = append(orders, &order)
  10643. }
  10644. }
  10645. }
  10646. //处方医嘱信息
  10647. }
  10648. fed.MatnStas = "0"
  10649. fed.MedfeeSumamt = "0"
  10650. fed.OwnpayAmt = "0"
  10651. fed.SelfpayAmt = "0"
  10652. fed.AcctPayamt = "0"
  10653. fed.MaAmt = "0"
  10654. fed.HifpPayamt = "0"
  10655. fed.SetlTotlnum = "1"
  10656. fed.Insutype = his.Insutype
  10657. fed.ReimFlag = "0"
  10658. fed.OutSetlFlag = "0"
  10659. var fopd []*models.FsiOperationDtosData
  10660. data := make(map[string]interface{})
  10661. data["fed"] = fed
  10662. data["fdd"] = fdds
  10663. data["fod"] = orders
  10664. data["pd"] = pd
  10665. data["pp"] = pp
  10666. data["fopd"] = fopd
  10667. data["trig_scen"] = trig_scen
  10668. fmt.Println(data)
  10669. fmt.Println(fed)
  10670. fmt.Println(fdds)
  10671. fmt.Println(orders)
  10672. fmt.Println(pd)
  10673. fmt.Println(pp)
  10674. fmt.Println(fopd)
  10675. client := &http.Client{}
  10676. bytesData, _ := json.Marshal(data)
  10677. var req *http.Request
  10678. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10679. if miConfig.MdtrtareaAdmvs == "320921" {
  10680. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10681. } else {
  10682. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10683. }
  10684. resp, _ := client.Do(req)
  10685. defer resp.Body.Close()
  10686. body, ioErr := ioutil.ReadAll(resp.Body)
  10687. if ioErr != nil {
  10688. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10690. return res
  10691. }
  10692. var respJSON map[string]interface{}
  10693. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10694. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10696. return res
  10697. }
  10698. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10699. fmt.Println(respJSON)
  10700. result, _ := json.Marshal(respJSON)
  10701. fmt.Println(result)
  10702. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10703. utils.ErrorLog("解析失败:%v", err)
  10704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10705. return res
  10706. }
  10707. return res
  10708. } else {
  10709. //if miConfig.MdtrtareaAdmvs == "441202" {
  10710. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10711. saveLog(output, input, "3101", "事前")
  10712. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10713. utils.ErrorLog("解析失败:%v", err)
  10714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10715. return
  10716. }
  10717. return res
  10718. //}
  10719. }
  10720. }
  10721. 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) {
  10722. adminUser := c.GetAdminUserInfo()
  10723. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10724. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10725. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10726. //record_time := c.GetString("record_time")
  10727. //trig_scen := c.GetString("trig_scen")
  10728. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  10729. timeLayout := "2006-01-02"
  10730. loc, _ := time.LoadLocation("Local")
  10731. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10732. if err != nil {
  10733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10734. return res
  10735. }
  10736. recordDateTime := theTime.Unix()
  10737. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  10738. var patientPrescription models.HisPrescriptionInfo
  10739. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10740. if patientPrescription.ID == 0 {
  10741. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10742. }
  10743. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10744. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10745. //
  10746. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10747. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10748. var pp models.PublicParams
  10749. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10750. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10751. pp.FixmedinsName = miConfig.OrgName
  10752. pp.FixmedinsCode = miConfig.Code
  10753. pp.RequestUrl = miConfig.Url
  10754. pp.Cainfo = miConfig.Cainfo
  10755. pp.SecretKey = miConfig.SecretKey
  10756. pp.AccessKey = miConfig.AccessKey
  10757. pp.OpterName = roles.UserName
  10758. var config []*models.HisXtDiagnoseConfig
  10759. for _, item := range diagnosis_ids {
  10760. id, _ := strconv.ParseInt(item, 10, 64)
  10761. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10762. config = append(config, &diagnosisConfig)
  10763. }
  10764. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  10765. var pd models.PatientDtos
  10766. pd.PatnID = his.PsnNo
  10767. pd.PatnName = his.Name
  10768. pd.Gend = his.Gend
  10769. pd.Brdy = str
  10770. pd.Poolarea = his.InsuplcAdmdvs
  10771. pd.CurrMdtrtID = his.Number
  10772. var fed models.FsiEncounterDtos
  10773. fed.MdtrtID = his.Number
  10774. fed.MedinsID = miConfig.Code
  10775. fed.MedinsName = miConfig.OrgName
  10776. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10777. fed.MedMdtrtType = "1"
  10778. fed.MedinsType = "1"
  10779. fed.MedinsLv = "11"
  10780. tm := time.Unix(his.RecordDate, 0)
  10781. s_tm := tm.Format("2006-01-02 15:04:05")
  10782. fed.AdmDate = s_tm
  10783. fed.DscgDate = s_tm
  10784. fed.DscgMainDiseCodg = config[0].CountryCode
  10785. fed.DscgMainDiseName = config[0].CountryContentName
  10786. //诊断信息
  10787. var fdds []*models.FsiDiagnoseDtos
  10788. for index, item := range config {
  10789. if index == 0 {
  10790. var fdd models.FsiDiagnoseDtos
  10791. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10792. fdd.InoutDiseType = "1"
  10793. fdd.MaindiseFlag = "1"
  10794. fdd.DiseDate = s_tm
  10795. fdd.DiasSrtNo = "1"
  10796. fdd.DiseName = item.CountryContentName
  10797. fdd.DiseCodg = item.CountryCode
  10798. fdds = append(fdds, &fdd)
  10799. } else {
  10800. var fdd models.FsiDiagnoseDtos
  10801. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10802. fdd.InoutDiseType = "1"
  10803. fdd.MaindiseFlag = "1"
  10804. fdd.DiseDate = s_tm
  10805. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10806. fdd.DiseName = item.CountryContentName
  10807. fdd.DiseCodg = item.CountryCode
  10808. fdds = append(fdds, &fdd)
  10809. }
  10810. }
  10811. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10812. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10813. fed.AdmDeptName = department.Name
  10814. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10815. fed.DscgDeptName = department.Name
  10816. fed.MedMdtrtType = "1"
  10817. fed.MedType = "11"
  10818. //if his.Insutype == "390" {
  10819. // fed.MedType = "1402"
  10820. //} else {
  10821. // fed.MedType = "9933"
  10822. //}
  10823. var orders []*models.FsiOrderDtos
  10824. if trig_scen == "2" {
  10825. //处方医嘱信息
  10826. for _, item := range prescriptions {
  10827. for _, subItem := range item.HisDoctorAdviceInfo {
  10828. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10829. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  10830. var order models.FsiOrderDtos
  10831. order.RxID = strconv.FormatInt(item.ID, 10)
  10832. order.Rxno = strconv.FormatInt(item.ID, 10)
  10833. order.LongDrordFlag = "0"
  10834. order.HilistType = "1"
  10835. order.ChrgType = "1"
  10836. order.DrordBhvr = "0"
  10837. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10838. order.HosplistName = subItem.BaseDrugLib.DrugName
  10839. order.HilistLv = "1"
  10840. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10841. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10842. order.HosplistName = subItem.BaseDrugLib.DrugName
  10843. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10844. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10845. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10846. order.OwnpayAmt = ""
  10847. order.SelfpayAmt = ""
  10848. order.Spec = spec
  10849. order.SpecUnt = subItem.PrescribingNumberUnit
  10850. order.DrordBegnDate = s_tm
  10851. order.DrordStopDate = ""
  10852. order.DrordDrCodg = doctor_info.DoctorNumber
  10853. order.DrordDeptName = department.Name
  10854. order.DrordDeptCodg = department.Number
  10855. order.DrordDrName = doctor_info.UserName
  10856. order.DrordDrProfttl = "234"
  10857. order.CurrDrordFlag = "1"
  10858. orders = append(orders, &order)
  10859. }
  10860. }
  10861. for _, subItem := range item.HisPrescriptionProject {
  10862. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10863. var order models.FsiOrderDtos
  10864. order.RxID = strconv.FormatInt(item.ID, 10)
  10865. order.Rxno = strconv.FormatInt(item.ID, 10)
  10866. order.LongDrordFlag = "0"
  10867. order.HilistType = "1"
  10868. order.ChrgType = "1"
  10869. order.DrordBhvr = "0"
  10870. order.HilistCode = subItem.HisProject.MedicalCode
  10871. order.HosplistName = subItem.HisProject.ProjectName
  10872. order.HilistLv = "1"
  10873. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10874. order.HosplistCode = subItem.HisProject.MedicalCode
  10875. order.HosplistName = subItem.HisProject.ProjectName
  10876. order.Cnt = subItem.Count
  10877. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10878. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10879. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10880. order.OwnpayAmt = ""
  10881. order.SelfpayAmt = ""
  10882. order.Spec = subItem.Unit
  10883. order.SpecUnt = subItem.Unit
  10884. order.DrordBegnDate = s_tm
  10885. order.DrordStopDate = ""
  10886. order.DrordDrCodg = doctor_info.DoctorNumber
  10887. order.DrordDeptName = department.Name
  10888. order.DrordDeptCodg = department.Number
  10889. order.DrordDrName = doctor_info.UserName
  10890. order.DrordDrProfttl = "234"
  10891. order.CurrDrordFlag = "1"
  10892. orders = append(orders, &order)
  10893. }
  10894. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10895. var order models.FsiOrderDtos
  10896. order.RxID = strconv.FormatInt(item.ID, 10)
  10897. order.Rxno = strconv.FormatInt(item.ID, 10)
  10898. order.LongDrordFlag = "0"
  10899. order.HilistType = "1"
  10900. order.ChrgType = "1"
  10901. order.DrordBhvr = "0"
  10902. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10903. order.HosplistName = subItem.GoodInfo.GoodName
  10904. order.HilistLv = "1"
  10905. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10906. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10907. order.HosplistName = subItem.GoodInfo.GoodName
  10908. order.Cnt = subItem.Count
  10909. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10910. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10911. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10912. order.OwnpayAmt = ""
  10913. order.SelfpayAmt = ""
  10914. order.Spec = subItem.GoodInfo.SpecificationName
  10915. order.SpecUnt = subItem.Unit
  10916. order.DrordBegnDate = s_tm
  10917. order.DrordStopDate = ""
  10918. order.DrordDrCodg = doctor_info.DoctorNumber
  10919. order.DrordDeptName = department.Name
  10920. order.DrordDeptCodg = department.Number
  10921. order.DrordDrName = doctor_info.UserName
  10922. order.DrordDrProfttl = "234"
  10923. order.CurrDrordFlag = "1"
  10924. orders = append(orders, &order)
  10925. }
  10926. }
  10927. }
  10928. //处方医嘱信息
  10929. }
  10930. fed.MatnStas = "0"
  10931. fed.MedfeeSumamt = "0"
  10932. fed.OwnpayAmt = "0"
  10933. fed.SelfpayAmt = "0"
  10934. fed.AcctPayamt = "0"
  10935. fed.MaAmt = "0"
  10936. fed.HifpPayamt = "0"
  10937. fed.SetlTotlnum = "1"
  10938. fed.Insutype = his.Insutype
  10939. fed.ReimFlag = "0"
  10940. fed.OutSetlFlag = "0"
  10941. var fopd []*models.FsiOperationDtosData
  10942. data := make(map[string]interface{})
  10943. data["fed"] = fed
  10944. data["fdd"] = fdds
  10945. data["fod"] = orders
  10946. data["pd"] = pd
  10947. data["pp"] = pp
  10948. data["fopd"] = fopd
  10949. data["trig_scen"] = trig_scen
  10950. fmt.Println(data)
  10951. fmt.Println(fed)
  10952. fmt.Println(fdds)
  10953. fmt.Println(orders)
  10954. fmt.Println(pd)
  10955. fmt.Println(pp)
  10956. fmt.Println(fopd)
  10957. client := &http.Client{}
  10958. bytesData, _ := json.Marshal(data)
  10959. var req *http.Request
  10960. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10961. if miConfig.MdtrtareaAdmvs == "320921" {
  10962. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10963. } else {
  10964. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10965. }
  10966. resp, _ := client.Do(req)
  10967. defer resp.Body.Close()
  10968. body, ioErr := ioutil.ReadAll(resp.Body)
  10969. if ioErr != nil {
  10970. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10972. return res
  10973. }
  10974. var respJSON map[string]interface{}
  10975. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10976. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10978. return res
  10979. }
  10980. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10981. fmt.Println(respJSON)
  10982. result, _ := json.Marshal(respJSON)
  10983. fmt.Println(result)
  10984. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10985. utils.ErrorLog("解析失败:%v", err)
  10986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10987. return res
  10988. }
  10989. return res
  10990. } else {
  10991. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10992. saveLog(output, input, "3101", "事前")
  10993. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10994. utils.ErrorLog("解析失败:%v", err)
  10995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10996. return
  10997. }
  10998. return res
  10999. }
  11000. return res
  11001. }
  11002. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  11003. ////patient_id, _ := c.GetInt64("patient_id")
  11004. //order_id, _ := c.GetInt64("order_id")
  11005. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11006. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11007. //trig_scen := c.GetString("trig_scen")
  11008. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11009. //utils.ErrorLog("解析失败:%v", psn_info)
  11010. adminUser := c.GetAdminUserInfo()
  11011. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11012. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11013. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11014. record_time := c.GetString("record_time")
  11015. order, _ := service.GetHisOrderByID(order_id)
  11016. timeLayout := "2006-01-02"
  11017. loc, _ := time.LoadLocation("Local")
  11018. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11019. if err != nil {
  11020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11021. return
  11022. }
  11023. recordDateTime := theTime.Unix()
  11024. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11025. var patientPrescription models.HisPrescriptionInfo
  11026. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11027. if patientPrescription.ID == 0 {
  11028. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11029. }
  11030. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11031. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11032. //
  11033. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11034. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11035. var pp models.PublicParams
  11036. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11037. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11038. pp.FixmedinsName = miConfig.OrgName
  11039. pp.FixmedinsCode = miConfig.Code
  11040. pp.RequestUrl = miConfig.Url
  11041. pp.Cainfo = miConfig.Cainfo
  11042. pp.SecretKey = miConfig.SecretKey
  11043. pp.AccessKey = miConfig.AccessKey
  11044. pp.OpterName = roles.UserName
  11045. var config []*models.HisXtDiagnoseConfig
  11046. for _, item := range diagnosis_ids {
  11047. id, _ := strconv.ParseInt(item, 10, 64)
  11048. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11049. config = append(config, &diagnosisConfig)
  11050. }
  11051. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  11052. var pd models.PatientDtos
  11053. pd.PatnID = his.PsnNo
  11054. pd.PatnName = his.Name
  11055. pd.Gend = his.Gend
  11056. pd.Brdy = str
  11057. pd.Poolarea = his.InsuplcAdmdvs
  11058. pd.CurrMdtrtID = his.Number
  11059. var fed models.FsiEncounterDtos
  11060. fed.MdtrtID = his.Number
  11061. fed.MedinsID = miConfig.Code
  11062. fed.MedinsName = miConfig.OrgName
  11063. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11064. fed.MedMdtrtType = "1"
  11065. fed.MedinsType = "1"
  11066. fed.MedinsLv = "11"
  11067. tm := time.Unix(his.RecordDate, 0)
  11068. s_tm := tm.Format("2006-01-02 15:04:05")
  11069. fed.AdmDate = s_tm
  11070. fed.DscgDate = s_tm
  11071. fed.DscgMainDiseCodg = config[0].CountryCode
  11072. fed.DscgMainDiseName = config[0].CountryContentName
  11073. //诊断信息
  11074. var fdds []*models.FsiDiagnoseDtos
  11075. for index, item := range config {
  11076. if index == 0 {
  11077. var fdd models.FsiDiagnoseDtos
  11078. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11079. fdd.InoutDiseType = "1"
  11080. fdd.MaindiseFlag = "1"
  11081. fdd.DiseDate = s_tm
  11082. fdd.DiasSrtNo = "1"
  11083. fdd.DiseName = item.CountryContentName
  11084. fdd.DiseCodg = item.CountryCode
  11085. fdds = append(fdds, &fdd)
  11086. } else {
  11087. var fdd models.FsiDiagnoseDtos
  11088. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11089. fdd.InoutDiseType = "1"
  11090. fdd.MaindiseFlag = "1"
  11091. fdd.DiseDate = s_tm
  11092. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11093. fdd.DiseName = item.CountryContentName
  11094. fdd.DiseCodg = item.CountryCode
  11095. fdds = append(fdds, &fdd)
  11096. }
  11097. }
  11098. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11099. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11100. fed.AdmDeptName = department.Name
  11101. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11102. fed.DscgDeptName = department.Name
  11103. fed.MedType = order.MedType
  11104. //处方医嘱信息
  11105. var orders []*models.FsiOrderDtos
  11106. //for _, item := range prescriptions {
  11107. // for _, subItem := range item.HisDoctorAdviceInfo {
  11108. // var order models.FsiOrderDtos
  11109. // order.RxID = strconv.FormatInt(item.ID, 10)
  11110. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11111. // order.LongDrordFlag = "0"
  11112. // order.HilistType = "1"
  11113. // order.ChrgType = "1"
  11114. // order.DrordBhvr = "-"
  11115. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11116. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11117. // order.HilistLv = "1"
  11118. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11119. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11120. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11121. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11122. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11123. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11124. // order.OwnpayAmt = ""
  11125. // order.SelfpayAmt = ""
  11126. // order.Spec = ""
  11127. // order.SpecUnt = ""
  11128. // order.DrordBegnDate = s_tm
  11129. // order.DrordStopDate = ""
  11130. // order.DrordDrCodg = "1"
  11131. // order.DrordDeptName = department.Name
  11132. // order.DrordDrCodg = "1"
  11133. // order.DrordDrName = doctor_info.UserName
  11134. // order.DrordDrProfttl = ""
  11135. // order.CurrDrordFlag = "1"
  11136. // orders = append(orders, &order)
  11137. // }
  11138. // for _, subItem := range item.HisPrescriptionProject {
  11139. // if subItem.Type == 2 {
  11140. // var order models.FsiOrderDtos
  11141. // order.RxID = strconv.FormatInt(item.ID, 10)
  11142. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11143. // order.LongDrordFlag = "0"
  11144. // order.HilistType = "1"
  11145. // order.ChrgType = "1"
  11146. // order.DrordBhvr = "-"
  11147. // order.HilistCode = subItem.HisProject.MedicalCode
  11148. // order.HosplistName = subItem.HisProject.ProjectName
  11149. // order.HilistLv = "1"
  11150. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11151. // order.HosplistCode = subItem.HisProject.MedicalCode
  11152. // order.HosplistName = subItem.HisProject.ProjectName
  11153. // order.Cnt = subItem.Count
  11154. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11155. //
  11156. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11157. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11158. // order.OwnpayAmt = ""
  11159. // order.SelfpayAmt = ""
  11160. // order.Spec = ""
  11161. // order.SpecUnt = ""
  11162. // order.DrordBegnDate = s_tm
  11163. // order.DrordStopDate = ""
  11164. // order.DrordDrCodg = "1"
  11165. // order.DrordDeptName = department.Name
  11166. // order.DrordDrCodg = "1"
  11167. // order.DrordDrName = doctor_info.UserName
  11168. // order.DrordDrProfttl = ""
  11169. // order.CurrDrordFlag = "1"
  11170. // orders = append(orders, &order)
  11171. //
  11172. // }
  11173. // if subItem.Type == 3 {
  11174. //
  11175. // var order models.FsiOrderDtos
  11176. // order.RxID = strconv.FormatInt(item.ID, 10)
  11177. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11178. // order.LongDrordFlag = "0"
  11179. // order.HilistType = "1"
  11180. // order.ChrgType = "1"
  11181. // order.DrordBhvr = "-"
  11182. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11183. // order.HosplistName = subItem.GoodInfo.GoodName
  11184. // order.HilistLv = "1"
  11185. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11186. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11187. // order.HosplistName = subItem.GoodInfo.GoodName
  11188. // order.Cnt = subItem.Count
  11189. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11190. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11191. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11192. // order.OwnpayAmt = ""
  11193. // order.SelfpayAmt = ""
  11194. // order.Spec = ""
  11195. // order.SpecUnt = ""
  11196. // order.DrordBegnDate = s_tm
  11197. // order.DrordStopDate = ""
  11198. // order.DrordDrCodg = "1"
  11199. // order.DrordDeptName = department.Name
  11200. // order.DrordDrCodg = "1"
  11201. // order.DrordDrName = doctor_info.UserName
  11202. // order.DrordDrProfttl = ""
  11203. // order.CurrDrordFlag = "1"
  11204. // orders = append(orders, &order)
  11205. //
  11206. // }
  11207. // }
  11208. //}
  11209. for _, item := range prescriptions {
  11210. for _, subItem := range item.HisDoctorAdviceInfo {
  11211. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11212. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11213. var order models.FsiOrderDtos
  11214. order.RxID = strconv.FormatInt(item.ID, 10)
  11215. order.Rxno = strconv.FormatInt(item.ID, 10)
  11216. order.LongDrordFlag = "0"
  11217. order.HilistType = "1"
  11218. order.ChrgType = "1"
  11219. order.DrordBhvr = "0"
  11220. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11221. order.HosplistName = subItem.BaseDrugLib.DrugName
  11222. order.HilistLv = "1"
  11223. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11224. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11225. order.HosplistName = subItem.BaseDrugLib.DrugName
  11226. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11227. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11228. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11229. order.OwnpayAmt = ""
  11230. order.SelfpayAmt = ""
  11231. order.Spec = spec
  11232. order.SpecUnt = subItem.PrescribingNumberUnit
  11233. order.DrordBegnDate = s_tm
  11234. order.DrordStopDate = ""
  11235. order.DrordDrCodg = doctor_info.DoctorNumber
  11236. order.DrordDeptName = department.Name
  11237. order.DrordDeptCodg = department.Number
  11238. order.DrordDrName = doctor_info.UserName
  11239. order.DrordDrProfttl = "234"
  11240. order.CurrDrordFlag = "1"
  11241. orders = append(orders, &order)
  11242. }
  11243. }
  11244. for _, subItem := range item.HisPrescriptionProject {
  11245. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11246. var order models.FsiOrderDtos
  11247. order.RxID = strconv.FormatInt(item.ID, 10)
  11248. order.Rxno = strconv.FormatInt(item.ID, 10)
  11249. order.LongDrordFlag = "0"
  11250. order.HilistType = "1"
  11251. order.ChrgType = "1"
  11252. order.DrordBhvr = "0"
  11253. order.HilistCode = subItem.HisProject.MedicalCode
  11254. order.HosplistName = subItem.HisProject.ProjectName
  11255. order.HilistLv = "1"
  11256. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11257. order.HosplistCode = subItem.HisProject.MedicalCode
  11258. order.HosplistName = subItem.HisProject.ProjectName
  11259. order.Cnt = subItem.Count
  11260. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11261. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11262. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11263. order.OwnpayAmt = ""
  11264. order.SelfpayAmt = ""
  11265. order.Spec = subItem.Unit
  11266. order.SpecUnt = subItem.Unit
  11267. order.DrordBegnDate = s_tm
  11268. order.DrordStopDate = ""
  11269. order.DrordDrCodg = doctor_info.DoctorNumber
  11270. order.DrordDeptName = department.Name
  11271. order.DrordDeptCodg = department.Number
  11272. order.DrordDrName = doctor_info.UserName
  11273. order.DrordDrProfttl = "234"
  11274. order.CurrDrordFlag = "1"
  11275. orders = append(orders, &order)
  11276. }
  11277. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11278. var order models.FsiOrderDtos
  11279. order.RxID = strconv.FormatInt(item.ID, 10)
  11280. order.Rxno = strconv.FormatInt(item.ID, 10)
  11281. order.LongDrordFlag = "0"
  11282. order.HilistType = "1"
  11283. order.ChrgType = "1"
  11284. order.DrordBhvr = "0"
  11285. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11286. order.HosplistName = subItem.GoodInfo.GoodName
  11287. order.HilistLv = "1"
  11288. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11289. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11290. order.HosplistName = subItem.GoodInfo.GoodName
  11291. order.Cnt = subItem.Count
  11292. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11293. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11294. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11295. order.OwnpayAmt = ""
  11296. order.SelfpayAmt = ""
  11297. order.Spec = subItem.GoodInfo.SpecificationName
  11298. order.SpecUnt = subItem.Unit
  11299. order.DrordBegnDate = s_tm
  11300. order.DrordStopDate = ""
  11301. order.DrordDrCodg = doctor_info.DoctorNumber
  11302. order.DrordDeptName = department.Name
  11303. order.DrordDeptCodg = department.Number
  11304. order.DrordDrName = doctor_info.UserName
  11305. order.DrordDrProfttl = "234"
  11306. order.CurrDrordFlag = "1"
  11307. orders = append(orders, &order)
  11308. }
  11309. }
  11310. }
  11311. //处方医嘱信息
  11312. fed.MatnStas = "0"
  11313. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11314. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11315. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11316. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11317. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11318. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11319. fed.SetlTotlnum = "1"
  11320. fed.Insutype = his.Insutype
  11321. fed.ReimFlag = "0"
  11322. fed.OutSetlFlag = "0"
  11323. var fopd []*models.FsiOperationDtosData
  11324. data := make(map[string]interface{})
  11325. data["fed"] = fed
  11326. data["fdd"] = fdds
  11327. data["fod"] = orders
  11328. data["pd"] = pd
  11329. data["pp"] = pp
  11330. data["fopd"] = fopd
  11331. data["trig_scen"] = trig_scen
  11332. client := &http.Client{}
  11333. bytesData, _ := json.Marshal(data)
  11334. var req *http.Request
  11335. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11336. if miConfig.MdtrtareaAdmvs == "320921" {
  11337. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11338. } else {
  11339. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11340. }
  11341. resp, _ := client.Do(req)
  11342. defer resp.Body.Close()
  11343. body, ioErr := ioutil.ReadAll(resp.Body)
  11344. if ioErr != nil {
  11345. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11347. return res
  11348. }
  11349. var respJSON map[string]interface{}
  11350. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11351. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11353. return res
  11354. }
  11355. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11356. result, _ := json.Marshal(respJSON)
  11357. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11358. utils.ErrorLog("解析失败:%v", err)
  11359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11360. return res
  11361. }
  11362. return res
  11363. } else {
  11364. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11365. saveLog(output, input, "3102", "事中")
  11366. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11367. utils.ErrorLog("解析失败:%v", err)
  11368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11369. return
  11370. }
  11371. return res
  11372. }
  11373. return res
  11374. }
  11375. func (c *HisApiController) Check() {
  11376. psn_no := c.GetString("psn_no")
  11377. in := c.GetString("in")
  11378. mt := c.GetString("mt")
  11379. baseParams := models.BaseParams{
  11380. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  11381. FixmedinsCode: "H15049901371",
  11382. InsuplcAdmdvs: "150499",
  11383. MdtrtareaAdmvs: "150499",
  11384. OrgName: "赤峰费森血液透析中心",
  11385. Doctor: "1111",
  11386. }
  11387. service.Gdyb2001(baseParams, psn_no, in, mt)
  11388. }
  11389. func (c *HisApiController) GetPsnNcdsInfo() {
  11390. admin_user_id, _ := c.GetInt64("admin_user_id")
  11391. patient_id, _ := c.GetInt64("patient_id")
  11392. //id, _ := c.GetInt64("id")
  11393. adminUser := c.GetAdminUserInfo()
  11394. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11395. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11396. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  11397. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11398. //psn_record, _ := service.GetP(id)
  11399. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11400. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  11401. //
  11402. //if psn_record.ID == 0 {
  11403. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  11404. // return
  11405. //}
  11406. var res Result5301
  11407. var res10265 Result5301For10265
  11408. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11409. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11410. var api string
  11411. if miConfig.MdtrtareaAdmvs == "320921" {
  11412. 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 +
  11413. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11414. } else {
  11415. 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 +
  11416. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11417. }
  11418. resp, requestErr := http.Get(api)
  11419. if requestErr != nil {
  11420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11421. return
  11422. }
  11423. body, ioErr := ioutil.ReadAll(resp.Body)
  11424. if ioErr != nil {
  11425. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11427. return
  11428. }
  11429. var respJSON map[string]interface{}
  11430. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11431. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11433. return
  11434. }
  11435. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11436. result, _ := json.Marshal(respJSON)
  11437. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11438. utils.ErrorLog("解析失败:%v", err)
  11439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11440. return
  11441. }
  11442. res.ErrMsg = res10265.ErrMsg
  11443. res.Output = res10265.Output
  11444. res.InfRefmsgid = res10265.InfRefmsgid
  11445. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11446. res.Infcode = infocode
  11447. } else if miConfig.MdtrtareaAdmvs == "341203" {
  11448. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11449. var api string
  11450. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  11451. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11452. resp, requestErr := http.Get(api)
  11453. if requestErr != nil {
  11454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11455. return
  11456. }
  11457. body, ioErr := ioutil.ReadAll(resp.Body)
  11458. if ioErr != nil {
  11459. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11461. return
  11462. }
  11463. var respJSON map[string]interface{}
  11464. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11465. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11467. return
  11468. }
  11469. status := respJSON["data"].(map[string]interface{})["status"].(string)
  11470. if status == "0" {
  11471. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  11472. c.ServeSuccessJSON(map[string]interface{}{
  11473. "failed_code": -10,
  11474. "msg": err_msg,
  11475. })
  11476. return
  11477. }
  11478. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11479. result, _ := json.Marshal(respJSON)
  11480. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11481. utils.ErrorLog("解析失败:%v", err)
  11482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11483. return
  11484. }
  11485. } else if miConfig.MdtrtareaAdmvs == "360302" {
  11486. p, _ := service.GetHisPatientById(patient_id)
  11487. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  11488. var dat map[string]interface{}
  11489. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11490. fmt.Println(dat)
  11491. } else {
  11492. fmt.Println(err)
  11493. }
  11494. userJSONBytes, _ := json.Marshal(dat)
  11495. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11496. utils.ErrorLog("解析失败:%v", err)
  11497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11498. return
  11499. }
  11500. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11501. p, _ := service.GetHisPatientById(patient_id)
  11502. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  11503. var dat map[string]interface{}
  11504. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11505. fmt.Println(dat)
  11506. } else {
  11507. fmt.Println(err)
  11508. }
  11509. userJSONBytes, _ := json.Marshal(dat)
  11510. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11511. utils.ErrorLog("解析失败:%v", err)
  11512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11513. return
  11514. }
  11515. } else if miConfig.MdtrtareaAdmvs == "420200" {
  11516. p, _ := service.GetHisPatientById(patient_id)
  11517. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  11518. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11519. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11520. resp, requestErr := http.Get(api)
  11521. if requestErr != nil {
  11522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11523. return
  11524. }
  11525. body, ioErr := ioutil.ReadAll(resp.Body)
  11526. if ioErr != nil {
  11527. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11529. return
  11530. }
  11531. var respJSON map[string]interface{}
  11532. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11533. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11535. return
  11536. }
  11537. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11538. result, _ := json.Marshal(respJSON)
  11539. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11540. utils.ErrorLog("解析失败:%v", err)
  11541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11542. return
  11543. }
  11544. } else if miConfig.MdtrtareaAdmvs == "420902" {
  11545. p, _ := service.GetHisPatientById(patient_id)
  11546. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  11547. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11548. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11549. resp, requestErr := http.Get(api)
  11550. if requestErr != nil {
  11551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11552. return
  11553. }
  11554. body, ioErr := ioutil.ReadAll(resp.Body)
  11555. if ioErr != nil {
  11556. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11558. return
  11559. }
  11560. var respJSON map[string]interface{}
  11561. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11562. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11564. return
  11565. }
  11566. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11567. result, _ := json.Marshal(respJSON)
  11568. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11569. utils.ErrorLog("解析失败:%v", err)
  11570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11571. return
  11572. }
  11573. } else if miConfig.MdtrtareaAdmvs == "421182" {
  11574. p, _ := service.GetHisPatientById(patient_id)
  11575. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  11576. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11577. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11578. resp, requestErr := http.Get(api)
  11579. if requestErr != nil {
  11580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11581. return
  11582. }
  11583. body, ioErr := ioutil.ReadAll(resp.Body)
  11584. if ioErr != nil {
  11585. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11587. return
  11588. }
  11589. var respJSON map[string]interface{}
  11590. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11593. return
  11594. }
  11595. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11596. result, _ := json.Marshal(respJSON)
  11597. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11598. utils.ErrorLog("解析失败:%v", err)
  11599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11600. return
  11601. }
  11602. } else if miConfig.MdtrtareaAdmvs == "420902" {
  11603. p, _ := service.GetHisPatientById(patient_id)
  11604. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  11605. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11606. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11607. resp, requestErr := http.Get(api)
  11608. if requestErr != nil {
  11609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11610. return
  11611. }
  11612. body, ioErr := ioutil.ReadAll(resp.Body)
  11613. if ioErr != nil {
  11614. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11616. return
  11617. }
  11618. var respJSON map[string]interface{}
  11619. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11620. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11622. return
  11623. }
  11624. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11625. result, _ := json.Marshal(respJSON)
  11626. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11627. utils.ErrorLog("解析失败:%v", err)
  11628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11629. return
  11630. }
  11631. } else if miConfig.MdtrtareaAdmvs == "421300" {
  11632. p, _ := service.GetHisPatientById(patient_id)
  11633. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  11634. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11635. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11636. resp, requestErr := http.Get(api)
  11637. if requestErr != nil {
  11638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11639. return
  11640. }
  11641. body, ioErr := ioutil.ReadAll(resp.Body)
  11642. if ioErr != nil {
  11643. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11645. return
  11646. }
  11647. var respJSON map[string]interface{}
  11648. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11649. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11651. return
  11652. }
  11653. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11654. result, _ := json.Marshal(respJSON)
  11655. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11656. utils.ErrorLog("解析失败:%v", err)
  11657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11658. return
  11659. }
  11660. } else if miConfig.MdtrtareaAdmvs == "441799" {
  11661. p, _ := service.GetHisPatientById(patient_id)
  11662. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  11663. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11664. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11665. resp, requestErr := http.Get(api)
  11666. if requestErr != nil {
  11667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11668. return
  11669. }
  11670. body, ioErr := ioutil.ReadAll(resp.Body)
  11671. if ioErr != nil {
  11672. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11674. return
  11675. }
  11676. var respJSON map[string]interface{}
  11677. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11678. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11680. return
  11681. }
  11682. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11683. result, _ := json.Marshal(respJSON)
  11684. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11685. utils.ErrorLog("解析失败:%v", err)
  11686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11687. return
  11688. }
  11689. } else {
  11690. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  11691. var dat map[string]interface{}
  11692. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11693. fmt.Println(dat)
  11694. } else {
  11695. fmt.Println(err)
  11696. }
  11697. userJSONBytes, _ := json.Marshal(dat)
  11698. if miConfig.Code == "H15049901371" {
  11699. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  11700. utils.ErrorLog("解析失败:%v", err)
  11701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11702. return
  11703. }
  11704. res.InfRefmsgid = res10265.InfRefmsgid
  11705. res.Output = res10265.Output
  11706. res.ErrMsg = res10265.ErrMsg
  11707. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11708. res.Infcode = infocode
  11709. } else {
  11710. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11711. utils.ErrorLog("解析失败:%v", err)
  11712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11713. return
  11714. }
  11715. }
  11716. }
  11717. if res.Infcode == 0 {
  11718. c.ServeSuccessJSON(map[string]interface{}{
  11719. "result": res.Output.Result,
  11720. })
  11721. }
  11722. }
  11723. func (c *HisApiController) CheckInsutype() {
  11724. his_patient_id, _ := c.GetInt64("his_patient_id")
  11725. admin_user_id, _ := c.GetInt64("admin_user_id")
  11726. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11727. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11728. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11729. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  11730. var dat map[string]interface{}
  11731. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11732. fmt.Println(dat)
  11733. } else {
  11734. fmt.Println(err)
  11735. }
  11736. userJSONBytes, _ := json.Marshal(dat)
  11737. var res Result90100
  11738. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11739. utils.ErrorLog("解析失败:%v", err)
  11740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11741. return
  11742. }
  11743. if res.Infcode != 0 {
  11744. c.ServeSuccessJSON(map[string]interface{}{
  11745. "failed_code": -10,
  11746. "msg": res.ErrMsg,
  11747. })
  11748. return
  11749. } else {
  11750. fmt.Println(res)
  11751. }
  11752. }
  11753. func (c *HisApiController) CheckCardPWD() {
  11754. card_pwd := c.GetString("card_pwd")
  11755. his_patient_id, _ := c.GetInt64("his_patient_id")
  11756. admin_user_id, _ := c.GetInt64("admin_user_id")
  11757. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11758. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11759. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11760. psn, _ := service.GetPsnByPatientId(his.PatientId)
  11761. bas := strings.Split(psn.CardInfo, "|")
  11762. basNumber := bas[2]
  11763. if psn.InsuplcAdmdvs[:4] == "4403" {
  11764. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  11765. var dat map[string]interface{}
  11766. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11767. fmt.Println(dat)
  11768. } else {
  11769. fmt.Println(err)
  11770. }
  11771. userJSONBytes, _ := json.Marshal(dat)
  11772. var res Result90991
  11773. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11774. utils.ErrorLog("解析失败:%v", err)
  11775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11776. return
  11777. }
  11778. if res.Infcode != 0 {
  11779. c.ServeSuccessJSON(map[string]interface{}{
  11780. "failed_code": -10,
  11781. "msg": res.ErrMsg,
  11782. })
  11783. return
  11784. } else {
  11785. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  11786. var msg string
  11787. switch res.Output.Result.CardStat {
  11788. case "00":
  11789. msg = "未激活"
  11790. break
  11791. case "10":
  11792. msg = "激活"
  11793. break
  11794. case "20":
  11795. msg = "窗口挂失"
  11796. break
  11797. case "21":
  11798. msg = "电话挂失"
  11799. break
  11800. case "22":
  11801. msg = "单位网上申报挂失"
  11802. break
  11803. case "23":
  11804. msg = "保健办挂失"
  11805. break
  11806. case "24":
  11807. msg = "个人网上挂失"
  11808. break
  11809. case "25":
  11810. msg = "网上服务大厅挂失"
  11811. break
  11812. case "30":
  11813. msg = "注销"
  11814. break
  11815. case "40":
  11816. msg = "回收"
  11817. break
  11818. case "99":
  11819. msg = "制卡中(无效卡)"
  11820. break
  11821. }
  11822. c.ServeSuccessJSON(map[string]interface{}{
  11823. "failed_code": -10,
  11824. "msg": msg,
  11825. })
  11826. return
  11827. } else {
  11828. c.ServeSuccessJSON(map[string]interface{}{
  11829. "msg": "校验成功",
  11830. })
  11831. return
  11832. }
  11833. }
  11834. } else {
  11835. c.ServeSuccessJSON(map[string]interface{}{
  11836. "msg": "校验成功",
  11837. })
  11838. return
  11839. }
  11840. }
  11841. func (c *HisApiController) CheckCardPWDTwo() {
  11842. //card_pwd := c.GetString("card_pwd")
  11843. //his_patient_id, _ := c.GetInt64("his_patient_id")
  11844. admin_user_id, _ := c.GetInt64("admin_user_id")
  11845. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11846. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11847. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  11848. var dat map[string]interface{}
  11849. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11850. fmt.Println(dat)
  11851. } else {
  11852. fmt.Println(err)
  11853. }
  11854. userJSONBytes, _ := json.Marshal(dat)
  11855. var res Result90991
  11856. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11857. utils.ErrorLog("解析失败:%v", err)
  11858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11859. return
  11860. }
  11861. if res.Infcode != 0 {
  11862. c.ServeSuccessJSON(map[string]interface{}{
  11863. "failed_code": -10,
  11864. "msg": res.ErrMsg,
  11865. })
  11866. return
  11867. } else {
  11868. if res.Output.Result.SscnoCheckStat == "0" {
  11869. var msg string
  11870. switch res.Output.Result.CardStat {
  11871. case "00":
  11872. msg = "未激活"
  11873. break
  11874. case "10":
  11875. msg = "激活"
  11876. break
  11877. case "20":
  11878. msg = "窗口挂失"
  11879. break
  11880. case "21":
  11881. msg = "电话挂失"
  11882. break
  11883. case "22":
  11884. msg = "单位网上申报挂失"
  11885. break
  11886. case "23":
  11887. msg = "保健办挂失"
  11888. break
  11889. case "24":
  11890. msg = "个人网上挂失"
  11891. break
  11892. case "25":
  11893. msg = "网上服务大厅挂失"
  11894. break
  11895. case "30":
  11896. msg = "注销"
  11897. break
  11898. case "40":
  11899. msg = "回收"
  11900. break
  11901. case "99":
  11902. msg = "制卡中(无效卡)"
  11903. break
  11904. }
  11905. c.ServeSuccessJSON(map[string]interface{}{
  11906. "failed_code": -10,
  11907. "msg": msg,
  11908. })
  11909. return
  11910. } else {
  11911. c.ServeSuccessJSON(map[string]interface{}{
  11912. "msg": "校验成功",
  11913. })
  11914. return
  11915. }
  11916. }
  11917. }
  11918. type ELeCertData struct {
  11919. Data struct {
  11920. Extra string `json:"extra"`
  11921. IDNo string `json:"idNo"`
  11922. IDType string `json:"idType"`
  11923. EcToken string `json:"ecToken"`
  11924. InsuOrg string `json:"insuOrg"`
  11925. UserName string `json:"userName"`
  11926. EcIndexNo string `json:"ecIndexNo"`
  11927. Gender string `json:"gender"`
  11928. Birthday string `json:"birthday"`
  11929. Nationality string `json:"nationality"`
  11930. Email string `json:"email"`
  11931. } `json:"OutData"`
  11932. }
  11933. func (c *HisApiController) ReadCard() {
  11934. id_card_type, _ := c.GetInt64("id_card_type")
  11935. admin_user_id, _ := c.GetInt64("admin_user_id")
  11936. certificates, _ := c.GetInt64("certificates")
  11937. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  11938. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11939. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11940. switch id_card_type {
  11941. case 1:
  11942. if miConfig.MdtrtareaAdmvs == "421300" {
  11943. var res ResultTwo
  11944. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  11945. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11946. "&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)
  11947. resp, requestErr := http.Get(api)
  11948. if requestErr != nil {
  11949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11950. return
  11951. }
  11952. body, ioErr := ioutil.ReadAll(resp.Body)
  11953. if ioErr != nil {
  11954. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11956. return
  11957. }
  11958. var respJSON map[string]interface{}
  11959. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11960. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11962. return
  11963. }
  11964. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11965. result, _ := json.Marshal(respJSON)
  11966. fmt.Println("log")
  11967. fmt.Println(string(result))
  11968. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11969. utils.ErrorLog("解析失败:%v", err)
  11970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11971. return
  11972. }
  11973. if res.Infcode == 0 {
  11974. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11975. if err == gorm.ErrRecordNotFound {
  11976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11977. return
  11978. } else if err != nil {
  11979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11980. return
  11981. } else {
  11982. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11983. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11984. infoStr := string(Iinfos)
  11985. idetinfoStr := string(Idetinfos)
  11986. var rf []*ResultFive
  11987. json.Unmarshal([]byte(infoStr), &rf)
  11988. var insutypes []*ResultFive
  11989. var insutype string
  11990. var is390 int = 0
  11991. var is310 int = 0
  11992. for _, item := range rf {
  11993. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  11994. insutypes = append(insutypes, item)
  11995. }
  11996. }
  11997. if len(insutypes) == 1 {
  11998. insutype = insutypes[0].Insutype
  11999. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12000. } else {
  12001. for _, i := range insutypes {
  12002. if i.Insutype == "390" {
  12003. is390 = 1
  12004. }
  12005. if i.Insutype == "310" {
  12006. is310 = 1
  12007. }
  12008. }
  12009. }
  12010. if is390 == 1 {
  12011. insutype = "390"
  12012. }
  12013. if is310 == 1 {
  12014. insutype = "310"
  12015. }
  12016. if len(insutypes) == 0 {
  12017. insutype = "390"
  12018. }
  12019. var insuplc_admdvs string
  12020. for _, item := range rf {
  12021. if item.Insutype == insutype {
  12022. insuplc_admdvs = item.InsuplcAdmdvs
  12023. }
  12024. }
  12025. if strings.Contains(insuplc_admdvs, "4213") {
  12026. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  12027. }
  12028. psn := &models.HisPsn{
  12029. PsnNo: res.Output.Baseinfo.PsnNo,
  12030. PatientId: patient.ID,
  12031. Certno: res.Output.Baseinfo.Certno,
  12032. Gend: res.Output.Baseinfo.Gend,
  12033. Naty: res.Output.Baseinfo.Naty,
  12034. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12035. PsnName: res.Output.Baseinfo.PsnName,
  12036. Idetinfo: idetinfoStr,
  12037. Insuinfo: infoStr,
  12038. InsuplcAdmdvs: insuplc_admdvs,
  12039. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12040. }
  12041. service.CreateHisPsn(psn)
  12042. c.ServeSuccessJSON(map[string]interface{}{
  12043. "patient": patient,
  12044. "number": res.Output.Baseinfo.Certno,
  12045. })
  12046. }
  12047. } else {
  12048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12049. return
  12050. }
  12051. } else if miConfig.MdtrtareaAdmvs == "420200" {
  12052. var res ResultTwo
  12053. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  12054. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12055. "&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)
  12056. resp, requestErr := http.Get(api)
  12057. if requestErr != nil {
  12058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12059. return
  12060. }
  12061. body, ioErr := ioutil.ReadAll(resp.Body)
  12062. if ioErr != nil {
  12063. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12065. return
  12066. }
  12067. var respJSON map[string]interface{}
  12068. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12069. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12071. return
  12072. }
  12073. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12074. result, _ := json.Marshal(respJSON)
  12075. fmt.Println("log")
  12076. fmt.Println(string(result))
  12077. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12078. utils.ErrorLog("解析失败:%v", err)
  12079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12080. return
  12081. }
  12082. if res.Infcode == 0 {
  12083. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12084. if err == gorm.ErrRecordNotFound {
  12085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12086. return
  12087. } else if err != nil {
  12088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12089. return
  12090. } else {
  12091. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12092. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12093. infoStr := string(Iinfos)
  12094. idetinfoStr := string(Idetinfos)
  12095. psn := &models.HisPsn{
  12096. PsnNo: res.Output.Baseinfo.PsnNo,
  12097. PatientId: patient.ID,
  12098. Certno: res.Output.Baseinfo.Certno,
  12099. Gend: res.Output.Baseinfo.Gend,
  12100. Naty: res.Output.Baseinfo.Naty,
  12101. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12102. PsnName: res.Output.Baseinfo.PsnName,
  12103. Idetinfo: idetinfoStr,
  12104. Insuinfo: infoStr,
  12105. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12106. }
  12107. service.CreateHisPsn(psn)
  12108. var rf []*ResultFive
  12109. json.Unmarshal([]byte(infoStr), &rf)
  12110. var insutypes []*ResultFive
  12111. var insutype string
  12112. var is390 int = 0
  12113. var is310 int = 0
  12114. for _, item := range rf {
  12115. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12116. insutypes = append(insutypes, item)
  12117. }
  12118. }
  12119. if len(insutypes) == 1 {
  12120. insutype = insutypes[0].Insutype
  12121. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12122. } else {
  12123. for _, i := range insutypes {
  12124. if i.Insutype == "390" {
  12125. is390 = 1
  12126. }
  12127. if i.Insutype == "310" {
  12128. is310 = 1
  12129. }
  12130. }
  12131. }
  12132. if is390 == 1 {
  12133. insutype = "390"
  12134. }
  12135. if is310 == 1 {
  12136. insutype = "310"
  12137. }
  12138. if len(insutypes) == 0 {
  12139. insutype = "310"
  12140. }
  12141. c.ServeSuccessJSON(map[string]interface{}{
  12142. "patient": patient,
  12143. "number": res.Output.Baseinfo.Certno,
  12144. "insutype": insutype,
  12145. })
  12146. }
  12147. } else {
  12148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12149. return
  12150. }
  12151. } else if miConfig.MdtrtareaAdmvs == "420902" {
  12152. var res ResultTwo
  12153. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  12154. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12155. "&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)
  12156. resp, requestErr := http.Get(api)
  12157. if requestErr != nil {
  12158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12159. return
  12160. }
  12161. body, ioErr := ioutil.ReadAll(resp.Body)
  12162. if ioErr != nil {
  12163. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12165. return
  12166. }
  12167. var respJSON map[string]interface{}
  12168. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12169. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12171. return
  12172. }
  12173. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12174. result, _ := json.Marshal(respJSON)
  12175. fmt.Println("log")
  12176. fmt.Println(string(result))
  12177. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12178. utils.ErrorLog("解析失败:%v", err)
  12179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12180. return
  12181. }
  12182. if res.Infcode == 0 {
  12183. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12184. if err == gorm.ErrRecordNotFound {
  12185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12186. return
  12187. } else if err != nil {
  12188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12189. return
  12190. } else {
  12191. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12192. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12193. infoStr := string(Iinfos)
  12194. idetinfoStr := string(Idetinfos)
  12195. var rf []*ResultFive
  12196. json.Unmarshal([]byte(infoStr), &rf)
  12197. var insutypes []*ResultFive
  12198. var insutype string
  12199. var is390 int = 0
  12200. var is310 int = 0
  12201. for _, item := range rf {
  12202. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12203. insutypes = append(insutypes, item)
  12204. }
  12205. }
  12206. if len(insutypes) == 1 {
  12207. insutype = insutypes[0].Insutype
  12208. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12209. } else {
  12210. for _, i := range insutypes {
  12211. if i.Insutype == "390" {
  12212. is390 = 1
  12213. }
  12214. if i.Insutype == "310" {
  12215. is310 = 1
  12216. }
  12217. }
  12218. }
  12219. if is390 == 1 {
  12220. insutype = "390"
  12221. }
  12222. if is310 == 1 {
  12223. insutype = "310"
  12224. }
  12225. if len(insutypes) == 0 {
  12226. insutype = "390"
  12227. }
  12228. var insuplc_admdvs string
  12229. for _, item := range rf {
  12230. if item.Insutype == insutype {
  12231. insuplc_admdvs = item.InsuplcAdmdvs
  12232. }
  12233. }
  12234. psn := &models.HisPsn{
  12235. PsnNo: res.Output.Baseinfo.PsnNo,
  12236. PatientId: patient.ID,
  12237. Certno: res.Output.Baseinfo.Certno,
  12238. Gend: res.Output.Baseinfo.Gend,
  12239. Naty: res.Output.Baseinfo.Naty,
  12240. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12241. PsnName: res.Output.Baseinfo.PsnName,
  12242. Idetinfo: idetinfoStr,
  12243. Insuinfo: infoStr,
  12244. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12245. InsuplcAdmdvs: insuplc_admdvs,
  12246. }
  12247. service.CreateHisPsn(psn)
  12248. for _, item := range rf {
  12249. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12250. insutypes = append(insutypes, item)
  12251. }
  12252. }
  12253. if len(insutypes) == 1 {
  12254. insutype = insutypes[0].Insutype
  12255. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12256. } else {
  12257. for _, i := range insutypes {
  12258. if i.Insutype == "390" {
  12259. is390 = 1
  12260. }
  12261. if i.Insutype == "310" {
  12262. is310 = 1
  12263. }
  12264. }
  12265. }
  12266. if is390 == 1 {
  12267. insutype = "390"
  12268. }
  12269. if is310 == 1 {
  12270. insutype = "310"
  12271. }
  12272. if len(insutypes) == 0 {
  12273. insutype = "310"
  12274. }
  12275. c.ServeSuccessJSON(map[string]interface{}{
  12276. "patient": patient,
  12277. "number": res.Output.Baseinfo.Certno,
  12278. "insutype": insutype,
  12279. })
  12280. }
  12281. } else {
  12282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12283. return
  12284. }
  12285. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12286. var res ResultTwo
  12287. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  12288. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12289. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(certificates, 10)
  12290. resp, requestErr := http.Get(api)
  12291. if requestErr != nil {
  12292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12293. return
  12294. }
  12295. body, ioErr := ioutil.ReadAll(resp.Body)
  12296. if ioErr != nil {
  12297. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12299. return
  12300. }
  12301. var respJSON map[string]interface{}
  12302. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12305. return
  12306. }
  12307. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12308. result, _ := json.Marshal(respJSON)
  12309. fmt.Println("log")
  12310. fmt.Println(string(result))
  12311. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12312. utils.ErrorLog("解析失败:%v", err)
  12313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12314. return
  12315. }
  12316. if res.Infcode == 0 {
  12317. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12318. if err == gorm.ErrRecordNotFound {
  12319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12320. return
  12321. } else if err != nil {
  12322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12323. return
  12324. } else {
  12325. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12326. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12327. infoStr := string(Iinfos)
  12328. idetinfoStr := string(Idetinfos)
  12329. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  12330. psn := &models.HisPsn{
  12331. PsnNo: res.Output.Baseinfo.PsnNo,
  12332. PatientId: patient.ID,
  12333. Certno: res.Output.Baseinfo.Certno,
  12334. Brdy: b,
  12335. Age: float64(age),
  12336. Gend: res.Output.Baseinfo.Gend,
  12337. Naty: res.Output.Baseinfo.Naty,
  12338. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12339. PsnName: res.Output.Baseinfo.PsnName,
  12340. Idetinfo: idetinfoStr,
  12341. Insuinfo: infoStr,
  12342. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12343. }
  12344. service.CreateHisPsn(psn)
  12345. var rf []*ResultFive
  12346. json.Unmarshal([]byte(infoStr), &rf)
  12347. var insutypes []*ResultFive
  12348. var insutype string
  12349. var is390 int = 0
  12350. var is310 int = 0
  12351. for _, item := range rf {
  12352. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12353. insutypes = append(insutypes, item)
  12354. }
  12355. }
  12356. if len(insutypes) == 1 {
  12357. insutype = insutypes[0].Insutype
  12358. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12359. } else {
  12360. for _, i := range insutypes {
  12361. if i.Insutype == "390" {
  12362. is390 = 1
  12363. }
  12364. if i.Insutype == "310" {
  12365. is310 = 1
  12366. }
  12367. }
  12368. }
  12369. if is390 == 1 {
  12370. insutype = "390"
  12371. }
  12372. if is310 == 1 {
  12373. insutype = "310"
  12374. }
  12375. if len(insutypes) == 0 {
  12376. insutype = "310"
  12377. }
  12378. c.ServeSuccessJSON(map[string]interface{}{
  12379. "patient": patient,
  12380. "number": res.Output.Baseinfo.Certno,
  12381. "insutype": insutype,
  12382. })
  12383. }
  12384. } else {
  12385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12386. return
  12387. }
  12388. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12389. var api string
  12390. if miConfig.MdtrtareaAdmvs == "320921" {
  12391. 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 +
  12392. "&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
  12393. fmt.Println(api)
  12394. } else {
  12395. 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 +
  12396. "&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)
  12397. }
  12398. resp, requestErr := http.Get(api)
  12399. if requestErr != nil {
  12400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12401. return
  12402. }
  12403. body, ioErr := ioutil.ReadAll(resp.Body)
  12404. if ioErr != nil {
  12405. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12407. return
  12408. }
  12409. var respJSON map[string]interface{}
  12410. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12411. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12413. return
  12414. }
  12415. var status string
  12416. status = respJSON["data"].(map[string]interface{})["status"].(string)
  12417. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  12418. //console.log()
  12419. fmt.Println("type===")
  12420. fmt.Println(card_type)
  12421. var token string
  12422. var res ResultTwo //1101结果
  12423. var res10265 ResultTwo10265 //1101结果
  12424. var card_info string //卡信息
  12425. var busi_card_info string
  12426. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  12427. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  12428. if status == "0" { //读卡成功
  12429. if card_type == "1" {
  12430. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12431. result, _ := json.Marshal(respJSON)
  12432. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12433. utils.ErrorLog("解析失败:%v", err)
  12434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12435. return
  12436. }
  12437. res.ErrMsg = res10265.ErrMsg
  12438. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12439. res.Infcode = infocode
  12440. res.Output = res10265.Output
  12441. res.InfRefmsgid = res10265.InfRefmsgid
  12442. } else {
  12443. //var card_info string //卡信息
  12444. //var busi_card_info string
  12445. token = respJSON["data"].(map[string]interface{})["token"].(string)
  12446. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  12447. //fmt.Println(card_info)
  12448. //fmt.Println(busi_card_info)
  12449. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12450. result, _ := json.Marshal(respJSON)
  12451. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12452. utils.ErrorLog("解析失败:%v", err)
  12453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12454. return
  12455. }
  12456. res.ErrMsg = res10265.ErrMsg
  12457. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12458. res.Infcode = infocode
  12459. res.Output = res10265.Output
  12460. res.InfRefmsgid = res10265.InfRefmsgid
  12461. }
  12462. if res.Infcode == 0 {
  12463. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12464. if err == gorm.ErrRecordNotFound {
  12465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12466. return
  12467. } else if err != nil {
  12468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12469. return
  12470. } else {
  12471. if card_type == "1" {
  12472. bas := strings.Split(card_info, "|")
  12473. basNumber := bas[2]
  12474. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12475. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12476. infoStr := string(Iinfos)
  12477. idetinfoStr := string(Idetinfos)
  12478. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  12479. psn := &models.HisPsn{
  12480. PsnNo: res.Output.Baseinfo.PsnNo,
  12481. PatientId: patient.ID,
  12482. Certno: res.Output.Baseinfo.Certno,
  12483. Brdy: b,
  12484. Age: float64(age),
  12485. Gend: res.Output.Baseinfo.Gend,
  12486. Naty: res.Output.Baseinfo.Naty,
  12487. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12488. PsnName: res.Output.Baseinfo.PsnName,
  12489. Idetinfo: idetinfoStr,
  12490. Insuinfo: infoStr,
  12491. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12492. CardInfo: card_info,
  12493. VerifyNumber: busi_card_info,
  12494. }
  12495. service.CreateHisPsn(psn)
  12496. var rf []*ResultFive
  12497. json.Unmarshal([]byte(infoStr), &rf)
  12498. var insutypes []*ResultFive
  12499. var insutype string
  12500. var is390 int = 0
  12501. var is310 int = 0
  12502. for _, item := range rf {
  12503. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12504. insutypes = append(insutypes, item)
  12505. }
  12506. }
  12507. if len(insutypes) == 1 {
  12508. insutype = insutypes[0].Insutype
  12509. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12510. } else {
  12511. for _, i := range insutypes {
  12512. if i.Insutype == "390" {
  12513. is390 = 1
  12514. }
  12515. if i.Insutype == "310" {
  12516. is310 = 1
  12517. }
  12518. }
  12519. }
  12520. if is390 == 1 {
  12521. insutype = "390"
  12522. }
  12523. if is310 == 1 {
  12524. insutype = "310"
  12525. }
  12526. if len(insutypes) == 0 {
  12527. insutype = "310"
  12528. }
  12529. c.ServeSuccessJSON(map[string]interface{}{
  12530. "patient": patient,
  12531. "number": basNumber,
  12532. "insutype": insutype,
  12533. })
  12534. } else {
  12535. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12536. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12537. infoStr := string(Iinfos)
  12538. idetinfoStr := string(Idetinfos)
  12539. psn := &models.HisPsn{
  12540. PsnNo: res.Output.Baseinfo.PsnNo,
  12541. PatientId: patient.ID,
  12542. Certno: res.Output.Baseinfo.Certno,
  12543. Gend: res.Output.Baseinfo.Gend,
  12544. Naty: res.Output.Baseinfo.Naty,
  12545. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12546. PsnName: res.Output.Baseinfo.PsnName,
  12547. Idetinfo: idetinfoStr,
  12548. Insuinfo: infoStr,
  12549. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12550. CardInfo: card_info,
  12551. VerifyNumber: token,
  12552. }
  12553. service.CreateHisPsn(psn)
  12554. c.ServeSuccessJSON(map[string]interface{}{
  12555. "patient": patient,
  12556. "number": token,
  12557. })
  12558. }
  12559. }
  12560. } else {
  12561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12562. return
  12563. }
  12564. } else { //读卡失败
  12565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12566. return
  12567. }
  12568. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12569. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  12570. cardnum = DeleteExtraSpaceTwo(cardnum)
  12571. cardCode = DeleteExtraSpaceTwo(cardCode)
  12572. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  12573. name = DeleteExtraSpaceTwo(name)
  12574. errmsg = DeleteExtraSpaceTwo(errmsg)
  12575. cardnum = Remove0000(cardnum)
  12576. cardCode = Remove0000(cardCode)
  12577. id_card_no = Remove0000(id_card_no)
  12578. name = Remove0000(name)
  12579. errmsg = Remove0000(errmsg)
  12580. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  12581. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  12582. //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)
  12583. //fmt.Println(result2)
  12584. //fmt.Println(requestLog2)
  12585. //fmt.Println(errMsgLog2)
  12586. 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)
  12587. saveLog(result, requestLog, "1101", "获取人员信息")
  12588. fmt.Println(errMsgLog)
  12589. if len(errMsgLog) > 0 {
  12590. } else {
  12591. var dat map[string]interface{}
  12592. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12593. fmt.Println(dat)
  12594. } else {
  12595. fmt.Println(err)
  12596. }
  12597. userJSONBytes, _ := json.Marshal(dat)
  12598. var res ResultTwo
  12599. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12600. utils.ErrorLog("解析失败:%v", err)
  12601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12602. return
  12603. }
  12604. res.ErrMsg = errMsgLog
  12605. if res.Infcode == 0 {
  12606. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12607. if err == gorm.ErrRecordNotFound {
  12608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12609. return
  12610. } else if err != nil {
  12611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12612. return
  12613. } else {
  12614. fmt.Println(res)
  12615. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12616. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12617. infoStr := string(Iinfos)
  12618. idetinfoStr := string(Idetinfos)
  12619. var rf []*ResultFive
  12620. json.Unmarshal([]byte(infoStr), &rf)
  12621. var insutypes []*ResultFive
  12622. var insutype string
  12623. var is390 int = 0
  12624. var is310 int = 0
  12625. for _, item := range rf {
  12626. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12627. insutypes = append(insutypes, item)
  12628. }
  12629. }
  12630. if len(insutypes) == 1 {
  12631. insutype = insutypes[0].Insutype
  12632. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12633. } else {
  12634. for _, i := range insutypes {
  12635. if i.Insutype == "390" {
  12636. is390 = 1
  12637. }
  12638. if i.Insutype == "310" {
  12639. is310 = 1
  12640. }
  12641. }
  12642. }
  12643. if is390 == 1 {
  12644. insutype = "390"
  12645. }
  12646. if is310 == 1 {
  12647. insutype = "310"
  12648. }
  12649. if len(insutypes) == 0 {
  12650. insutype = "390"
  12651. }
  12652. var insuplc_admdvs string
  12653. for _, item := range rf {
  12654. if item.Insutype == insutype {
  12655. insuplc_admdvs = item.InsuplcAdmdvs
  12656. }
  12657. }
  12658. psn := &models.HisPsn{
  12659. PsnNo: res.Output.Baseinfo.PsnNo,
  12660. PatientId: patient.ID,
  12661. Certno: res.Output.Baseinfo.Certno,
  12662. Gend: res.Output.Baseinfo.Gend,
  12663. Naty: res.Output.Baseinfo.Naty,
  12664. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12665. PsnName: res.Output.Baseinfo.PsnName,
  12666. Idetinfo: idetinfoStr,
  12667. Insuinfo: infoStr,
  12668. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12669. CardInfo: basStr,
  12670. VerifyNumber: "",
  12671. InsuplcAdmdvs: insuplc_admdvs,
  12672. }
  12673. service.CreateHisPsn(psn)
  12674. c.ServeSuccessJSON(map[string]interface{}{
  12675. "patient": patient,
  12676. "number": cardnum,
  12677. "insutype": insutype,
  12678. })
  12679. }
  12680. } else {
  12681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12682. return
  12683. }
  12684. }
  12685. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12686. fmt.Println(initFlag)
  12687. fmt.Println("initFlag")
  12688. if initFlag == 0 {
  12689. c.TestGetJiangXiBasBaseInit()
  12690. }
  12691. basStr := c.GetBasBaseInfo()
  12692. if len(basStr) == 0 {
  12693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  12694. return
  12695. }
  12696. fmt.Println(basStr)
  12697. bas := strings.Split(basStr, "|")
  12698. basNumber := bas[1]
  12699. fmt.Println(basNumber)
  12700. card_sn := bas[3]
  12701. fmt.Println(card_sn)
  12702. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  12703. 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)
  12704. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  12705. var dat map[string]interface{}
  12706. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12707. fmt.Println(dat)
  12708. } else {
  12709. fmt.Println(err)
  12710. }
  12711. userJSONBytes, _ := json.Marshal(dat)
  12712. var res ResultTwo
  12713. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12714. utils.ErrorLog("解析失败:%v", err)
  12715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12716. return
  12717. }
  12718. if res.Infcode == 0 {
  12719. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  12720. if err == gorm.ErrRecordNotFound {
  12721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12722. return
  12723. } else if err != nil {
  12724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12725. return
  12726. } else {
  12727. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12728. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12729. infoStr := string(Iinfos)
  12730. idetinfoStr := string(Idetinfos)
  12731. var rf []*ResultFive
  12732. json.Unmarshal([]byte(infoStr), &rf)
  12733. var insutypes []*ResultFive
  12734. var insutype string
  12735. var is390 int = 0
  12736. var is310 int = 0
  12737. var insuplc_admdvs string
  12738. for _, item := range rf {
  12739. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12740. insutypes = append(insutypes, item)
  12741. }
  12742. }
  12743. if len(insutypes) == 1 {
  12744. insutype = insutypes[0].Insutype
  12745. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12746. } else {
  12747. for _, i := range insutypes {
  12748. if i.Insutype == "390" {
  12749. is390 = 1
  12750. }
  12751. if i.Insutype == "310" {
  12752. is310 = 1
  12753. }
  12754. }
  12755. }
  12756. if is390 == 1 {
  12757. insutype = "390"
  12758. }
  12759. if is310 == 1 {
  12760. insutype = "310"
  12761. }
  12762. if len(insutypes) == 0 {
  12763. insutype = "310"
  12764. }
  12765. for _, item := range rf {
  12766. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  12767. insuplc_admdvs = item.InsuplcAdmdvs
  12768. }
  12769. }
  12770. psn := &models.HisPsn{
  12771. PsnNo: res.Output.Baseinfo.PsnNo,
  12772. PatientId: patient.ID,
  12773. Certno: res.Output.Baseinfo.Certno,
  12774. Gend: res.Output.Baseinfo.Gend,
  12775. Naty: res.Output.Baseinfo.Naty,
  12776. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12777. PsnName: res.Output.Baseinfo.PsnName,
  12778. Idetinfo: idetinfoStr,
  12779. Insuinfo: infoStr,
  12780. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12781. CardInfo: basStr,
  12782. InsuplcAdmdvs: insuplc_admdvs,
  12783. VerifyNumber: "",
  12784. }
  12785. service.CreateHisPsn(psn)
  12786. c.ServeSuccessJSON(map[string]interface{}{
  12787. "patient": patient,
  12788. "number": basNumber,
  12789. "insutype": insutype,
  12790. })
  12791. }
  12792. } else {
  12793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12794. return
  12795. }
  12796. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12797. fmt.Println(initFlag)
  12798. fmt.Println("initFlag")
  12799. if initFlag == 0 {
  12800. c.TestGetHnBasBaseInit()
  12801. }
  12802. basStr := c.GetBasBaseInfo()
  12803. if len(basStr) == 0 {
  12804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  12805. return
  12806. }
  12807. fmt.Println(basStr)
  12808. bas := strings.Split(basStr, "|")
  12809. basNumber := bas[1]
  12810. fmt.Println(basNumber)
  12811. card_sn := bas[3]
  12812. card_no := bas[2]
  12813. fmt.Println(card_sn)
  12814. name := bas[4]
  12815. name = ConvertToString(name, "gbk", "utf-8")
  12816. 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)
  12817. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  12818. var dat map[string]interface{}
  12819. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12820. fmt.Println(dat)
  12821. } else {
  12822. fmt.Println(err)
  12823. }
  12824. userJSONBytes, _ := json.Marshal(dat)
  12825. var res ResultTwo
  12826. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12827. utils.ErrorLog("解析失败:%v", err)
  12828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12829. return
  12830. }
  12831. if res.Infcode == 0 {
  12832. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  12833. if err == gorm.ErrRecordNotFound {
  12834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12835. return
  12836. } else if err != nil {
  12837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12838. return
  12839. } else {
  12840. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12841. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12842. infoStr := string(Iinfos)
  12843. idetinfoStr := string(Idetinfos)
  12844. psn := &models.HisPsn{
  12845. PsnNo: res.Output.Baseinfo.PsnNo,
  12846. PatientId: patient.ID,
  12847. Certno: res.Output.Baseinfo.Certno,
  12848. Gend: res.Output.Baseinfo.Gend,
  12849. Naty: res.Output.Baseinfo.Naty,
  12850. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12851. PsnName: res.Output.Baseinfo.PsnName,
  12852. Idetinfo: idetinfoStr,
  12853. Insuinfo: infoStr,
  12854. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12855. CardInfo: basStr,
  12856. VerifyNumber: "",
  12857. }
  12858. service.CreateHisPsn(psn)
  12859. var rf []*ResultFive
  12860. json.Unmarshal([]byte(infoStr), &rf)
  12861. var insutypes []*ResultFive
  12862. var insutype string
  12863. var is390 int = 0
  12864. var is310 int = 0
  12865. for _, item := range rf {
  12866. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12867. insutypes = append(insutypes, item)
  12868. }
  12869. }
  12870. if len(insutypes) == 1 {
  12871. insutype = insutypes[0].Insutype
  12872. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12873. } else {
  12874. for _, i := range insutypes {
  12875. if i.Insutype == "390" {
  12876. is390 = 1
  12877. }
  12878. if i.Insutype == "310" {
  12879. is310 = 1
  12880. }
  12881. }
  12882. }
  12883. if is390 == 1 {
  12884. insutype = "390"
  12885. }
  12886. if is310 == 1 {
  12887. insutype = "310"
  12888. }
  12889. if len(insutypes) == 0 {
  12890. insutype = "310"
  12891. }
  12892. c.ServeSuccessJSON(map[string]interface{}{
  12893. "patient": patient,
  12894. "number": basNumber,
  12895. "insutype": insutype,
  12896. })
  12897. }
  12898. } else {
  12899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12900. return
  12901. }
  12902. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12903. var api string
  12904. 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 +
  12905. "&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
  12906. fmt.Println(api)
  12907. resp, requestErr := http.Get(api)
  12908. if requestErr != nil {
  12909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12910. return
  12911. }
  12912. body, ioErr := ioutil.ReadAll(resp.Body)
  12913. if ioErr != nil {
  12914. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12916. return
  12917. }
  12918. var respJSON map[string]interface{}
  12919. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12920. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12922. return
  12923. }
  12924. var res ResultTwo //1101结果
  12925. var res10265 ResultTwo10265 //1101结果
  12926. var card_info string //卡信息
  12927. token := respJSON["data"].(map[string]interface{})["token"].(string)
  12928. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12929. result, _ := json.Marshal(respJSON)
  12930. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12931. utils.ErrorLog("解析失败:%v", err)
  12932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12933. return
  12934. }
  12935. res.ErrMsg = res10265.ErrMsg
  12936. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12937. res.Infcode = infocode
  12938. res.Output = res10265.Output
  12939. res.InfRefmsgid = res10265.InfRefmsgid
  12940. if res.Infcode == 0 {
  12941. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12942. if err == gorm.ErrRecordNotFound {
  12943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12944. return
  12945. } else if err != nil {
  12946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12947. return
  12948. } else {
  12949. bas := strings.Split(card_info, "|")
  12950. basNumber := bas[2]
  12951. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12952. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12953. infoStr := string(Iinfos)
  12954. idetinfoStr := string(Idetinfos)
  12955. psn := &models.HisPsn{
  12956. PsnNo: res.Output.Baseinfo.PsnNo,
  12957. PatientId: patient.ID,
  12958. Certno: res.Output.Baseinfo.Certno,
  12959. Gend: res.Output.Baseinfo.Gend,
  12960. Naty: res.Output.Baseinfo.Naty,
  12961. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12962. PsnName: res.Output.Baseinfo.PsnName,
  12963. Idetinfo: idetinfoStr,
  12964. Insuinfo: infoStr,
  12965. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12966. CardInfo: card_info,
  12967. VerifyNumber: token,
  12968. }
  12969. service.CreateHisPsn(psn)
  12970. var rf []*ResultFive
  12971. json.Unmarshal([]byte(infoStr), &rf)
  12972. var insutypes []*ResultFive
  12973. var insutype string
  12974. var is390 int = 0
  12975. var is310 int = 0
  12976. for _, item := range rf {
  12977. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12978. insutypes = append(insutypes, item)
  12979. }
  12980. }
  12981. if len(insutypes) == 1 {
  12982. insutype = insutypes[0].Insutype
  12983. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12984. } else {
  12985. for _, i := range insutypes {
  12986. if i.Insutype == "390" {
  12987. is390 = 1
  12988. }
  12989. if i.Insutype == "310" {
  12990. is310 = 1
  12991. }
  12992. }
  12993. }
  12994. if is390 == 1 {
  12995. insutype = "390"
  12996. }
  12997. if is310 == 1 {
  12998. insutype = "310"
  12999. }
  13000. if len(insutypes) == 0 {
  13001. insutype = "310"
  13002. }
  13003. c.ServeSuccessJSON(map[string]interface{}{
  13004. "patient": patient,
  13005. "number": basNumber,
  13006. "insutype": insutype,
  13007. })
  13008. }
  13009. } else {
  13010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13011. return
  13012. }
  13013. } else if miConfig.MdtrtareaAdmvs == "450721" {
  13014. res := c.GetoleInfo()
  13015. if res.Infcode == 0 {
  13016. var result string
  13017. if res.Output.MdtrtCertType == "01" {
  13018. 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)
  13019. } else if res.Output.MdtrtCertType == "02" {
  13020. 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)
  13021. } else if res.Output.MdtrtCertType == "03" {
  13022. 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)
  13023. }
  13024. var dat map[string]interface{}
  13025. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13026. fmt.Println(dat)
  13027. } else {
  13028. fmt.Println(err)
  13029. }
  13030. userJSONBytes, _ := json.Marshal(dat)
  13031. var res2 ResultTwo
  13032. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13033. utils.ErrorLog("解析失败:%v", err)
  13034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13035. return
  13036. }
  13037. if res2.Infcode == 0 {
  13038. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  13039. if err == gorm.ErrRecordNotFound {
  13040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13041. return
  13042. } else if err != nil {
  13043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13044. return
  13045. } else {
  13046. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  13047. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  13048. infoStr := string(Iinfos)
  13049. idetinfoStr := string(Idetinfos)
  13050. var rf []*ResultFive
  13051. json.Unmarshal([]byte(infoStr), &rf)
  13052. var insutypes []*ResultFive
  13053. var insutype string
  13054. var is390 int = 0
  13055. var is310 int = 0
  13056. //var insuplc_admdvs string
  13057. for _, item := range rf {
  13058. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13059. insutypes = append(insutypes, item)
  13060. }
  13061. }
  13062. if len(insutypes) == 1 {
  13063. insutype = insutypes[0].Insutype
  13064. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13065. } else {
  13066. for _, i := range insutypes {
  13067. if i.Insutype == "390" {
  13068. is390 = 1
  13069. }
  13070. if i.Insutype == "310" {
  13071. is310 = 1
  13072. }
  13073. }
  13074. }
  13075. if is390 == 1 {
  13076. insutype = "390"
  13077. }
  13078. if is310 == 1 {
  13079. insutype = "310"
  13080. }
  13081. if len(insutypes) == 0 {
  13082. insutype = "310"
  13083. }
  13084. psn := &models.HisPsn{
  13085. PsnNo: res2.Output.Baseinfo.PsnNo,
  13086. PatientId: patient.ID,
  13087. Certno: res2.Output.Baseinfo.Certno,
  13088. Gend: res2.Output.Baseinfo.Gend,
  13089. Naty: res2.Output.Baseinfo.Naty,
  13090. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  13091. PsnName: res2.Output.Baseinfo.PsnName,
  13092. Idetinfo: idetinfoStr,
  13093. Insuinfo: infoStr,
  13094. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13095. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  13096. VerifyNumber: res.Output.EcToken,
  13097. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  13098. }
  13099. if res.Output.MdtrtCertType == "01" {
  13100. psn.VerifyNumber = res.Output.EcToken
  13101. //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)
  13102. } else if res.Output.MdtrtCertType == "02" {
  13103. psn.VerifyNumber = res.Output.MdtrtCertNo
  13104. //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)
  13105. } else if res.Output.MdtrtCertType == "03" {
  13106. psn.VerifyNumber = res.Output.MdtrtCertNo
  13107. //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)
  13108. }
  13109. var balc float64
  13110. for _, item := range rf {
  13111. if item.Insutype == insutype {
  13112. balc = item.Balc
  13113. }
  13114. }
  13115. service.CreateHisPsn(psn)
  13116. c.ServeSuccessJSON(map[string]interface{}{
  13117. "patient": patient,
  13118. "number": res.Output.CardNo,
  13119. "insutype": insutype,
  13120. "blac": balc,
  13121. "desc": idetinfoStr,
  13122. })
  13123. }
  13124. } else {
  13125. c.ServeSuccessJSON(map[string]interface{}{
  13126. "failed_code": -10,
  13127. "msg": res2.ErrMsg,
  13128. })
  13129. }
  13130. } else {
  13131. c.ServeSuccessJSON(map[string]interface{}{
  13132. "failed_code": -10,
  13133. "msg": res.ErrMsg,
  13134. })
  13135. }
  13136. } else if miConfig.MdtrtareaAdmvs == "341203" {
  13137. var api string
  13138. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  13139. "&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
  13140. fmt.Println(api)
  13141. resp, requestErr := http.Get(api)
  13142. if requestErr != nil {
  13143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13144. return
  13145. }
  13146. body, ioErr := ioutil.ReadAll(resp.Body)
  13147. if ioErr != nil {
  13148. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13150. return
  13151. }
  13152. var respJSON map[string]interface{}
  13153. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13154. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13156. return
  13157. }
  13158. var status string
  13159. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13160. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13161. //console.log()
  13162. fmt.Println("type===")
  13163. fmt.Println(card_type)
  13164. var token string
  13165. var res ResultTwo //1101结果
  13166. //var res10265 ResultTwoesultTwo10265 //1101结果
  13167. var card_info string //卡信息
  13168. var busi_card_info string
  13169. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13170. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13171. if status == "0" { //读卡成功
  13172. if card_type == "1" {
  13173. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13174. result, _ := json.Marshal(respJSON)
  13175. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13176. utils.ErrorLog("解析失败:%v", err)
  13177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13178. return
  13179. }
  13180. } else {
  13181. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13182. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13183. result, _ := json.Marshal(respJSON)
  13184. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13185. utils.ErrorLog("解析失败:%v", err)
  13186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13187. return
  13188. }
  13189. }
  13190. if res.Infcode == 0 {
  13191. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13192. if err == gorm.ErrRecordNotFound {
  13193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13194. return
  13195. } else if err != nil {
  13196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13197. return
  13198. } else {
  13199. if card_type == "1" {
  13200. bas := strings.Split(card_info, "|")
  13201. basNumber := bas[2]
  13202. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13203. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13204. infoStr := string(Iinfos)
  13205. idetinfoStr := string(Idetinfos)
  13206. psn := &models.HisPsn{
  13207. PsnNo: res.Output.Baseinfo.PsnNo,
  13208. PatientId: patient.ID,
  13209. Certno: res.Output.Baseinfo.Certno,
  13210. Gend: res.Output.Baseinfo.Gend,
  13211. Naty: res.Output.Baseinfo.Naty,
  13212. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13213. PsnName: res.Output.Baseinfo.PsnName,
  13214. Idetinfo: idetinfoStr,
  13215. Insuinfo: infoStr,
  13216. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13217. CardInfo: card_info,
  13218. VerifyNumber: busi_card_info,
  13219. }
  13220. service.CreateHisPsn(psn)
  13221. var rf []*ResultFive
  13222. json.Unmarshal([]byte(infoStr), &rf)
  13223. var insutypes []*ResultFive
  13224. var insutype string
  13225. var is390 int = 0
  13226. var is310 int = 0
  13227. for _, item := range rf {
  13228. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13229. insutypes = append(insutypes, item)
  13230. }
  13231. }
  13232. if len(insutypes) == 1 {
  13233. insutype = insutypes[0].Insutype
  13234. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13235. } else {
  13236. for _, i := range insutypes {
  13237. if i.Insutype == "390" {
  13238. is390 = 1
  13239. }
  13240. if i.Insutype == "310" {
  13241. is310 = 1
  13242. }
  13243. }
  13244. }
  13245. if is390 == 1 {
  13246. insutype = "390"
  13247. }
  13248. if is310 == 1 {
  13249. insutype = "310"
  13250. }
  13251. if len(insutypes) == 0 {
  13252. insutype = "310"
  13253. }
  13254. c.ServeSuccessJSON(map[string]interface{}{
  13255. "patient": patient,
  13256. "number": basNumber,
  13257. "insutype": insutype,
  13258. })
  13259. } else {
  13260. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13261. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13262. infoStr := string(Iinfos)
  13263. idetinfoStr := string(Idetinfos)
  13264. psn := &models.HisPsn{
  13265. PsnNo: res.Output.Baseinfo.PsnNo,
  13266. PatientId: patient.ID,
  13267. Certno: res.Output.Baseinfo.Certno,
  13268. Gend: res.Output.Baseinfo.Gend,
  13269. Naty: res.Output.Baseinfo.Naty,
  13270. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13271. PsnName: res.Output.Baseinfo.PsnName,
  13272. Idetinfo: idetinfoStr,
  13273. Insuinfo: infoStr,
  13274. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13275. CardInfo: card_info,
  13276. VerifyNumber: token,
  13277. }
  13278. service.CreateHisPsn(psn)
  13279. c.ServeSuccessJSON(map[string]interface{}{
  13280. "patient": patient,
  13281. "number": token,
  13282. })
  13283. }
  13284. }
  13285. } else {
  13286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13287. return
  13288. }
  13289. } else { //读卡失败
  13290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13291. return
  13292. }
  13293. } else {
  13294. if initFlag == 0 {
  13295. c.TestGetBasBaseInit()
  13296. }
  13297. basStr := c.GetBasBaseInfo()
  13298. if len(basStr) == 0 {
  13299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13300. return
  13301. }
  13302. fmt.Println(basStr)
  13303. bas := strings.Split(basStr, "|")
  13304. basNumber := bas[1]
  13305. fmt.Println(basNumber)
  13306. card_sn := bas[3]
  13307. fmt.Println(card_sn)
  13308. cardNumber := bas[2]
  13309. fmt.Println(cardNumber)
  13310. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  13311. var result string
  13312. if bas[0][:2] == "44" {
  13313. 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)
  13314. } else {
  13315. 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)
  13316. }
  13317. var dat map[string]interface{}
  13318. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13319. fmt.Println(dat)
  13320. } else {
  13321. fmt.Println(err)
  13322. }
  13323. userJSONBytes, _ := json.Marshal(dat)
  13324. var res ResultTwo
  13325. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13326. utils.ErrorLog("解析失败:%v", err)
  13327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13328. return
  13329. }
  13330. if res.Infcode == 0 {
  13331. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13332. if err == gorm.ErrRecordNotFound {
  13333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13334. return
  13335. } else if err != nil {
  13336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13337. return
  13338. } else {
  13339. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13340. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13341. infoStr := string(Iinfos)
  13342. idetinfoStr := string(Idetinfos)
  13343. var rf []*ResultFive
  13344. json.Unmarshal([]byte(infoStr), &rf)
  13345. var insutypes []*ResultFive
  13346. var insutype string
  13347. var is390 int = 0
  13348. var is310 int = 0
  13349. var insuplc_admdvs string
  13350. for _, item := range rf {
  13351. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13352. insutypes = append(insutypes, item)
  13353. }
  13354. }
  13355. if len(insutypes) == 1 {
  13356. insutype = insutypes[0].Insutype
  13357. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13358. } else {
  13359. for _, i := range insutypes {
  13360. if i.Insutype == "390" {
  13361. is390 = 1
  13362. }
  13363. if i.Insutype == "310" {
  13364. is310 = 1
  13365. }
  13366. }
  13367. }
  13368. if is390 == 1 {
  13369. insutype = "390"
  13370. }
  13371. if is310 == 1 {
  13372. insutype = "310"
  13373. }
  13374. if len(insutypes) == 0 {
  13375. insutype = "310"
  13376. }
  13377. for _, item := range rf {
  13378. if item.Insutype == insutype {
  13379. insuplc_admdvs = item.InsuplcAdmdvs
  13380. }
  13381. }
  13382. psn := &models.HisPsn{
  13383. PsnNo: res.Output.Baseinfo.PsnNo,
  13384. PatientId: patient.ID,
  13385. Certno: res.Output.Baseinfo.Certno,
  13386. Gend: res.Output.Baseinfo.Gend,
  13387. Naty: res.Output.Baseinfo.Naty,
  13388. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13389. PsnName: res.Output.Baseinfo.PsnName,
  13390. Idetinfo: idetinfoStr,
  13391. Insuinfo: infoStr,
  13392. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13393. CardInfo: basStr,
  13394. VerifyNumber: "",
  13395. InsuplcAdmdvs: insuplc_admdvs,
  13396. }
  13397. service.CreateHisPsn(psn)
  13398. c.ServeSuccessJSON(map[string]interface{}{
  13399. "patient": patient,
  13400. "number": basNumber,
  13401. })
  13402. }
  13403. } else {
  13404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13405. return
  13406. }
  13407. break
  13408. }
  13409. case 2:
  13410. if miConfig.MdtrtareaAdmvs == "430800" {
  13411. if initFlag == 0 {
  13412. c.TestGetHnBasBaseInit()
  13413. }
  13414. SFZStr := c.GetSFZBaseInfo()
  13415. if len(SFZStr) == 0 {
  13416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13417. return
  13418. }
  13419. fmt.Println(SFZStr)
  13420. id_card_str := strings.Split(SFZStr, "^")
  13421. card_no := id_card_str[0]
  13422. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  13423. //name := id_card_str[1]
  13424. //name = ConvertToString(name, "gbk", "utf-8")
  13425. 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)
  13426. var dat map[string]interface{}
  13427. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13428. fmt.Println(dat)
  13429. } else {
  13430. fmt.Println(err)
  13431. }
  13432. userJSONBytes, _ := json.Marshal(dat)
  13433. var res ResultTwo
  13434. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13435. utils.ErrorLog("解析失败:%v", err)
  13436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13437. return
  13438. }
  13439. if res.Infcode == 0 {
  13440. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  13441. if err == gorm.ErrRecordNotFound {
  13442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13443. return
  13444. } else if err != nil {
  13445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13446. return
  13447. } else {
  13448. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13449. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13450. infoStr := string(Iinfos)
  13451. idetinfoStr := string(Idetinfos)
  13452. var rf []*ResultFive
  13453. json.Unmarshal([]byte(infoStr), &rf)
  13454. var insutypes []*ResultFive
  13455. var insutype string
  13456. var is390 int = 0
  13457. var is310 int = 0
  13458. for _, item := range rf {
  13459. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13460. insutypes = append(insutypes, item)
  13461. }
  13462. }
  13463. if len(insutypes) == 1 {
  13464. insutype = insutypes[0].Insutype
  13465. } else {
  13466. for _, i := range insutypes {
  13467. if i.Insutype == "390" {
  13468. is390 = 1
  13469. }
  13470. if i.Insutype == "310" {
  13471. is310 = 1
  13472. }
  13473. }
  13474. }
  13475. if is390 == 1 {
  13476. insutype = "390"
  13477. }
  13478. if is310 == 1 {
  13479. insutype = "310"
  13480. }
  13481. if len(insutypes) == 0 {
  13482. insutype = "310"
  13483. }
  13484. var InsuplcAdmdvs string
  13485. for _, item := range rf {
  13486. if item.Insutype == insutype {
  13487. InsuplcAdmdvs = item.InsuplcAdmdvs
  13488. }
  13489. }
  13490. psn := &models.HisPsn{
  13491. PsnNo: res.Output.Baseinfo.PsnNo,
  13492. PatientId: patient.ID,
  13493. Certno: res.Output.Baseinfo.Certno,
  13494. Gend: res.Output.Baseinfo.Gend,
  13495. Naty: res.Output.Baseinfo.Naty,
  13496. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13497. PsnName: res.Output.Baseinfo.PsnName,
  13498. Idetinfo: idetinfoStr,
  13499. Insuinfo: infoStr,
  13500. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13501. CardInfo: SFZStr,
  13502. VerifyNumber: "",
  13503. InsuplcAdmdvs: InsuplcAdmdvs,
  13504. }
  13505. service.CreateHisPsn(psn)
  13506. c.ServeSuccessJSON(map[string]interface{}{
  13507. "patient": patient,
  13508. "number": card_no,
  13509. "insutype": insutype,
  13510. })
  13511. }
  13512. } else {
  13513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13514. return
  13515. }
  13516. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13517. var res ResultTwo
  13518. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  13519. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13520. "&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)
  13521. resp, requestErr := http.Get(api)
  13522. if requestErr != nil {
  13523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13524. return
  13525. }
  13526. body, ioErr := ioutil.ReadAll(resp.Body)
  13527. if ioErr != nil {
  13528. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13530. return
  13531. }
  13532. var respJSON map[string]interface{}
  13533. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13534. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13536. return
  13537. }
  13538. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13539. result, _ := json.Marshal(respJSON)
  13540. fmt.Println("log")
  13541. fmt.Println(string(result))
  13542. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13543. utils.ErrorLog("解析失败:%v", err)
  13544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13545. return
  13546. }
  13547. if res.Infcode == 0 {
  13548. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13549. if err == gorm.ErrRecordNotFound {
  13550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13551. return
  13552. } else if err != nil {
  13553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13554. return
  13555. } else {
  13556. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13557. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13558. infoStr := string(Iinfos)
  13559. idetinfoStr := string(Idetinfos)
  13560. psn := &models.HisPsn{
  13561. PsnNo: res.Output.Baseinfo.PsnNo,
  13562. PatientId: patient.ID,
  13563. Certno: res.Output.Baseinfo.Certno,
  13564. Gend: res.Output.Baseinfo.Gend,
  13565. Naty: res.Output.Baseinfo.Naty,
  13566. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13567. PsnName: res.Output.Baseinfo.PsnName,
  13568. Idetinfo: idetinfoStr,
  13569. Insuinfo: infoStr,
  13570. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13571. }
  13572. service.CreateHisPsn(psn)
  13573. c.ServeSuccessJSON(map[string]interface{}{
  13574. "patient": patient,
  13575. "number": res.Output.Baseinfo.Certno,
  13576. })
  13577. }
  13578. } else {
  13579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13580. return
  13581. }
  13582. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13583. var res ResultTwo
  13584. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13585. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13586. "&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)
  13587. resp, requestErr := http.Get(api)
  13588. if requestErr != nil {
  13589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13590. return
  13591. }
  13592. body, ioErr := ioutil.ReadAll(resp.Body)
  13593. if ioErr != nil {
  13594. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13596. return
  13597. }
  13598. var respJSON map[string]interface{}
  13599. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13600. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13602. return
  13603. }
  13604. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13605. result, _ := json.Marshal(respJSON)
  13606. fmt.Println("log")
  13607. fmt.Println(string(result))
  13608. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13609. utils.ErrorLog("解析失败:%v", err)
  13610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13611. return
  13612. }
  13613. if res.Infcode == 0 {
  13614. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13615. if err == gorm.ErrRecordNotFound {
  13616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13617. return
  13618. } else if err != nil {
  13619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13620. return
  13621. } else {
  13622. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13623. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13624. infoStr := string(Iinfos)
  13625. idetinfoStr := string(Idetinfos)
  13626. psn := &models.HisPsn{
  13627. PsnNo: res.Output.Baseinfo.PsnNo,
  13628. PatientId: patient.ID,
  13629. Certno: res.Output.Baseinfo.Certno,
  13630. Gend: res.Output.Baseinfo.Gend,
  13631. Naty: res.Output.Baseinfo.Naty,
  13632. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13633. PsnName: res.Output.Baseinfo.PsnName,
  13634. Idetinfo: idetinfoStr,
  13635. Insuinfo: infoStr,
  13636. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13637. }
  13638. service.CreateHisPsn(psn)
  13639. c.ServeSuccessJSON(map[string]interface{}{
  13640. "patient": patient,
  13641. "number": res.Output.Baseinfo.Certno,
  13642. })
  13643. }
  13644. } else {
  13645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13646. return
  13647. }
  13648. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13649. var res ResultTwo
  13650. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13651. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13652. "&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)
  13653. resp, requestErr := http.Get(api)
  13654. if requestErr != nil {
  13655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13656. return
  13657. }
  13658. body, ioErr := ioutil.ReadAll(resp.Body)
  13659. if ioErr != nil {
  13660. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13662. return
  13663. }
  13664. var respJSON map[string]interface{}
  13665. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13666. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13668. return
  13669. }
  13670. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13671. result, _ := json.Marshal(respJSON)
  13672. fmt.Println("log")
  13673. fmt.Println(string(result))
  13674. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13675. utils.ErrorLog("解析失败:%v", err)
  13676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13677. return
  13678. }
  13679. if res.Infcode == 0 {
  13680. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13681. if err == gorm.ErrRecordNotFound {
  13682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13683. return
  13684. } else if err != nil {
  13685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13686. return
  13687. } else {
  13688. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13689. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13690. infoStr := string(Iinfos)
  13691. idetinfoStr := string(Idetinfos)
  13692. var rf []*ResultFive
  13693. json.Unmarshal([]byte(infoStr), &rf)
  13694. var insutypes []*ResultFive
  13695. var insutype string
  13696. var is390 int = 0
  13697. var is310 int = 0
  13698. for _, item := range rf {
  13699. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13700. insutypes = append(insutypes, item)
  13701. }
  13702. }
  13703. if len(insutypes) == 1 {
  13704. insutype = insutypes[0].Insutype
  13705. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13706. } else {
  13707. for _, i := range insutypes {
  13708. if i.Insutype == "390" {
  13709. is390 = 1
  13710. }
  13711. if i.Insutype == "310" {
  13712. is310 = 1
  13713. }
  13714. }
  13715. }
  13716. if is390 == 1 {
  13717. insutype = "390"
  13718. }
  13719. if is310 == 1 {
  13720. insutype = "310"
  13721. }
  13722. if len(insutypes) == 0 {
  13723. insutype = "390"
  13724. }
  13725. var insuplc_admdvs string
  13726. for _, item := range rf {
  13727. if item.Insutype == insutype {
  13728. insuplc_admdvs = item.InsuplcAdmdvs
  13729. }
  13730. }
  13731. psn := &models.HisPsn{
  13732. PsnNo: res.Output.Baseinfo.PsnNo,
  13733. PatientId: patient.ID,
  13734. Certno: res.Output.Baseinfo.Certno,
  13735. Gend: res.Output.Baseinfo.Gend,
  13736. Naty: res.Output.Baseinfo.Naty,
  13737. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13738. PsnName: res.Output.Baseinfo.PsnName,
  13739. Idetinfo: idetinfoStr,
  13740. Insuinfo: infoStr,
  13741. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13742. InsuplcAdmdvs: insuplc_admdvs,
  13743. }
  13744. service.CreateHisPsn(psn)
  13745. c.ServeSuccessJSON(map[string]interface{}{
  13746. "patient": patient,
  13747. "number": res.Output.Baseinfo.Certno,
  13748. })
  13749. }
  13750. } else {
  13751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13752. return
  13753. }
  13754. } else if miConfig.MdtrtareaAdmvs == "450721" {
  13755. res := c.GetoleInfo()
  13756. if res.Infcode == 0 {
  13757. var result string
  13758. if res.Output.MdtrtCertType == "01" {
  13759. 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)
  13760. } else if res.Output.MdtrtCertType == "02" {
  13761. 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)
  13762. } else if res.Output.MdtrtCertType == "03" {
  13763. 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)
  13764. }
  13765. var dat map[string]interface{}
  13766. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13767. fmt.Println(dat)
  13768. } else {
  13769. fmt.Println(err)
  13770. }
  13771. userJSONBytes, _ := json.Marshal(dat)
  13772. var res2 ResultTwo
  13773. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13774. utils.ErrorLog("解析失败:%v", err)
  13775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13776. return
  13777. }
  13778. if res2.Infcode == 0 {
  13779. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  13780. if err == gorm.ErrRecordNotFound {
  13781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13782. return
  13783. } else if err != nil {
  13784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13785. return
  13786. } else {
  13787. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  13788. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  13789. infoStr := string(Iinfos)
  13790. idetinfoStr := string(Idetinfos)
  13791. var rf []*ResultFive
  13792. json.Unmarshal([]byte(infoStr), &rf)
  13793. var insutypes []*ResultFive
  13794. var insutype string
  13795. var is390 int = 0
  13796. var is310 int = 0
  13797. //var insuplc_admdvs string
  13798. for _, item := range rf {
  13799. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13800. insutypes = append(insutypes, item)
  13801. }
  13802. }
  13803. if len(insutypes) == 1 {
  13804. insutype = insutypes[0].Insutype
  13805. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13806. } else {
  13807. for _, i := range insutypes {
  13808. if i.Insutype == "390" {
  13809. is390 = 1
  13810. }
  13811. if i.Insutype == "310" {
  13812. is310 = 1
  13813. }
  13814. }
  13815. }
  13816. if is390 == 1 {
  13817. insutype = "390"
  13818. }
  13819. if is310 == 1 {
  13820. insutype = "310"
  13821. }
  13822. if len(insutypes) == 0 {
  13823. insutype = "310"
  13824. }
  13825. psn := &models.HisPsn{
  13826. PsnNo: res2.Output.Baseinfo.PsnNo,
  13827. PatientId: patient.ID,
  13828. //Brdy: res2.Output.Baseinfo.Brdy,
  13829. Certno: res2.Output.Baseinfo.Certno,
  13830. Gend: res2.Output.Baseinfo.Gend,
  13831. Naty: res2.Output.Baseinfo.Naty,
  13832. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  13833. PsnName: res2.Output.Baseinfo.PsnName,
  13834. Idetinfo: idetinfoStr,
  13835. Insuinfo: infoStr,
  13836. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13837. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  13838. VerifyNumber: res.Output.EcToken,
  13839. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  13840. }
  13841. service.CreateHisPsn(psn)
  13842. var balc float64
  13843. for _, item := range rf {
  13844. if item.Insutype == insutype {
  13845. balc = item.Balc
  13846. }
  13847. }
  13848. c.ServeSuccessJSON(map[string]interface{}{
  13849. "patient": patient,
  13850. "number": res.Output.CardNo,
  13851. "insutype": insutype,
  13852. "blac": balc,
  13853. "desc": idetinfoStr,
  13854. })
  13855. }
  13856. } else {
  13857. c.ServeSuccessJSON(map[string]interface{}{
  13858. "failed_code": -10,
  13859. "msg": res2.ErrMsg,
  13860. })
  13861. }
  13862. } else {
  13863. c.ServeSuccessJSON(map[string]interface{}{
  13864. "failed_code": -10,
  13865. "msg": res.ErrMsg,
  13866. })
  13867. }
  13868. } else {
  13869. SFZStr := c.GetSFZBaseInfo()
  13870. id_card_str := strings.Split(SFZStr, "^")
  13871. id_card_number := id_card_str[0]
  13872. card_sn := ""
  13873. 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)
  13874. var dat map[string]interface{}
  13875. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13876. fmt.Println(dat)
  13877. } else {
  13878. fmt.Println(err)
  13879. }
  13880. userJSONBytes, _ := json.Marshal(dat)
  13881. var res ResultTwo
  13882. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13883. utils.ErrorLog("解析失败:%v", err)
  13884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13885. return
  13886. }
  13887. if res.Infcode == 0 {
  13888. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  13889. if err == gorm.ErrRecordNotFound {
  13890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13891. return
  13892. } else if err != nil {
  13893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13894. return
  13895. } else {
  13896. c.ServeSuccessJSON(map[string]interface{}{
  13897. "patient": patient,
  13898. "number": id_card_number,
  13899. })
  13900. }
  13901. } else {
  13902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13903. return
  13904. }
  13905. }
  13906. break
  13907. case 3:
  13908. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13909. var api string
  13910. if miConfig.MdtrtareaAdmvs == "320921" {
  13911. 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 +
  13912. "&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
  13913. fmt.Println(api)
  13914. } else {
  13915. 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 +
  13916. "&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)
  13917. }
  13918. resp, requestErr := http.Get(api)
  13919. if requestErr != nil {
  13920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13921. return
  13922. }
  13923. body, ioErr := ioutil.ReadAll(resp.Body)
  13924. if ioErr != nil {
  13925. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13927. return
  13928. }
  13929. var respJSON map[string]interface{}
  13930. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13931. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13933. return
  13934. }
  13935. var status string
  13936. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13937. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13938. var token string
  13939. var res ResultTwo //1101结果
  13940. var res10265 ResultTwo10265 //1101结果
  13941. var card_info string //卡信息
  13942. var busi_card_info string
  13943. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13944. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13945. if status == "0" { //读卡成功
  13946. if card_type == "1" {
  13947. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13948. result, _ := json.Marshal(respJSON)
  13949. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13950. utils.ErrorLog("解析失败:%v", err)
  13951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13952. return
  13953. }
  13954. res.ErrMsg = res10265.ErrMsg
  13955. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13956. res.Infcode = infocode
  13957. res.Output = res10265.Output
  13958. res.InfRefmsgid = res10265.InfRefmsgid
  13959. } else {
  13960. //var card_info string //卡信息
  13961. //var busi_card_info string
  13962. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13963. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13964. //fmt.Println(card_info)
  13965. //fmt.Println(busi_card_info)
  13966. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13967. result, _ := json.Marshal(respJSON)
  13968. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13969. utils.ErrorLog("解析失败:%v", err)
  13970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13971. return
  13972. }
  13973. res.ErrMsg = res10265.ErrMsg
  13974. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13975. res.Infcode = infocode
  13976. res.Output = res10265.Output
  13977. res.InfRefmsgid = res10265.InfRefmsgid
  13978. }
  13979. if res.Infcode == 0 {
  13980. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13981. if err == gorm.ErrRecordNotFound {
  13982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13983. return
  13984. } else if err != nil {
  13985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13986. return
  13987. } else {
  13988. if card_type == "1" {
  13989. bas := strings.Split(card_info, "|")
  13990. basNumber := bas[2]
  13991. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13992. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13993. infoStr := string(Iinfos)
  13994. idetinfoStr := string(Idetinfos)
  13995. psn := &models.HisPsn{
  13996. PsnNo: res.Output.Baseinfo.PsnNo,
  13997. PatientId: patient.ID,
  13998. Certno: res.Output.Baseinfo.Certno,
  13999. //Brdy: res.Output.Baseinfo.Brdy,
  14000. Gend: res.Output.Baseinfo.Gend,
  14001. Naty: res.Output.Baseinfo.Naty,
  14002. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14003. PsnName: res.Output.Baseinfo.PsnName,
  14004. Idetinfo: idetinfoStr,
  14005. Insuinfo: infoStr,
  14006. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14007. CardInfo: card_info,
  14008. VerifyNumber: busi_card_info,
  14009. }
  14010. service.CreateHisPsn(psn)
  14011. c.ServeSuccessJSON(map[string]interface{}{
  14012. "patient": patient,
  14013. "number": basNumber,
  14014. })
  14015. } else {
  14016. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14017. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14018. infoStr := string(Iinfos)
  14019. idetinfoStr := string(Idetinfos)
  14020. psn := &models.HisPsn{
  14021. PsnNo: res.Output.Baseinfo.PsnNo,
  14022. PatientId: patient.ID,
  14023. Certno: res.Output.Baseinfo.Certno,
  14024. Gend: res.Output.Baseinfo.Gend,
  14025. Naty: res.Output.Baseinfo.Naty,
  14026. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14027. PsnName: res.Output.Baseinfo.PsnName,
  14028. Idetinfo: idetinfoStr,
  14029. Insuinfo: infoStr,
  14030. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14031. CardInfo: card_info,
  14032. VerifyNumber: token,
  14033. }
  14034. service.CreateHisPsn(psn)
  14035. var rf []*ResultFive
  14036. json.Unmarshal([]byte(infoStr), &rf)
  14037. var insutypes []*ResultFive
  14038. var insutype string
  14039. var is390 int = 0
  14040. var is310 int = 0
  14041. for _, item := range rf {
  14042. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14043. insutypes = append(insutypes, item)
  14044. }
  14045. }
  14046. if len(insutypes) == 1 {
  14047. insutype = insutypes[0].Insutype
  14048. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14049. } else {
  14050. for _, i := range insutypes {
  14051. if i.Insutype == "390" {
  14052. is390 = 1
  14053. }
  14054. if i.Insutype == "310" {
  14055. is310 = 1
  14056. }
  14057. }
  14058. }
  14059. if is390 == 1 {
  14060. insutype = "390"
  14061. }
  14062. if is310 == 1 {
  14063. insutype = "310"
  14064. }
  14065. if len(insutypes) == 0 {
  14066. insutype = "310"
  14067. }
  14068. c.ServeSuccessJSON(map[string]interface{}{
  14069. "patient": patient,
  14070. "number": token,
  14071. "insutype": insutype,
  14072. })
  14073. }
  14074. }
  14075. } else {
  14076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14077. return
  14078. }
  14079. } else { //读卡失败
  14080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14081. return
  14082. }
  14083. }
  14084. break
  14085. case 4:
  14086. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14087. var api string
  14088. if miConfig.MdtrtareaAdmvs == "320921" {
  14089. 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 +
  14090. "&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
  14091. fmt.Println(api)
  14092. } else {
  14093. 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 +
  14094. "&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)
  14095. }
  14096. resp, requestErr := http.Get(api)
  14097. if requestErr != nil {
  14098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14099. return
  14100. }
  14101. body, ioErr := ioutil.ReadAll(resp.Body)
  14102. if ioErr != nil {
  14103. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14105. return
  14106. }
  14107. var respJSON map[string]interface{}
  14108. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14109. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14111. return
  14112. }
  14113. var status string
  14114. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14115. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14116. var token string
  14117. var res ResultTwo //1101结果
  14118. var res10265 ResultTwo10265 //1101结果
  14119. if status == "0" { //读卡成功
  14120. var card_info string //卡信息
  14121. var busi_card_info string
  14122. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14123. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14124. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14125. fmt.Println(card_info)
  14126. fmt.Println(busi_card_info)
  14127. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14128. result, _ := json.Marshal(respJSON)
  14129. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14130. utils.ErrorLog("解析失败:%v", err)
  14131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14132. return
  14133. }
  14134. res.ErrMsg = res10265.ErrMsg
  14135. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14136. res.Infcode = infocode
  14137. res.Output = res10265.Output
  14138. res.InfRefmsgid = res10265.InfRefmsgid
  14139. if res.Infcode == 0 {
  14140. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14141. if err == gorm.ErrRecordNotFound {
  14142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14143. return
  14144. } else if err != nil {
  14145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14146. return
  14147. } else {
  14148. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14149. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14150. infoStr := string(Iinfos)
  14151. idetinfoStr := string(Idetinfos)
  14152. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  14153. psn := &models.HisPsn{
  14154. PsnNo: res.Output.Baseinfo.PsnNo,
  14155. PatientId: patient.ID,
  14156. Certno: res.Output.Baseinfo.Certno,
  14157. Brdy: b,
  14158. Age: float64(age),
  14159. //Brdy: res.Output.Baseinfo.Brdy,
  14160. Gend: res.Output.Baseinfo.Gend,
  14161. Naty: res.Output.Baseinfo.Naty,
  14162. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14163. PsnName: res.Output.Baseinfo.PsnName,
  14164. Idetinfo: idetinfoStr,
  14165. Insuinfo: infoStr,
  14166. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14167. CardInfo: card_info,
  14168. VerifyNumber: token,
  14169. }
  14170. var rf []*ResultFive
  14171. json.Unmarshal([]byte(infoStr), &rf)
  14172. var insutypes []*ResultFive
  14173. var insutype string
  14174. var is390 int = 0
  14175. var is310 int = 0
  14176. for _, item := range rf {
  14177. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14178. insutypes = append(insutypes, item)
  14179. }
  14180. }
  14181. if len(insutypes) == 1 {
  14182. insutype = insutypes[0].Insutype
  14183. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14184. } else {
  14185. for _, i := range insutypes {
  14186. if i.Insutype == "390" {
  14187. is390 = 1
  14188. }
  14189. if i.Insutype == "310" {
  14190. is310 = 1
  14191. }
  14192. }
  14193. }
  14194. if is390 == 1 {
  14195. insutype = "390"
  14196. }
  14197. if is310 == 1 {
  14198. insutype = "310"
  14199. }
  14200. if len(insutypes) == 0 {
  14201. insutype = "310"
  14202. }
  14203. service.CreateHisPsn(psn)
  14204. c.ServeSuccessJSON(map[string]interface{}{
  14205. "patient": patient,
  14206. "number": token,
  14207. "insutype": insutype,
  14208. })
  14209. }
  14210. } else {
  14211. c.ServeSuccessJSON(map[string]interface{}{
  14212. "failed_code": -10,
  14213. "msg": res.ErrMsg,
  14214. })
  14215. }
  14216. } else { //读卡失败
  14217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14218. return
  14219. }
  14220. } else if miConfig.MdtrtareaAdmvs == "341203" {
  14221. var api string
  14222. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14223. "&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
  14224. resp, requestErr := http.Get(api)
  14225. if requestErr != nil {
  14226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14227. return
  14228. }
  14229. body, ioErr := ioutil.ReadAll(resp.Body)
  14230. if ioErr != nil {
  14231. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14233. return
  14234. }
  14235. var respJSON map[string]interface{}
  14236. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14237. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14239. return
  14240. }
  14241. var status string
  14242. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14243. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14244. var token string
  14245. var res ResultTwo //1101结果
  14246. if status == "1" { //读卡成功
  14247. var card_info string //卡信息
  14248. var busi_card_info string
  14249. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14250. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14251. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14252. fmt.Println(card_info)
  14253. fmt.Println(busi_card_info)
  14254. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14255. result, _ := json.Marshal(respJSON)
  14256. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14257. utils.ErrorLog("解析失败:%v", err)
  14258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14259. return
  14260. }
  14261. if res.Infcode == 0 {
  14262. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14263. if err == gorm.ErrRecordNotFound {
  14264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14265. return
  14266. } else if err != nil {
  14267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14268. return
  14269. } else {
  14270. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14271. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14272. infoStr := string(Iinfos)
  14273. idetinfoStr := string(Idetinfos)
  14274. psn := &models.HisPsn{
  14275. PsnNo: res.Output.Baseinfo.PsnNo,
  14276. PatientId: patient.ID,
  14277. Certno: res.Output.Baseinfo.Certno,
  14278. Gend: res.Output.Baseinfo.Gend,
  14279. Naty: res.Output.Baseinfo.Naty,
  14280. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14281. PsnName: res.Output.Baseinfo.PsnName,
  14282. Idetinfo: idetinfoStr,
  14283. Insuinfo: infoStr,
  14284. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14285. CardInfo: card_info,
  14286. VerifyNumber: token,
  14287. }
  14288. var rf []*ResultFive
  14289. json.Unmarshal([]byte(infoStr), &rf)
  14290. var insutypes []*ResultFive
  14291. var insutype string
  14292. var is390 int = 0
  14293. var is310 int = 0
  14294. for _, item := range rf {
  14295. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14296. insutypes = append(insutypes, item)
  14297. }
  14298. }
  14299. if len(insutypes) == 1 {
  14300. insutype = insutypes[0].Insutype
  14301. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14302. } else {
  14303. for _, i := range insutypes {
  14304. if i.Insutype == "390" {
  14305. is390 = 1
  14306. }
  14307. if i.Insutype == "310" {
  14308. is310 = 1
  14309. }
  14310. }
  14311. }
  14312. if is390 == 1 {
  14313. insutype = "390"
  14314. }
  14315. if is310 == 1 {
  14316. insutype = "310"
  14317. }
  14318. if len(insutypes) == 0 {
  14319. insutype = "310"
  14320. }
  14321. service.CreateHisPsn(psn)
  14322. c.ServeSuccessJSON(map[string]interface{}{
  14323. "patient": patient,
  14324. "number": token,
  14325. "insutype": insutype,
  14326. })
  14327. }
  14328. } else {
  14329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14330. return
  14331. }
  14332. } else { //读卡失败
  14333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14334. return
  14335. }
  14336. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14337. //idNo := c.GetString("idNo")
  14338. //userName := c.GetString("userName")
  14339. //ecToken := c.GetString("ecToken")
  14340. //insuOrg := c.GetString("insuOrg")
  14341. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  14342. utils.ErrorLog("解析失败:%v", json_result)
  14343. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  14344. type ELeData struct {
  14345. Data struct {
  14346. IdNo string `json:"idNo"`
  14347. IdType string `json:"idType"`
  14348. UserName string `json:"userName"`
  14349. EcToken string `json:"ecToken"`
  14350. InsuOrg string `json:"insuOrg"`
  14351. Gender string `json:"gender"`
  14352. Birthday string `json:"birthday"`
  14353. Nationality string `json:"nationality"`
  14354. Email string `json:"email"`
  14355. Extra string `json:"extra"`
  14356. } `json:"data"`
  14357. Code int `json:"code"`
  14358. Message string `json:"message"`
  14359. }
  14360. var ele ELeData
  14361. err := json.Unmarshal([]byte(json_result), &ele)
  14362. if err != nil {
  14363. utils.ErrorLog("解析失败:%v", err)
  14364. }
  14365. token := ele.Data.EcToken
  14366. token = Remove0000(token)
  14367. 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)
  14368. saveLog(result2, requestLog2, "1101", "获取人员信息")
  14369. var res ResultTwo
  14370. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  14371. utils.ErrorLog("解析失败:%v", err)
  14372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14373. return
  14374. }
  14375. if res.Infcode == 0 {
  14376. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14377. if err == gorm.ErrRecordNotFound {
  14378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14379. return
  14380. } else if err != nil {
  14381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14382. return
  14383. } else {
  14384. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14385. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14386. infoStr := string(Iinfos)
  14387. idetinfoStr := string(Idetinfos)
  14388. psn := &models.HisPsn{
  14389. PsnNo: res.Output.Baseinfo.PsnNo,
  14390. PatientId: patient.ID,
  14391. Certno: res.Output.Baseinfo.Certno,
  14392. Gend: res.Output.Baseinfo.Gend,
  14393. Naty: res.Output.Baseinfo.Naty,
  14394. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14395. PsnName: res.Output.Baseinfo.PsnName,
  14396. Idetinfo: idetinfoStr,
  14397. Insuinfo: infoStr,
  14398. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14399. CardInfo: "",
  14400. Stage: "1",
  14401. VerifyNumber: token,
  14402. InsuplcAdmdvs: ele.Data.InsuOrg,
  14403. }
  14404. service.CreateHisPsn(psn)
  14405. var rf []*ResultFive
  14406. json.Unmarshal([]byte(infoStr), &rf)
  14407. var insutypes []*ResultFive
  14408. var insutype string
  14409. var is390 int = 0
  14410. var is310 int = 0
  14411. for _, item := range rf {
  14412. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14413. insutypes = append(insutypes, item)
  14414. }
  14415. }
  14416. if len(insutypes) == 1 {
  14417. insutype = insutypes[0].Insutype
  14418. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14419. } else {
  14420. for _, i := range insutypes {
  14421. if i.Insutype == "390" {
  14422. is390 = 1
  14423. }
  14424. if i.Insutype == "310" {
  14425. is310 = 1
  14426. }
  14427. }
  14428. }
  14429. if is390 == 1 {
  14430. insutype = "390"
  14431. }
  14432. if is310 == 1 {
  14433. insutype = "310"
  14434. }
  14435. if len(insutypes) == 0 {
  14436. insutype = "310"
  14437. }
  14438. c.ServeSuccessJSON(map[string]interface{}{
  14439. "patient": patient,
  14440. "number": token,
  14441. "insutype": insutype,
  14442. })
  14443. }
  14444. } else {
  14445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14446. return
  14447. }
  14448. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14449. //if initFlag == 0 {
  14450. //c.TestGetJiangXiBasBaseInit()
  14451. //}
  14452. //if initEleFlag == 0 {
  14453. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  14454. //}
  14455. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  14456. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  14457. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  14458. type ELeData struct {
  14459. Data struct {
  14460. IdNo string `json:"idNo"`
  14461. IdType string `json:"idType"`
  14462. UserName string `json:"userName"`
  14463. EcToken string `json:"ecToken"`
  14464. InsuOrg string `json:"insuOrg"`
  14465. Gender string `json:"gender"`
  14466. Birthday string `json:"birthday"`
  14467. Nationality string `json:"nationality"`
  14468. Email string `json:"email"`
  14469. Extra string `json:"extra"`
  14470. } `json:"data"`
  14471. Code int `json:"code"`
  14472. Message string `json:"message"`
  14473. }
  14474. var ele ELeData
  14475. err := json.Unmarshal([]byte(result), &ele)
  14476. if err != nil {
  14477. utils.ErrorLog("解析失败:%v", err)
  14478. }
  14479. token := ele.Data.EcToken
  14480. token = Remove0000(token)
  14481. 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)
  14482. saveLog(result2, requestLog2, "1101", "获取人员信息")
  14483. var res ResultTwo
  14484. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  14485. utils.ErrorLog("解析失败:%v", err)
  14486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14487. return
  14488. }
  14489. if res.Infcode == 0 {
  14490. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14491. if err == gorm.ErrRecordNotFound {
  14492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14493. return
  14494. } else if err != nil {
  14495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14496. return
  14497. } else {
  14498. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14499. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14500. infoStr := string(Iinfos)
  14501. idetinfoStr := string(Idetinfos)
  14502. psn := &models.HisPsn{
  14503. PsnNo: res.Output.Baseinfo.PsnNo,
  14504. PatientId: patient.ID,
  14505. Certno: res.Output.Baseinfo.Certno,
  14506. Gend: res.Output.Baseinfo.Gend,
  14507. Naty: res.Output.Baseinfo.Naty,
  14508. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14509. PsnName: res.Output.Baseinfo.PsnName,
  14510. Idetinfo: idetinfoStr,
  14511. Insuinfo: infoStr,
  14512. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14513. CardInfo: "",
  14514. VerifyNumber: token,
  14515. InsuplcAdmdvs: ele.Data.InsuOrg,
  14516. }
  14517. service.CreateHisPsn(psn)
  14518. var rf []*ResultFive
  14519. json.Unmarshal([]byte(infoStr), &rf)
  14520. var insutypes []*ResultFive
  14521. var insutype string
  14522. var is390 int = 0
  14523. var is310 int = 0
  14524. for _, item := range rf {
  14525. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14526. insutypes = append(insutypes, item)
  14527. }
  14528. }
  14529. if len(insutypes) == 1 {
  14530. insutype = insutypes[0].Insutype
  14531. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14532. } else {
  14533. for _, i := range insutypes {
  14534. if i.Insutype == "390" {
  14535. is390 = 1
  14536. }
  14537. if i.Insutype == "310" {
  14538. is310 = 1
  14539. }
  14540. }
  14541. }
  14542. if is390 == 1 {
  14543. insutype = "390"
  14544. }
  14545. if is310 == 1 {
  14546. insutype = "310"
  14547. }
  14548. if len(insutypes) == 0 {
  14549. insutype = "310"
  14550. }
  14551. c.ServeSuccessJSON(map[string]interface{}{
  14552. "patient": patient,
  14553. "number": token,
  14554. "insutype": insutype,
  14555. })
  14556. }
  14557. } else {
  14558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14559. return
  14560. }
  14561. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14562. //if initFlag == 0 {
  14563. c.TestGetJiangXiBasBaseInit()
  14564. //}
  14565. //if initEleFlag == 0 {
  14566. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  14567. //}
  14568. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  14569. type ELeData struct {
  14570. Data struct {
  14571. IdNo string `json:"idNo"`
  14572. IdType string `json:"idType"`
  14573. UserName string `json:"userName"`
  14574. EcToken string `json:"ecToken"`
  14575. InsuOrg string `json:"insuOrg"`
  14576. Gender string `json:"gender"`
  14577. Birthday string `json:"birthday"`
  14578. Nationality string `json:"nationality"`
  14579. Email string `json:"email"`
  14580. Extra string `json:"extra"`
  14581. } `json:"data"`
  14582. Code int `json:"code"`
  14583. Message string `json:"message"`
  14584. }
  14585. var ele ELeData
  14586. err := json.Unmarshal([]byte(json_result), &ele)
  14587. if err != nil {
  14588. utils.ErrorLog("解析失败:%v", err)
  14589. }
  14590. token := ele.Data.EcToken
  14591. token = Remove0000(token)
  14592. 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)
  14593. saveLog(result2, requestLog2, "1101", "获取人员信息")
  14594. var res ResultTwo
  14595. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  14596. utils.ErrorLog("解析失败:%v", err)
  14597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14598. return
  14599. }
  14600. if res.Infcode == 0 {
  14601. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14602. if err == gorm.ErrRecordNotFound {
  14603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14604. return
  14605. } else if err != nil {
  14606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14607. return
  14608. } else {
  14609. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14610. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14611. infoStr := string(Iinfos)
  14612. idetinfoStr := string(Idetinfos)
  14613. psn := &models.HisPsn{
  14614. PsnNo: res.Output.Baseinfo.PsnNo,
  14615. PatientId: patient.ID,
  14616. Certno: res.Output.Baseinfo.Certno,
  14617. Gend: res.Output.Baseinfo.Gend,
  14618. Naty: res.Output.Baseinfo.Naty,
  14619. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14620. PsnName: res.Output.Baseinfo.PsnName,
  14621. Idetinfo: idetinfoStr,
  14622. Insuinfo: infoStr,
  14623. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14624. CardInfo: "",
  14625. VerifyNumber: token,
  14626. }
  14627. service.CreateHisPsn(psn)
  14628. var rf []*ResultFive
  14629. json.Unmarshal([]byte(infoStr), &rf)
  14630. var insutypes []*ResultFive
  14631. var insutype string
  14632. var is390 int = 0
  14633. var is310 int = 0
  14634. for _, item := range rf {
  14635. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14636. insutypes = append(insutypes, item)
  14637. }
  14638. }
  14639. if len(insutypes) == 1 {
  14640. insutype = insutypes[0].Insutype
  14641. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14642. } else {
  14643. for _, i := range insutypes {
  14644. if i.Insutype == "390" {
  14645. is390 = 1
  14646. }
  14647. if i.Insutype == "310" {
  14648. is310 = 1
  14649. }
  14650. }
  14651. }
  14652. if is390 == 1 {
  14653. insutype = "390"
  14654. }
  14655. if is310 == 1 {
  14656. insutype = "310"
  14657. }
  14658. if len(insutypes) == 0 {
  14659. insutype = "310"
  14660. }
  14661. c.ServeSuccessJSON(map[string]interface{}{
  14662. "patient": patient,
  14663. "number": token,
  14664. "insutype": insutype,
  14665. })
  14666. }
  14667. } else {
  14668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14669. return
  14670. }
  14671. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14672. type ELeData struct {
  14673. Code string `json:"code"`
  14674. Data struct {
  14675. Aac002 string `json:"aac002"`
  14676. Aaz500 string `json:"aaz500"`
  14677. ActCardNo string `json:"actCardNo"`
  14678. Bab520 string `json:"bab520"`
  14679. Bkz543 string `json:"bkz543"`
  14680. BusinessType string `json:"businessType"`
  14681. CertfCodg string `json:"certfCodg"`
  14682. EcIndexNo string `json:"ecIndexNo"`
  14683. EcToken string `json:"ecToken"`
  14684. ID0000 string `json:"id0000"`
  14685. IDNo string `json:"idNo"`
  14686. IDType string `json:"idType"`
  14687. Idcode string `json:"idcode"`
  14688. IdentityToken string `json:"identity_token"`
  14689. InsuOrg string `json:"insuOrg"`
  14690. OfficeID string `json:"officeId"`
  14691. OfficeName string `json:"officeName"`
  14692. OperatorID string `json:"operatorId"`
  14693. OperatorName string `json:"operatorName"`
  14694. OrgID string `json:"orgId"`
  14695. UserName string `json:"userName"`
  14696. } `json:"data"`
  14697. Infno interface{} `json:"infno"`
  14698. Message string `json:"message"`
  14699. OrgID string `json:"orgId"`
  14700. TransType string `json:"transType"`
  14701. }
  14702. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  14703. outPutInfo = Remove0000(outPutInfo)
  14704. if len(outPutInfo) > 0 {
  14705. var ele ELeData
  14706. err := json.Unmarshal([]byte(outPutInfo), &ele)
  14707. if err != nil {
  14708. utils.ErrorLog("解析失败:%v", err)
  14709. }
  14710. token := ele.Data.EcToken
  14711. fmt.Println(inputInfo)
  14712. fmt.Println(outPutInfo)
  14713. 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)
  14714. saveLog(result, requestLog, "1101", "获取人员信息")
  14715. var dat map[string]interface{}
  14716. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14717. fmt.Println(dat)
  14718. } else {
  14719. fmt.Println(err)
  14720. }
  14721. userJSONBytes, _ := json.Marshal(dat)
  14722. var res ResultTwo
  14723. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14724. utils.ErrorLog("解析失败:%v", err)
  14725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14726. return
  14727. }
  14728. res.ErrMsg = errMsgLog
  14729. if res.Infcode == 0 {
  14730. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  14731. if err == gorm.ErrRecordNotFound {
  14732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14733. return
  14734. } else if err != nil {
  14735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14736. return
  14737. } else {
  14738. fmt.Println(res)
  14739. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14740. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14741. infoStr := string(Iinfos)
  14742. idetinfoStr := string(Idetinfos)
  14743. psn := &models.HisPsn{
  14744. PsnNo: res.Output.Baseinfo.PsnNo,
  14745. PatientId: patient.ID,
  14746. Certno: res.Output.Baseinfo.Certno,
  14747. Gend: res.Output.Baseinfo.Gend,
  14748. Naty: res.Output.Baseinfo.Naty,
  14749. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14750. PsnName: res.Output.Baseinfo.PsnName,
  14751. Idetinfo: idetinfoStr,
  14752. Insuinfo: infoStr,
  14753. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14754. CardInfo: outPutInfo,
  14755. VerifyNumber: token,
  14756. InsuplcAdmdvs: ele.Data.InsuOrg,
  14757. }
  14758. service.CreateHisPsn(psn)
  14759. var rf []*ResultFive
  14760. json.Unmarshal([]byte(infoStr), &rf)
  14761. var insutypes []*ResultFive
  14762. var insutype string
  14763. var is390 int = 0
  14764. var is310 int = 0
  14765. for _, item := range rf {
  14766. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14767. insutypes = append(insutypes, item)
  14768. }
  14769. }
  14770. if len(insutypes) == 1 {
  14771. insutype = insutypes[0].Insutype
  14772. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14773. } else {
  14774. for _, i := range insutypes {
  14775. if i.Insutype == "390" {
  14776. is390 = 1
  14777. }
  14778. if i.Insutype == "310" {
  14779. is310 = 1
  14780. }
  14781. }
  14782. }
  14783. if is390 == 1 {
  14784. insutype = "390"
  14785. }
  14786. if is310 == 1 {
  14787. insutype = "310"
  14788. }
  14789. if len(insutypes) == 0 {
  14790. insutype = "310"
  14791. }
  14792. c.ServeSuccessJSON(map[string]interface{}{
  14793. "patient": patient,
  14794. "number": token,
  14795. "insutype": insutype,
  14796. })
  14797. }
  14798. } else {
  14799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14800. return
  14801. }
  14802. }
  14803. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14804. var api string
  14805. 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 +
  14806. "&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
  14807. resp, requestErr := http.Get(api)
  14808. if requestErr != nil {
  14809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14810. return
  14811. }
  14812. body, ioErr := ioutil.ReadAll(resp.Body)
  14813. if ioErr != nil {
  14814. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14816. return
  14817. }
  14818. var respJSON map[string]interface{}
  14819. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14822. return
  14823. }
  14824. var status string
  14825. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14826. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14827. var token string
  14828. var res ResultTwo //1101结果
  14829. var res10265 ResultTwo10265 //1101结果
  14830. if status == "0" { //读卡成功
  14831. var card_info string //卡信息
  14832. var busi_card_info string
  14833. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14834. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14835. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14836. fmt.Println(card_info)
  14837. fmt.Println(busi_card_info)
  14838. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14839. result, _ := json.Marshal(respJSON)
  14840. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14841. utils.ErrorLog("解析失败:%v", err)
  14842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14843. return
  14844. }
  14845. res.ErrMsg = res10265.ErrMsg
  14846. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14847. res.Infcode = infocode
  14848. res.Output = res10265.Output
  14849. res.InfRefmsgid = res10265.InfRefmsgid
  14850. if res.Infcode == 0 {
  14851. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14852. if err == gorm.ErrRecordNotFound {
  14853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14854. return
  14855. } else if err != nil {
  14856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14857. return
  14858. } else {
  14859. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14860. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14861. infoStr := string(Iinfos)
  14862. idetinfoStr := string(Idetinfos)
  14863. psn := &models.HisPsn{
  14864. PsnNo: res.Output.Baseinfo.PsnNo,
  14865. PatientId: patient.ID,
  14866. Certno: res.Output.Baseinfo.Certno,
  14867. Gend: res.Output.Baseinfo.Gend,
  14868. Naty: res.Output.Baseinfo.Naty,
  14869. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14870. PsnName: res.Output.Baseinfo.PsnName,
  14871. Idetinfo: idetinfoStr,
  14872. Insuinfo: infoStr,
  14873. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14874. CardInfo: card_info,
  14875. VerifyNumber: token,
  14876. }
  14877. var rf []*ResultFive
  14878. json.Unmarshal([]byte(infoStr), &rf)
  14879. var insutypes []*ResultFive
  14880. var insutype string
  14881. var is390 int = 0
  14882. var is310 int = 0
  14883. for _, item := range rf {
  14884. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14885. insutypes = append(insutypes, item)
  14886. }
  14887. }
  14888. if len(insutypes) == 1 {
  14889. insutype = insutypes[0].Insutype
  14890. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14891. } else {
  14892. for _, i := range insutypes {
  14893. if i.Insutype == "390" {
  14894. is390 = 1
  14895. }
  14896. if i.Insutype == "310" {
  14897. is310 = 1
  14898. }
  14899. }
  14900. }
  14901. if is390 == 1 {
  14902. insutype = "390"
  14903. }
  14904. if is310 == 1 {
  14905. insutype = "310"
  14906. }
  14907. if len(insutypes) == 0 {
  14908. insutype = "310"
  14909. }
  14910. service.CreateHisPsn(psn)
  14911. c.ServeSuccessJSON(map[string]interface{}{
  14912. "patient": patient,
  14913. "number": token,
  14914. "insutype": insutype,
  14915. })
  14916. }
  14917. } else {
  14918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14919. return
  14920. }
  14921. } else { //读卡失败
  14922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14923. return
  14924. }
  14925. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14926. res := c.GetoleInfo()
  14927. if res.Infcode == 0 {
  14928. var result string
  14929. if res.Output.MdtrtCertType == "01" {
  14930. 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)
  14931. } else if res.Output.MdtrtCertType == "02" {
  14932. 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)
  14933. } else if res.Output.MdtrtCertType == "03" {
  14934. 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)
  14935. }
  14936. var dat map[string]interface{}
  14937. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14938. fmt.Println(dat)
  14939. } else {
  14940. fmt.Println(err)
  14941. }
  14942. userJSONBytes, _ := json.Marshal(dat)
  14943. var res2 ResultTwo
  14944. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14945. utils.ErrorLog("解析失败:%v", err)
  14946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14947. return
  14948. }
  14949. if res2.Infcode == 0 {
  14950. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14951. if err == gorm.ErrRecordNotFound {
  14952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14953. return
  14954. } else if err != nil {
  14955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14956. return
  14957. } else {
  14958. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14959. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14960. infoStr := string(Iinfos)
  14961. idetinfoStr := string(Idetinfos)
  14962. var rf []*ResultFive
  14963. json.Unmarshal([]byte(infoStr), &rf)
  14964. var insutypes []*ResultFive
  14965. var insutype string
  14966. var is390 int = 0
  14967. var is310 int = 0
  14968. //var insuplc_admdvs string
  14969. for _, item := range rf {
  14970. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14971. insutypes = append(insutypes, item)
  14972. }
  14973. }
  14974. if len(insutypes) == 1 {
  14975. insutype = insutypes[0].Insutype
  14976. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14977. } else {
  14978. for _, i := range insutypes {
  14979. if i.Insutype == "390" {
  14980. is390 = 1
  14981. }
  14982. if i.Insutype == "310" {
  14983. is310 = 1
  14984. }
  14985. }
  14986. }
  14987. if is390 == 1 {
  14988. insutype = "390"
  14989. }
  14990. if is310 == 1 {
  14991. insutype = "310"
  14992. }
  14993. if len(insutypes) == 0 {
  14994. insutype = "310"
  14995. }
  14996. psn := &models.HisPsn{
  14997. PsnNo: res2.Output.Baseinfo.PsnNo,
  14998. PatientId: patient.ID,
  14999. Certno: res2.Output.Baseinfo.Certno,
  15000. Gend: res2.Output.Baseinfo.Gend,
  15001. Naty: res2.Output.Baseinfo.Naty,
  15002. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  15003. PsnName: res2.Output.Baseinfo.PsnName,
  15004. Idetinfo: idetinfoStr,
  15005. Insuinfo: infoStr,
  15006. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15007. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  15008. VerifyNumber: res.Output.EcToken,
  15009. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  15010. }
  15011. if res.Output.MdtrtCertType == "01" {
  15012. psn.VerifyNumber = res.Output.EcToken
  15013. //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)
  15014. } else if res.Output.MdtrtCertType == "02" {
  15015. psn.VerifyNumber = res.Output.CardNo
  15016. //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)
  15017. } else if res.Output.MdtrtCertType == "03" {
  15018. psn.VerifyNumber = res.Output.MdtrtCertNo
  15019. //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)
  15020. }
  15021. service.CreateHisPsn(psn)
  15022. var balc float64
  15023. for _, item := range rf {
  15024. if item.Insutype == insutype {
  15025. balc = item.Balc
  15026. }
  15027. }
  15028. c.ServeSuccessJSON(map[string]interface{}{
  15029. "patient": patient,
  15030. "number": res.Output.CardNo,
  15031. "insutype": insutype,
  15032. "blac": balc,
  15033. "desc": idetinfoStr,
  15034. })
  15035. }
  15036. } else {
  15037. c.ServeSuccessJSON(map[string]interface{}{
  15038. "failed_code": -10,
  15039. "msg": res2.ErrMsg,
  15040. })
  15041. }
  15042. } else {
  15043. c.ServeSuccessJSON(map[string]interface{}{
  15044. "failed_code": -10,
  15045. "msg": res.ErrMsg,
  15046. })
  15047. }
  15048. } else if miConfig.MdtrtareaAdmvs == "420902" {
  15049. var res ResultTwo
  15050. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15051. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15052. "&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)
  15053. resp, requestErr := http.Get(api)
  15054. if requestErr != nil {
  15055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15056. return
  15057. }
  15058. body, ioErr := ioutil.ReadAll(resp.Body)
  15059. if ioErr != nil {
  15060. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15062. return
  15063. }
  15064. var respJSON map[string]interface{}
  15065. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15066. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15068. return
  15069. }
  15070. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15071. result, _ := json.Marshal(respJSON)
  15072. fmt.Println("log")
  15073. fmt.Println(string(result))
  15074. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15075. utils.ErrorLog("解析失败:%v", err)
  15076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15077. return
  15078. }
  15079. if res.Infcode == 0 {
  15080. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15081. if err == gorm.ErrRecordNotFound {
  15082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15083. return
  15084. } else if err != nil {
  15085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15086. return
  15087. } else {
  15088. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15089. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15090. infoStr := string(Iinfos)
  15091. idetinfoStr := string(Idetinfos)
  15092. var rf []*ResultFive
  15093. json.Unmarshal([]byte(infoStr), &rf)
  15094. var insutypes []*ResultFive
  15095. var insutype string
  15096. var is390 int = 0
  15097. var is310 int = 0
  15098. for _, item := range rf {
  15099. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  15100. insutypes = append(insutypes, item)
  15101. }
  15102. }
  15103. if len(insutypes) == 1 {
  15104. insutype = insutypes[0].Insutype
  15105. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15106. } else {
  15107. for _, i := range insutypes {
  15108. if i.Insutype == "390" {
  15109. is390 = 1
  15110. }
  15111. if i.Insutype == "310" {
  15112. is310 = 1
  15113. }
  15114. }
  15115. }
  15116. if is390 == 1 {
  15117. insutype = "390"
  15118. }
  15119. if is310 == 1 {
  15120. insutype = "310"
  15121. }
  15122. if len(insutypes) == 0 {
  15123. insutype = "390"
  15124. }
  15125. var insuplc_admdvs string
  15126. for _, item := range rf {
  15127. if item.Insutype == insutype {
  15128. insuplc_admdvs = item.InsuplcAdmdvs
  15129. }
  15130. }
  15131. psn := &models.HisPsn{
  15132. PsnNo: res.Output.Baseinfo.PsnNo,
  15133. PatientId: patient.ID,
  15134. Certno: res.Output.Baseinfo.Certno,
  15135. Gend: res.Output.Baseinfo.Gend,
  15136. Naty: res.Output.Baseinfo.Naty,
  15137. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15138. PsnName: res.Output.Baseinfo.PsnName,
  15139. Idetinfo: idetinfoStr,
  15140. Insuinfo: infoStr,
  15141. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15142. InsuplcAdmdvs: insuplc_admdvs,
  15143. }
  15144. service.CreateHisPsn(psn)
  15145. c.ServeSuccessJSON(map[string]interface{}{
  15146. "patient": patient,
  15147. "number": res.Output.Baseinfo.Certno,
  15148. })
  15149. }
  15150. } else {
  15151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15152. return
  15153. }
  15154. } else {
  15155. type ELeData struct {
  15156. Code string `json:"code"`
  15157. Data struct {
  15158. Aac002 string `json:"aac002"`
  15159. Aaz500 string `json:"aaz500"`
  15160. ActCardNo string `json:"actCardNo"`
  15161. Bab520 string `json:"bab520"`
  15162. Bkz543 string `json:"bkz543"`
  15163. BusinessType string `json:"businessType"`
  15164. CertfCodg string `json:"certfCodg"`
  15165. EcIndexNo string `json:"ecIndexNo"`
  15166. EcToken string `json:"ecToken"`
  15167. ID0000 string `json:"id0000"`
  15168. IDNo string `json:"idNo"`
  15169. IDType string `json:"idType"`
  15170. Idcode string `json:"idcode"`
  15171. IdentityToken string `json:"identity_token"`
  15172. InsuOrg string `json:"insuOrg"`
  15173. OfficeID string `json:"officeId"`
  15174. OfficeName string `json:"officeName"`
  15175. OperatorID string `json:"operatorId"`
  15176. OperatorName string `json:"operatorName"`
  15177. OrgID string `json:"orgId"`
  15178. UserName string `json:"userName"`
  15179. } `json:"data"`
  15180. Infno interface{} `json:"infno"`
  15181. Message string `json:"message"`
  15182. OrgID string `json:"orgId"`
  15183. TransType string `json:"transType"`
  15184. }
  15185. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  15186. fmt.Println(result)
  15187. outPutInfo := Remove0000(result)
  15188. fmt.Println(outPutInfo)
  15189. if len(outPutInfo) > 0 {
  15190. var ele ELeData
  15191. err := json.Unmarshal([]byte(outPutInfo), &ele)
  15192. if err != nil {
  15193. utils.ErrorLog("解析失败:%v", err)
  15194. }
  15195. token := ele.Data.EcToken
  15196. fmt.Println(outPutInfo)
  15197. 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)
  15198. saveLog(result, requestLog, "1101", "获取人员信息")
  15199. var dat map[string]interface{}
  15200. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15201. fmt.Println(dat)
  15202. } else {
  15203. fmt.Println(err)
  15204. }
  15205. userJSONBytes, _ := json.Marshal(dat)
  15206. var res ResultTwo
  15207. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15208. utils.ErrorLog("解析失败:%v", err)
  15209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15210. return
  15211. }
  15212. if res.Infcode == 0 {
  15213. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  15214. if err == gorm.ErrRecordNotFound {
  15215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15216. return
  15217. } else if err != nil {
  15218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15219. return
  15220. } else {
  15221. fmt.Println(res)
  15222. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15223. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15224. infoStr := string(Iinfos)
  15225. idetinfoStr := string(Idetinfos)
  15226. psn := &models.HisPsn{
  15227. PsnNo: res.Output.Baseinfo.PsnNo,
  15228. PatientId: patient.ID,
  15229. Certno: res.Output.Baseinfo.Certno,
  15230. Gend: res.Output.Baseinfo.Gend,
  15231. Naty: res.Output.Baseinfo.Naty,
  15232. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15233. PsnName: res.Output.Baseinfo.PsnName,
  15234. Idetinfo: idetinfoStr,
  15235. Insuinfo: infoStr,
  15236. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15237. CardInfo: outPutInfo,
  15238. VerifyNumber: token,
  15239. InsuplcAdmdvs: ele.Data.InsuOrg,
  15240. }
  15241. service.CreateHisPsn(psn)
  15242. var rf []*ResultFive
  15243. json.Unmarshal([]byte(infoStr), &rf)
  15244. var insutypes []*ResultFive
  15245. var insutype string
  15246. var is390 int = 0
  15247. var is310 int = 0
  15248. for _, item := range rf {
  15249. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15250. insutypes = append(insutypes, item)
  15251. }
  15252. }
  15253. if len(insutypes) == 1 {
  15254. insutype = insutypes[0].Insutype
  15255. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15256. } else {
  15257. for _, i := range insutypes {
  15258. if i.Insutype == "390" {
  15259. is390 = 1
  15260. }
  15261. if i.Insutype == "310" {
  15262. is310 = 1
  15263. }
  15264. }
  15265. }
  15266. if is390 == 1 {
  15267. insutype = "390"
  15268. }
  15269. if is310 == 1 {
  15270. insutype = "310"
  15271. }
  15272. if len(insutypes) == 0 {
  15273. insutype = "310"
  15274. }
  15275. c.ServeSuccessJSON(map[string]interface{}{
  15276. "patient": patient,
  15277. "number": token,
  15278. "insutype": insutype,
  15279. })
  15280. }
  15281. } else {
  15282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15283. return
  15284. }
  15285. }
  15286. //fmt.Println(result)
  15287. //
  15288. //if initFlag == 0 {
  15289. // c.TestGetBasBaseInit()
  15290. //}
  15291. //token := c.GetEleBaseInfo()
  15292. //
  15293. //token = Remove0000(token)
  15294. //
  15295. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  15296. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  15297. ////
  15298. //var res ResultTwo
  15299. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15300. // utils.ErrorLog("解析失败:%v", err)
  15301. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15302. // return
  15303. //}
  15304. //
  15305. //if res.Infcode == 0 {
  15306. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15307. // if err == gorm.ErrRecordNotFound {
  15308. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15309. // return
  15310. // } else if err != nil {
  15311. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15312. // return
  15313. //
  15314. // } else {
  15315. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15316. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15317. // infoStr := string(Iinfos)
  15318. // idetinfoStr := string(Idetinfos)
  15319. //
  15320. //
  15321. //
  15322. //
  15323. // var rf []*ResultFive
  15324. // json.Unmarshal([]byte(infoStr), &rf)
  15325. //
  15326. // var insutypes []*ResultFive
  15327. // var insutype string
  15328. // var is390 int = 0
  15329. // var is310 int = 0
  15330. // var insuplc_admdvs string
  15331. //
  15332. // for _, item := range rf {
  15333. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15334. // insutypes = append(insutypes, item)
  15335. // }
  15336. // }
  15337. //
  15338. // if len(insutypes) == 1 {
  15339. // insutype = insutypes[0].Insutype
  15340. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15341. // } else {
  15342. // for _, i := range insutypes {
  15343. // if i.Insutype == "390" {
  15344. // is390 = 1
  15345. // }
  15346. //
  15347. // if i.Insutype == "310" {
  15348. // is310 = 1
  15349. // }
  15350. // }
  15351. // }
  15352. // if is390 == 1 {
  15353. // insutype = "390"
  15354. // }
  15355. //
  15356. // if is310 == 1 {
  15357. // insutype = "310"
  15358. // }
  15359. // if len(insutypes) == 0 {
  15360. // insutype = "310"
  15361. // }
  15362. // for _, item := range rf {
  15363. // if item.Insutype == insutype {
  15364. // insuplc_admdvs = item.InsuplcAdmdvs
  15365. // }
  15366. // }
  15367. // psn := &models.HisPsn{
  15368. // PsnNo: res.Output.Baseinfo.PsnNo,
  15369. // Age: res.Output.Baseinfo.Age,
  15370. // PatientId: patient.ID,
  15371. // Certno: res.Output.Baseinfo.Certno,
  15372. // Brdy: res.Output.Baseinfo.Brdy,
  15373. // Gend: res.Output.Baseinfo.Gend,
  15374. // Naty: res.Output.Baseinfo.Naty,
  15375. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  15376. // PsnName: res.Output.Baseinfo.PsnName,
  15377. // Idetinfo: idetinfoStr,
  15378. // Insuinfo: infoStr,
  15379. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15380. // CardInfo: "",
  15381. // VerifyNumber: token,
  15382. // InsuplcAdmdvs: insuplc_admdvs,
  15383. // }
  15384. // service.CreateHisPsn(psn)
  15385. //
  15386. // c.ServeSuccessJSON(map[string]interface{}{
  15387. // "patient": patient,
  15388. // "number": token,
  15389. // })
  15390. // }
  15391. //} else {
  15392. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15393. // return
  15394. //}
  15395. }
  15396. break
  15397. case 5:
  15398. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15399. var api string
  15400. if miConfig.MdtrtareaAdmvs == "320921" {
  15401. 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 +
  15402. "&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
  15403. fmt.Println(api)
  15404. } else {
  15405. 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 +
  15406. "&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)
  15407. }
  15408. resp, requestErr := http.Get(api)
  15409. if requestErr != nil {
  15410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15411. return
  15412. }
  15413. body, ioErr := ioutil.ReadAll(resp.Body)
  15414. if ioErr != nil {
  15415. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15417. return
  15418. }
  15419. var respJSON map[string]interface{}
  15420. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15421. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15423. return
  15424. }
  15425. var status string
  15426. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15427. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15428. var token string
  15429. var res ResultTwo //1101结果
  15430. var res10265 ResultTwo10265 //1101结果
  15431. if status == "0" { //读卡成功
  15432. var card_info string //卡信息
  15433. //var busi_card_info string
  15434. var auth_info string
  15435. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15436. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15437. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15438. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  15439. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15440. result, _ := json.Marshal(respJSON)
  15441. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15442. utils.ErrorLog("解析失败:%v", err)
  15443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15444. return
  15445. }
  15446. res.ErrMsg = res10265.ErrMsg
  15447. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15448. res.Infcode = infocode
  15449. res.Output = res10265.Output
  15450. res.InfRefmsgid = res10265.InfRefmsgid
  15451. if res.Infcode == 0 {
  15452. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15453. if err == gorm.ErrRecordNotFound {
  15454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15455. return
  15456. } else if err != nil {
  15457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15458. return
  15459. } else {
  15460. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15461. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15462. infoStr := string(Iinfos)
  15463. idetinfoStr := string(Idetinfos)
  15464. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  15465. psn := &models.HisPsn{
  15466. PsnNo: res.Output.Baseinfo.PsnNo,
  15467. PatientId: patient.ID,
  15468. Certno: res.Output.Baseinfo.Certno,
  15469. Gend: res.Output.Baseinfo.Gend,
  15470. Brdy: b,
  15471. Age: float64(age),
  15472. Naty: res.Output.Baseinfo.Naty,
  15473. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15474. PsnName: res.Output.Baseinfo.PsnName,
  15475. Idetinfo: idetinfoStr,
  15476. Insuinfo: infoStr,
  15477. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15478. CardInfo: card_info,
  15479. VerifyNumber: token,
  15480. AuthInfo: auth_info,
  15481. }
  15482. var rf []*ResultFive
  15483. json.Unmarshal([]byte(infoStr), &rf)
  15484. var insutypes []*ResultFive
  15485. var insutype string
  15486. var is390 int = 0
  15487. var is310 int = 0
  15488. for _, item := range rf {
  15489. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15490. insutypes = append(insutypes, item)
  15491. }
  15492. }
  15493. if len(insutypes) == 1 {
  15494. insutype = insutypes[0].Insutype
  15495. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15496. } else {
  15497. for _, i := range insutypes {
  15498. if i.Insutype == "390" {
  15499. is390 = 1
  15500. }
  15501. if i.Insutype == "310" {
  15502. is310 = 1
  15503. }
  15504. }
  15505. }
  15506. if is390 == 1 {
  15507. insutype = "390"
  15508. }
  15509. if is310 == 1 {
  15510. insutype = "310"
  15511. }
  15512. if len(insutypes) == 0 {
  15513. insutype = "310"
  15514. }
  15515. service.CreateHisPsn(psn)
  15516. c.ServeSuccessJSON(map[string]interface{}{
  15517. "patient": patient,
  15518. "number": token,
  15519. "insutype": insutype,
  15520. })
  15521. }
  15522. } else {
  15523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15524. return
  15525. }
  15526. } else { //读卡失败
  15527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15528. return
  15529. }
  15530. }
  15531. break
  15532. }
  15533. }
  15534. var initFlag int64 = 0
  15535. var initEleFlag int64 = 0
  15536. func (c *HisApiController) TestGetBasBaseInit() {
  15537. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15538. Iinit := DllDef.MustFindProc("Init")
  15539. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15540. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  15541. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  15542. if ret != 0 {
  15543. fmt.Println("SSCard的报错原因:", err)
  15544. fmt.Println("SSCard的运算结果为:", ret)
  15545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15546. return
  15547. }
  15548. result := int(ret)
  15549. fmt.Println("SSCard的运算结果为1:", result)
  15550. initFlag = 1
  15551. return
  15552. }
  15553. func (c *HisApiController) HandleJiangXiReadCard() {
  15554. fmt.Println("~~~~~~")
  15555. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15556. admin_user_id, _ := c.GetInt64("admin_user_id")
  15557. id_card_type, _ := c.GetInt64("id_card_type")
  15558. //certificates, _ := c.GetInt64("certificates")
  15559. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  15560. if initFlag == 0 {
  15561. c.TestGetJiangXiBasBaseInit()
  15562. }
  15563. basStr := c.GetBasBaseInfo()
  15564. if len(basStr) == 0 {
  15565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15566. return
  15567. }
  15568. fmt.Println(basStr)
  15569. bas := strings.Split(basStr, "|")
  15570. basNumber := bas[1]
  15571. fmt.Println(basNumber)
  15572. card_sn := bas[3]
  15573. fmt.Println(card_sn)
  15574. 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, "")
  15575. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  15576. var dat map[string]interface{}
  15577. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15578. fmt.Println(dat)
  15579. } else {
  15580. fmt.Println(err)
  15581. }
  15582. userJSONBytes, _ := json.Marshal(dat)
  15583. var res ResultTwo
  15584. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15585. utils.ErrorLog("解析失败:%v", err)
  15586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15587. return
  15588. }
  15589. if res.Infcode == 0 {
  15590. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  15591. if err == gorm.ErrRecordNotFound {
  15592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15593. return
  15594. } else if err != nil {
  15595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15596. return
  15597. } else {
  15598. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15599. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15600. infoStr := string(Iinfos)
  15601. idetinfoStr := string(Idetinfos)
  15602. psn := &models.HisPsn{
  15603. PsnNo: res.Output.Baseinfo.PsnNo,
  15604. PatientId: patient.ID,
  15605. Certno: res.Output.Baseinfo.Certno,
  15606. Gend: res.Output.Baseinfo.Gend,
  15607. Naty: res.Output.Baseinfo.Naty,
  15608. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15609. PsnName: res.Output.Baseinfo.PsnName,
  15610. Idetinfo: idetinfoStr,
  15611. Insuinfo: infoStr,
  15612. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15613. CardInfo: basStr,
  15614. VerifyNumber: "",
  15615. }
  15616. service.CreateHisPsn(psn)
  15617. c.ServeSuccessJSON(map[string]interface{}{
  15618. "patient": patient,
  15619. "number": basNumber,
  15620. })
  15621. }
  15622. } else {
  15623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15624. return
  15625. }
  15626. }
  15627. func (c *HisApiController) TestGetHnBasBaseInit() {
  15628. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15629. Iinit := DllDef.MustFindProc("Init")
  15630. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15631. //http://10.77.211.236/CSB/hsa-fsi-1303
  15632. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  15633. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  15634. // 调用 Init 函数
  15635. 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"))))
  15636. //if ret != 0 {
  15637. fmt.Println("SSCard的报错原因:", err)
  15638. fmt.Println("SSCard的运算结果为:", ret)
  15639. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15640. // return
  15641. //}
  15642. result := int(ret)
  15643. fmt.Println("SSCard的运算结果为1:", result)
  15644. initFlag = 1
  15645. return
  15646. }
  15647. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  15648. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15649. Iinit := DllDef.MustFindProc("Init")
  15650. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15651. //http://10.77.211.236/CSB/hsa-fsi-1303
  15652. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360302"))
  15653. if ret != 0 {
  15654. fmt.Println("SSCard的报错原因:", err)
  15655. fmt.Println("SSCard的运算结果为:", ret)
  15656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15657. return
  15658. }
  15659. result := int(ret)
  15660. fmt.Println("SSCard的运算结果为1:", result)
  15661. initFlag = 1
  15662. return
  15663. }
  15664. func (c *HisApiController) GetSFZBaseInfo() string {
  15665. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15666. readCard := DllDef.MustFindProc("ReadSFZ")
  15667. if readCard == nil {
  15668. fmt.Println("readcard is nil")
  15669. readCard = DllDef.MustFindProc("ReadSFZ")
  15670. }
  15671. str := make([]byte, 8096)
  15672. str1 := make([]byte, 8096)
  15673. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  15674. fmt.Println(r)
  15675. return Remove0000(string(str))
  15676. }
  15677. func (c *HisApiController) GetEleBaseInfo() string {
  15678. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15679. readCard := DllDef.MustFindProc("GetQRBase")
  15680. fmt.Println(readCard)
  15681. if readCard == nil {
  15682. fmt.Println("readcard is nil")
  15683. readCard = DllDef.MustFindProc("GetQRBase")
  15684. }
  15685. str := make([]byte, 1024)
  15686. str1 := make([]byte, 1024)
  15687. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  15688. fmt.Println(ret2)
  15689. fmt.Println(string(str1))
  15690. fmt.Println(string(str))
  15691. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  15692. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  15693. if ret2 != 0 {
  15694. return ""
  15695. }
  15696. return string(str)
  15697. }
  15698. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  15699. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  15700. readCard := DllDef.MustFindProc("NationEcTrans")
  15701. fmt.Println(readCard)
  15702. fmt.Println("!!!!!")
  15703. pBusiCardInfo := make([]byte, 2048)
  15704. input := make(map[string]interface{})
  15705. inputData := make(map[string]interface{})
  15706. inputData["orgId"] = code
  15707. inputData["businessType"] = "01101"
  15708. inputData["operatorId"] = "1"
  15709. inputData["operatorName"] = "admin"
  15710. inputData["officeId"] = "001"
  15711. inputData["officeName"] = "血透室"
  15712. inputData["deviceType"] = ""
  15713. input["data"] = inputData
  15714. input["orgId"] = code
  15715. input["transType"] = "ec.query"
  15716. bytesData, _ := json.Marshal(input)
  15717. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  15718. fmt.Println(ret2)
  15719. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  15720. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  15721. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  15722. }
  15723. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  15724. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  15725. readCard := DllDef.MustFindProc("NationEcTrans")
  15726. fmt.Println(readCard)
  15727. fmt.Println("!!!!!")
  15728. pBusiCardInfo := make([]byte, 2048)
  15729. input := make(map[string]interface{})
  15730. inputData := make(map[string]interface{})
  15731. inputData["orgId"] = code
  15732. inputData["businessType"] = "01101"
  15733. inputData["operatorId"] = "9"
  15734. inputData["operatorName"] = "admin"
  15735. inputData["officeId"] = "001"
  15736. inputData["officeName"] = "血透室"
  15737. inputData["deviceType"] = ""
  15738. input["data"] = inputData
  15739. input["orgId"] = code
  15740. input["transType"] = "ec.query"
  15741. bytesData, _ := json.Marshal(input)
  15742. 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])))
  15743. fmt.Println(ret2)
  15744. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  15745. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  15746. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  15747. }
  15748. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  15749. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  15750. readCard := DllDef.MustFindProc("NationEcTrans")
  15751. fmt.Println(readCard)
  15752. fmt.Println("!!!!!")
  15753. pBusiCardInfo := make([]byte, 2048)
  15754. input := make(map[string]interface{})
  15755. inputData := make(map[string]interface{})
  15756. inputData["orgId"] = code
  15757. inputData["businessType"] = "01301"
  15758. inputData["operatorId"] = "9"
  15759. inputData["operatorName"] = "admin"
  15760. inputData["officeId"] = "001"
  15761. inputData["officeName"] = "血透室"
  15762. inputData["deviceType"] = ""
  15763. input["data"] = inputData
  15764. input["orgId"] = code
  15765. input["transType"] = "ec.query"
  15766. bytesData, _ := json.Marshal(input)
  15767. 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])))
  15768. fmt.Println(ret2)
  15769. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  15770. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  15771. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  15772. }
  15773. func GetJxEleBaseInfo(org_id int64) string {
  15774. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15775. readCard := DllDef.MustFindProc("NationEcTrans")
  15776. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  15777. if readCard == nil {
  15778. fmt.Println("readcard is nil")
  15779. readCard = DllDef.MustFindProc("NationEcTrans")
  15780. }
  15781. str1 := make([]byte, 1024)
  15782. data := make(map[string]interface{})
  15783. inputData := make(map[string]interface{})
  15784. inputData["orgId"] = miConfig.Code
  15785. inputData["businessType"] = "01101"
  15786. inputData["operatorId"] = "test001"
  15787. inputData["operatorName"] = "cn"
  15788. inputData["officeId"] = "32760"
  15789. inputData["officeName"] = "waike"
  15790. inputData["deviceType"] = ""
  15791. data["data"] = inputData
  15792. data["transType"] = "ec.query"
  15793. data["extra "] = ""
  15794. data["orgId"] = miConfig.Code
  15795. bytesData, _ := json.Marshal(data)
  15796. //bytesData, _ := json.Marshal(data)
  15797. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  15798. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  15799. fmt.Println(ret2)
  15800. fmt.Println(string(str1))
  15801. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  15802. if ret2 != 0 {
  15803. return ""
  15804. }
  15805. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  15806. }
  15807. //func GetJxEleBaseInfoTWO(org_id int64) string {
  15808. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  15809. // readCard := DllDef.MustFindProc("NationEcTrans")
  15810. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  15811. //
  15812. // if readCard == nil {
  15813. // fmt.Println("readcard is nil")
  15814. // readCard = DllDef.MustFindProc("NationEcTrans")
  15815. // }
  15816. // str1 := make([]byte, 1024)
  15817. //
  15818. // data := make(map[string]interface{})
  15819. //
  15820. // inputData := make(map[string]interface{})
  15821. // inputData["orgId"] = miConfig.Code
  15822. // inputData["businessType"] = "01101"
  15823. // inputData["operatorId"] = "test001"
  15824. // inputData["operatorName"] = "cn"
  15825. // inputData["officeId"] = "32760"
  15826. // inputData["officeName"] = "waike"
  15827. // inputData["deviceType"] = ""
  15828. //
  15829. // data["data"] = inputData
  15830. // data["transType"] = "ec.query"
  15831. // data["extra "] = ""
  15832. // data["orgId"] = miConfig.Code
  15833. // bytesData, _ := json.Marshal(data)
  15834. // //bytesData, _ := json.Marshal(data)
  15835. //
  15836. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  15837. //
  15838. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  15839. // fmt.Println(ret2)
  15840. // fmt.Println(string(str1))
  15841. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  15842. //
  15843. // if ret2 != 0 {
  15844. // return ""
  15845. // }
  15846. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  15847. //}
  15848. func GetJxEleBaseInitInfo(org_id int64) string {
  15849. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15850. readCard := DllDef.MustFindProc("NationEcTrans")
  15851. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  15852. if readCard == nil {
  15853. fmt.Println("readcard is nil")
  15854. readCard = DllDef.MustFindProc("NationEcTrans")
  15855. }
  15856. str1 := make([]byte, 2048)
  15857. data := make(map[string]interface{})
  15858. inputData := make(map[string]interface{})
  15859. inputData["orgId"] = miConfig.Code
  15860. inputData["businessType"] = "01101"
  15861. inputData["operatorId"] = "1"
  15862. inputData["operatorName"] = "huangchuang"
  15863. inputData["officeId"] = "101"
  15864. inputData["officeName"] = "xuetou"
  15865. inputData["deviceType"] = ""
  15866. data["data"] = inputData
  15867. data["transType"] = "ec.query"
  15868. data["orgId"] = miConfig.Code
  15869. bytesData, _ := json.Marshal(data)
  15870. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  15871. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  15872. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  15873. fmt.Println(ret2)
  15874. fmt.Println(string(str1))
  15875. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  15876. if ret2 != 0 {
  15877. return ""
  15878. }
  15879. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  15880. initEleFlag = 1
  15881. }
  15882. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  15883. }
  15884. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  15885. // // 构建命令
  15886. // cmd := exec.Command("python", "b.py")
  15887. //
  15888. // // 执行命令并等待完成
  15889. // output, err := cmd.CombinedOutput()
  15890. // if err != nil {
  15891. // fmt.Println("Error executing Python script:", err)
  15892. // return
  15893. // }
  15894. //
  15895. // // 打印Python脚本的输出
  15896. // fmt.Println(string(output))
  15897. //}
  15898. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  15899. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  15900. readCard := DllDef.MustFindProc("gxyb_call")
  15901. if readCard == nil {
  15902. fmt.Println("readcard is nil")
  15903. readCard = DllDef.MustFindProc("gxyb_call")
  15904. }
  15905. str := make([]byte, 1024)
  15906. str1 := make([]byte, 1024)
  15907. //data := make(map[string]interface{})
  15908. currentTime := time.Now()
  15909. // 格式化时间为 "YYYYMMDDHH24MISS"
  15910. formattedTime := currentTime.Format("20060102150405")
  15911. inputData := make(map[string]interface{})
  15912. inputData2 := make(map[string]interface{})
  15913. inputData["transNo"] = "1401"
  15914. inputData["transType"] = "passwordCheck"
  15915. inputData["timestamp"] = formattedTime
  15916. inputData2["fixmedinsCode"] = code
  15917. inputData2["psnNo"] = ""
  15918. inputData["data"] = inputData2
  15919. jsonBytes, err := json.Marshal(inputData)
  15920. if err != nil {
  15921. fmt.Println("Error encoding map to JSON:", err)
  15922. }
  15923. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  15924. fmt.Println(string(str1))
  15925. fmt.Println(string(str))
  15926. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  15927. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  15928. if ret2 != 0 {
  15929. return ""
  15930. }
  15931. return string(str)
  15932. }
  15933. func (c *HisApiController) GetoleInfo() Response {
  15934. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  15935. defer ole.CoUninitialize()
  15936. // Replace with the ProgID or CLSID of your COM object
  15937. progID := "YinHai.XJ.Actual.Interface.New"
  15938. // Create COM object
  15939. unknown, err := oleutil.CreateObject(progID)
  15940. if err != nil {
  15941. fmt.Println("Unable to create COM object:", err)
  15942. }
  15943. defer unknown.Release()
  15944. // Query for the IDispatch interface
  15945. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  15946. if err != nil {
  15947. fmt.Println("Unable to get IDispatch interface:", err)
  15948. }
  15949. defer dispatch.Release()
  15950. // Prepare parameters
  15951. transNo := "1401"
  15952. transType := "passwordCheck"
  15953. timestamp := time.Now().Unix()
  15954. fixmedinsCode := "H45072101171"
  15955. psnNo := ""
  15956. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  15957. result2 := ""
  15958. // Call COM object's method using the IDispatch interface
  15959. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  15960. fmt.Println(resulr)
  15961. fmt.Println(result2)
  15962. if err != nil {
  15963. fmt.Println("调用COM对象方法失败:", err)
  15964. }
  15965. var response Response
  15966. err2 := json.Unmarshal([]byte(result2), &response)
  15967. if err2 != nil {
  15968. fmt.Println("解析JSON失败:", err)
  15969. }
  15970. return response
  15971. }
  15972. func (c *HisApiController) GetBasBaseInfo() string {
  15973. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15974. readCard := DllDef.MustFindProc("ReadCardBas")
  15975. if readCard == nil {
  15976. fmt.Println("readcard is nil")
  15977. readCard = DllDef.MustFindProc("ReadCardBas")
  15978. }
  15979. str := make([]byte, 1024)
  15980. str1 := make([]byte, 1024)
  15981. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  15982. fmt.Println(string(str1))
  15983. fmt.Println(string(str))
  15984. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  15985. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  15986. if ret2 != 0 {
  15987. return ""
  15988. }
  15989. return string(str)
  15990. }
  15991. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  15992. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  15993. readCard := DllDef.MustFindProc("read_cardinfo")
  15994. if readCard == nil {
  15995. fmt.Println("readcard is nil")
  15996. readCard = DllDef.MustFindProc("read_cardinfo")
  15997. }
  15998. str := make([]byte, 1024) //卡号
  15999. str1 := make([]byte, 1024) //卡识别码
  16000. str2 := make([]byte, 1024) //身份证号
  16001. str3 := make([]byte, 1024) //姓名
  16002. str4 := make([]byte, 1024) //错误信息
  16003. 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])))
  16004. fmt.Println(string(str1))
  16005. fmt.Println(string(str))
  16006. fmt.Println(string(str2))
  16007. fmt.Println(string(str3))
  16008. fmt.Println(string(str4))
  16009. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  16010. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  16011. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  16012. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  16013. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  16014. if ret2 != 0 {
  16015. return "", "", "", "", ""
  16016. }
  16017. return string(str), string(str1), string(str2), string(str3), string(str4)
  16018. }
  16019. type CustomFundPay struct {
  16020. FundPayType string `json:"fund_pay_type"`
  16021. FundPayamt float64 `json:"fund_payamt"`
  16022. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16023. }
  16024. //func (c *HisApiController) GetBatchSettleList() {
  16025. // start_time_str := c.GetString("start_time")
  16026. // //end_time_str := c.GetString("end_time")
  16027. // admin_user_id, _ := c.GetInt64("admin_user_id")
  16028. //
  16029. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  16030. //
  16031. // for _, item := range orders {
  16032. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  16033. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  16034. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  16035. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  16036. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  16037. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  16038. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16039. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  16040. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  16041. //
  16042. // if order.ID == 0 {
  16043. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  16044. // return
  16045. // }
  16046. //
  16047. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  16048. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  16049. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  16050. // //fmt.Println(count)
  16051. // //var zero string
  16052. // //number := count + 1
  16053. // //if number >= 1000 {
  16054. // // zero = "0000" + strconv.FormatInt(number, 10)
  16055. // //} else if number >= 10000 {
  16056. // // zero = "000" + strconv.FormatInt(number, 10)
  16057. // //} else if number >= 100000 {
  16058. // // zero = "00" + strconv.FormatInt(number, 10)
  16059. // //} else if number >= 1000000 {
  16060. // // zero = "0" + strconv.FormatInt(number, 10)
  16061. // //} else {
  16062. // // zero = strconv.FormatInt(number, 10)
  16063. // //}
  16064. // //fmt.Println(zero)
  16065. //
  16066. // struct4101 := service.Struct4101{
  16067. // PsnNo: order.PsnNo,
  16068. // MdtrtId: order.MdtrtId,
  16069. // SetlId: order.SetlId,
  16070. // PsnName: order.PsnName,
  16071. // Gend: order.Gend,
  16072. // Brdy: his.Brdy,
  16073. // Age: his.Age,
  16074. // Naty: order.Naty,
  16075. // PatnCertType: "01",
  16076. // Certno: order.Certno,
  16077. // Prfs: "90",
  16078. // ConerName: roles[0].UserName,
  16079. // PatnRlts: "99",
  16080. // ConerAddr: miConfig.OrgName,
  16081. // ConerTel: admin.Mobile,
  16082. // HiType: order.Insutype,
  16083. // Insuplc: miConfig.InsuplcAdmdvs,
  16084. // MaindiagFlag: "1",
  16085. // BillCode: order.SetlId,
  16086. // BillNo: order.SetlId,
  16087. // BizSn: order.Number,
  16088. // PsnSelfPay: order.PsnPartAmt,
  16089. // PsnOwnPay: order.PsnPartAmt,
  16090. // AcctPay: order.AcctPay,
  16091. // PsnCashpay: order.PsnCashPay,
  16092. // HiPaymtd: "1",
  16093. // Hsorg: miConfig.InsuplcAdmdvs,
  16094. // HsorgOpter: miConfig.InsuplcAdmdvs,
  16095. // MedinsFillPsn: curRoles.UserName,
  16096. // MedinsFillDept: miConfig.OrgName,
  16097. // IptMedType: "2",
  16098. // }
  16099. // struct4101.SetlBegnDate = order.SetlTime
  16100. // struct4101.SetlEndDate = order.SetlTime
  16101. // time_arr := strings.Split(order.SetlTime, " ")
  16102. // struct4101.AdmTime = time_arr[0]
  16103. // struct4101.AdmEndTime = time_arr[0]
  16104. //
  16105. // var rf []CustomFundPay
  16106. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  16107. //
  16108. // var tempFunPays []service.CustomStruct
  16109. // for _, item := range rf {
  16110. // var tempFunPay service.CustomStruct
  16111. // tempFunPay.FundPayamt = item.FundPayamt
  16112. // tempFunPay.FundPayType = item.FundPayType
  16113. // tempFunPays = append(tempFunPays, tempFunPay)
  16114. // }
  16115. // struct4101.CustomStruct = tempFunPays
  16116. //
  16117. // var tempDiaginfos []service.DiaginfoStructTwo
  16118. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  16119. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  16120. //
  16121. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  16122. // var config []*models.HisXtDiagnoseConfig
  16123. // for _, item := range diagnosis_ids {
  16124. // id, _ := strconv.ParseInt(item, 10, 64)
  16125. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  16126. // config = append(config, &diagnosisConfig)
  16127. // }
  16128. //
  16129. // for index, item := range config {
  16130. // if index == 0 {
  16131. // var tempDiaginfo service.DiaginfoStructTwo
  16132. // tempDiaginfo.DiagCode = item.CountryCode
  16133. // tempDiaginfo.DiagName = item.CountryContentName
  16134. // tempDiaginfo.DiagType = "1"
  16135. // tempDiaginfo.MaindiagFlag = "1"
  16136. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  16137. // } else {
  16138. // var tempDiaginfo service.DiaginfoStructTwo
  16139. // tempDiaginfo.DiagCode = item.CountryCode
  16140. // tempDiaginfo.DiagName = item.CountryContentName
  16141. // tempDiaginfo.DiagType = "1"
  16142. // tempDiaginfo.MaindiagFlag = "0"
  16143. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  16144. // }
  16145. // }
  16146. // struct4101.Diseinfo = tempDiaginfos
  16147. //
  16148. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  16149. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  16150. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  16151. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  16152. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  16153. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  16154. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  16155. //
  16156. // var iteminfo service.IteminfoStruct
  16157. //
  16158. // var bedCostTotal float64 = 0 //床位总费
  16159. // var bedCostSelfTotal float64 = 0 //床位自费
  16160. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  16161. //
  16162. // var operationCostTotal float64 = 0 //手术费
  16163. // var operationCostSelfTotal float64 = 0 //手术费
  16164. // var operationCostPartSelfTotal float64 = 0 //手术费
  16165. //
  16166. // var otherCostTotal float64 = 0 //其他费用
  16167. // var otherCostSelfTotal float64 = 0 //其他费用
  16168. // var otherCostPartSelfTotal float64 = 0 //其他费用
  16169. //
  16170. // var materialCostTotal float64 = 0 //材料费
  16171. // var materialCostSelfTotal float64 = 0 //材料费
  16172. // var materialCostPartSelfTotal float64 = 0 //材料费
  16173. //
  16174. // var westernMedicineCostTotal float64 = 0 //西药费
  16175. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  16176. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  16177. //
  16178. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  16179. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  16180. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  16181. //
  16182. // var checkCostTotal float64 = 0 //检查费
  16183. // var checkCostSelfTotal float64 = 0 //检查费
  16184. // var checkCostPartSelfTotal float64 = 0 //检查费
  16185. //
  16186. // var laboratoryCostTotal float64 = 0 //化验费
  16187. // var laboratoryCostSelfTotal float64 = 0 //化验费
  16188. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  16189. //
  16190. // var treatCostTotal float64 = 0 //治疗费用
  16191. // var treatCostSelfTotal float64 = 0 //治疗费用
  16192. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  16193. //
  16194. // decimal.DivisionPrecision = 2
  16195. //
  16196. // var bed_fulamt_ownpay_amt float64 = 0
  16197. // var operation_fulamt_ownpay_amt float64 = 0
  16198. // var other_fulamt_ownpay_amt float64 = 0
  16199. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  16200. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  16201. // var check_fulamt_ownpay_amt float64 = 0
  16202. // var material_fulamt_ownpay_amt float64 = 0
  16203. // var laboratory_fulamt_ownpay_amt float64 = 0
  16204. // var treat_fulamt_ownpay_amt float64 = 0
  16205. //
  16206. // var bed_claa_sunmfee float64 = 0
  16207. // var bed_clab_amt float64 = 0
  16208. // var bed_other_amt float64 = 0
  16209. //
  16210. // var operation_claa_sunmfee float64 = 0
  16211. // var operation_clab_amt float64 = 0
  16212. // var operation_other_amt float64 = 0
  16213. //
  16214. // var other_claa_sunmfee float64 = 0
  16215. // var other_clab_amt float64 = 0
  16216. // var other_other_amt float64 = 0
  16217. //
  16218. // var westernMedicine_claa_sunmfee float64 = 0
  16219. // var westernMedicine_clab_amt float64 = 0
  16220. // var westernMedicine_other_amt float64 = 0
  16221. //
  16222. // var chineseTraditional_claa_sunmfee float64 = 0
  16223. // var chineseTraditional_clab_amt float64 = 0
  16224. // var chineseTraditional_other_amt float64 = 0
  16225. //
  16226. // var check_claa_sunmfee float64 = 0
  16227. // var check_clab_amt float64 = 0
  16228. // var check_other_amt float64 = 0
  16229. //
  16230. // var material_claa_sunmfee float64 = 0
  16231. // var material_clab_amt float64 = 0
  16232. // var material_other_amt float64 = 0
  16233. //
  16234. // var laboratory_claa_sunmfee float64 = 0
  16235. // var laboratory_clab_amt float64 = 0
  16236. // var laboratory_other_amt float64 = 0
  16237. //
  16238. // var treat_claa_sunmfee float64 = 0
  16239. // var treat_clab_amt float64 = 0
  16240. // var treat_other_amt float64 = 0
  16241. //
  16242. // for _, item := range order.HisOrderInfo {
  16243. // if item.MedChrgitmType == "01" { //床位费
  16244. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16245. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16246. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16247. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16248. // if item.ChrgitmLv == "1" {
  16249. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16250. // }
  16251. // if item.ChrgitmLv == "2" {
  16252. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16253. //
  16254. // }
  16255. // if item.ChrgitmLv == "3" {
  16256. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16257. // }
  16258. //
  16259. // }
  16260. //
  16261. // if item.MedChrgitmType == "03" { //检查费
  16262. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16263. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16264. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16265. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16266. // if item.ChrgitmLv == "1" {
  16267. //
  16268. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16269. //
  16270. // }
  16271. // if item.ChrgitmLv == "2" {
  16272. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16273. //
  16274. // }
  16275. // if item.ChrgitmLv == "3" {
  16276. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16277. // }
  16278. // }
  16279. //
  16280. // if item.MedChrgitmType == "04" { //化验费
  16281. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16282. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16283. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16284. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16285. // if item.ChrgitmLv == "1" {
  16286. //
  16287. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16288. //
  16289. // }
  16290. // if item.ChrgitmLv == "2" {
  16291. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16292. //
  16293. // }
  16294. // if item.ChrgitmLv == "3" {
  16295. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16296. // }
  16297. // }
  16298. //
  16299. // if item.MedChrgitmType == "05" { //治疗费
  16300. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16301. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16302. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16303. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16304. // if item.ChrgitmLv == "1" {
  16305. //
  16306. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16307. //
  16308. // }
  16309. // if item.ChrgitmLv == "2" {
  16310. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16311. //
  16312. // }
  16313. // if item.ChrgitmLv == "3" {
  16314. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16315. // }
  16316. // }
  16317. //
  16318. // if item.MedChrgitmType == "06" { //手术费
  16319. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16320. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16321. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16322. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16323. //
  16324. // if item.ChrgitmLv == "1" {
  16325. //
  16326. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16327. //
  16328. // }
  16329. // if item.ChrgitmLv == "2" {
  16330. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16331. //
  16332. // }
  16333. // if item.ChrgitmLv == "3" {
  16334. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16335. // }
  16336. // }
  16337. //
  16338. // if item.MedChrgitmType == "08" { //材料费
  16339. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16340. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16341. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16342. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16343. // if item.ChrgitmLv == "1" {
  16344. //
  16345. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16346. //
  16347. // }
  16348. // if item.ChrgitmLv == "2" {
  16349. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16350. //
  16351. // }
  16352. // if item.ChrgitmLv == "3" {
  16353. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16354. // }
  16355. // }
  16356. //
  16357. // if item.MedChrgitmType == "09" { //西药费
  16358. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16359. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16360. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16361. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16362. // if item.ChrgitmLv == "1" {
  16363. //
  16364. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16365. //
  16366. // }
  16367. // if item.ChrgitmLv == "2" {
  16368. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16369. //
  16370. // }
  16371. // if item.ChrgitmLv == "3" {
  16372. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16373. // }
  16374. // }
  16375. //
  16376. // if item.MedChrgitmType == "11" { //中成费
  16377. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16378. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16379. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16380. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16381. // if item.ChrgitmLv == "1" {
  16382. //
  16383. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16384. //
  16385. // }
  16386. // if item.ChrgitmLv == "2" {
  16387. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16388. //
  16389. // }
  16390. // if item.ChrgitmLv == "3" {
  16391. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16392. // }
  16393. // }
  16394. //
  16395. // if item.MedChrgitmType == "14" { //其他费
  16396. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16397. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16398. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16399. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16400. // if item.ChrgitmLv == "1" {
  16401. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16402. //
  16403. // }
  16404. // if item.ChrgitmLv == "2" {
  16405. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16406. //
  16407. // }
  16408. // if item.ChrgitmLv == "3" {
  16409. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16410. // }
  16411. // }
  16412. //
  16413. // }
  16414. //
  16415. // var iteminfoStructs []service.IteminfoStruct
  16416. //
  16417. // if bedCostTotal != 0 {
  16418. // iteminfo.MedChrgitm = "01"
  16419. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  16420. // iteminfo.Amt = bedCostTotal
  16421. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  16422. // iteminfo.ClabAmt = bed_clab_amt
  16423. // iteminfo.OthAmt = bed_other_amt
  16424. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16425. // }
  16426. //
  16427. // if checkCostTotal != 0 {
  16428. // iteminfo.MedChrgitm = "03"
  16429. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  16430. // iteminfo.Amt = checkCostTotal
  16431. // iteminfo.ClaaSumfee = check_claa_sunmfee
  16432. // iteminfo.ClabAmt = check_clab_amt
  16433. // iteminfo.OthAmt = check_other_amt
  16434. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16435. //
  16436. // }
  16437. //
  16438. // if laboratoryCostTotal != 0 {
  16439. // iteminfo.MedChrgitm = "04"
  16440. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  16441. // iteminfo.Amt = laboratoryCostTotal
  16442. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  16443. // iteminfo.ClabAmt = laboratory_clab_amt
  16444. // iteminfo.OthAmt = laboratory_other_amt
  16445. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16446. //
  16447. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16448. //
  16449. // }
  16450. //
  16451. // if treatCostTotal != 0 {
  16452. // iteminfo.MedChrgitm = "05"
  16453. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  16454. // iteminfo.Amt = treatCostTotal
  16455. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  16456. // iteminfo.ClabAmt = treat_clab_amt
  16457. // iteminfo.OthAmt = treat_other_amt
  16458. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16459. // //(struct4101.IteminfoStruct, iteminfo)
  16460. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16461. // }
  16462. //
  16463. // if operationCostTotal != 0 {
  16464. // iteminfo.MedChrgitm = "06"
  16465. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  16466. // iteminfo.Amt = operationCostTotal
  16467. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  16468. // iteminfo.ClabAmt = operation_clab_amt
  16469. // iteminfo.OthAmt = operation_other_amt
  16470. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16471. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16472. // }
  16473. //
  16474. // if materialCostTotal != 0 {
  16475. // iteminfo.MedChrgitm = "08"
  16476. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  16477. // iteminfo.Amt = materialCostTotal
  16478. // iteminfo.ClaaSumfee = material_claa_sunmfee
  16479. // iteminfo.ClabAmt = material_clab_amt
  16480. // iteminfo.OthAmt = material_other_amt
  16481. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16482. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16483. // }
  16484. //
  16485. // if westernMedicineCostTotal != 0 {
  16486. // iteminfo.MedChrgitm = "09"
  16487. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  16488. // iteminfo.Amt = westernMedicineCostTotal
  16489. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  16490. // iteminfo.ClabAmt = westernMedicine_clab_amt
  16491. // iteminfo.OthAmt = westernMedicine_other_amt
  16492. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16493. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16494. //
  16495. // }
  16496. // if chineseTraditionalMedicineCostTotal != 0 {
  16497. // iteminfo.MedChrgitm = "11"
  16498. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  16499. // iteminfo.Amt = westernMedicineCostTotal
  16500. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  16501. // iteminfo.ClabAmt = westernMedicine_clab_amt
  16502. // iteminfo.OthAmt = westernMedicine_other_amt
  16503. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16504. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16505. //
  16506. // }
  16507. // if otherCostTotal != 0 {
  16508. // iteminfo.MedChrgitm = "14"
  16509. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  16510. // iteminfo.Amt = otherCostTotal
  16511. // iteminfo.ClaaSumfee = other_claa_sunmfee
  16512. // iteminfo.ClabAmt = other_clab_amt
  16513. // iteminfo.OthAmt = other_other_amt
  16514. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16515. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16516. //
  16517. // }
  16518. // struct4101.IteminfoStruct = iteminfoStructs
  16519. // struct4101.Ntly = "中国"
  16520. // struct4101.AdmCaty = "A03.06"
  16521. //
  16522. // struct4101.DoctorName = doctor.UserName
  16523. // struct4101.DoctorCode = doctor.DoctorNumber
  16524. //
  16525. // var res ResultSeventeen
  16526. //
  16527. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16528. // struct4101.BillCode = order.Number
  16529. // struct4101.BillNo = order.SetlId
  16530. // var resOther ResultSeventeenOther
  16531. // var pp models.PublicParams
  16532. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16533. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16534. // pp.FixmedinsName = miConfig.OrgName
  16535. // pp.FixmedinsCode = miConfig.Code
  16536. // pp.RequestUrl = miConfig.Url
  16537. // pp.Cainfo = miConfig.Cainfo
  16538. // pp.SecretKey = miConfig.SecretKey
  16539. // pp.AccessKey = miConfig.AccessKey
  16540. // pp.OpterName = curRoles.UserName
  16541. //
  16542. // client := &http.Client{}
  16543. // var req *http.Request
  16544. // data := make(map[string]interface{})
  16545. // data["struct4101"] = struct4101
  16546. // data["pp"] = pp
  16547. // bytesData, _ := json.Marshal(data)
  16548. // if miConfig.MdtrtareaAdmvs == "320921" {
  16549. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  16550. // } else {
  16551. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  16552. // }
  16553. // resp, _ := client.Do(req)
  16554. // defer resp.Body.Close()
  16555. // body, ioErr := ioutil.ReadAll(resp.Body)
  16556. // if ioErr != nil {
  16557. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16558. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16559. // return
  16560. // }
  16561. // var respJSON map[string]interface{}
  16562. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16563. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16564. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16565. // return
  16566. // }
  16567. //
  16568. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16569. // userJSONBytes, _ := json.Marshal(respJSON)
  16570. // fmt.Println("log")
  16571. // fmt.Println(string(userJSONBytes))
  16572. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  16573. // utils.ErrorLog("解析失败:%v", err)
  16574. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16575. // return
  16576. // }
  16577. // res.InfRefmsgid = resOther.InfRefmsgid
  16578. // res.Output = resOther.Output
  16579. // res.ErrMsg = resOther.ErrMsg
  16580. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  16581. // res.Infcode = infocode
  16582. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  16583. //
  16584. // var pp models.PublicParams
  16585. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16586. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16587. // pp.FixmedinsName = miConfig.OrgName
  16588. // pp.FixmedinsCode = miConfig.Code
  16589. // pp.RequestUrl = miConfig.Url
  16590. // pp.Cainfo = miConfig.Cainfo
  16591. // pp.SecretKey = miConfig.SecretKey
  16592. // pp.AccessKey = miConfig.AccessKey
  16593. // pp.OpterName = curRoles.UserName
  16594. // result, _ := service.Jxyb4101(struct4101, pp)
  16595. // var dat map[string]interface{}
  16596. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16597. // fmt.Println(dat)
  16598. // } else {
  16599. // fmt.Println(err)
  16600. // }
  16601. // userJSONBytes, _ := json.Marshal(dat)
  16602. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16603. // utils.ErrorLog("解析失败:%v", err)
  16604. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16605. // return
  16606. // }
  16607. //
  16608. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  16609. // var pp models.PublicParams
  16610. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16611. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16612. // pp.FixmedinsName = miConfig.OrgName
  16613. // pp.FixmedinsCode = miConfig.Code
  16614. // pp.RequestUrl = miConfig.Url
  16615. // pp.Cainfo = miConfig.Cainfo
  16616. // pp.SecretKey = miConfig.SecretKey
  16617. // pp.AccessKey = miConfig.AccessKey
  16618. // pp.OpterName = curRoles.UserName
  16619. // result, _ := service.Hnyb4101(struct4101, pp)
  16620. // var dat map[string]interface{}
  16621. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16622. // fmt.Println(dat)
  16623. // } else {
  16624. // fmt.Println(err)
  16625. // }
  16626. // userJSONBytes, _ := json.Marshal(dat)
  16627. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16628. // utils.ErrorLog("解析失败:%v", err)
  16629. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16630. // return
  16631. // }
  16632. //
  16633. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  16634. // var resOther ResultSeventeenOther
  16635. //
  16636. // var pp models.PublicParams
  16637. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16638. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16639. // pp.FixmedinsName = miConfig.OrgName
  16640. // pp.FixmedinsCode = miConfig.Code
  16641. // pp.RequestUrl = miConfig.Url
  16642. // pp.Cainfo = miConfig.Cainfo
  16643. // pp.SecretKey = miConfig.SecretKey
  16644. // pp.AccessKey = miConfig.AccessKey
  16645. // pp.OpterName = curRoles.UserName
  16646. // client := &http.Client{}
  16647. // var req *http.Request
  16648. // data := make(map[string]interface{})
  16649. // data["struct4101"] = struct4101
  16650. // data["pp"] = pp
  16651. // bytesData, _ := json.Marshal(data)
  16652. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  16653. // resp, _ := client.Do(req)
  16654. // defer resp.Body.Close()
  16655. // body, ioErr := ioutil.ReadAll(resp.Body)
  16656. // if ioErr != nil {
  16657. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16658. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16659. // return
  16660. // }
  16661. // var respJSON map[string]interface{}
  16662. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16663. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16664. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16665. // return
  16666. // }
  16667. //
  16668. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16669. // userJSONBytes, _ := json.Marshal(respJSON)
  16670. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  16671. // utils.ErrorLog("解析失败:%v", err)
  16672. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16673. // return
  16674. // }
  16675. // res.InfRefmsgid = resOther.InfRefmsgid
  16676. // res.Output = resOther.Output
  16677. // res.ErrMsg = resOther.ErrMsg
  16678. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  16679. // res.Infcode = infocode
  16680. //
  16681. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  16682. // var pp models.PublicParams
  16683. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16684. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16685. // pp.FixmedinsName = miConfig.OrgName
  16686. // pp.FixmedinsCode = miConfig.Code
  16687. // pp.RequestUrl = miConfig.Url
  16688. // pp.Cainfo = miConfig.Cainfo
  16689. // pp.SecretKey = miConfig.SecretKey
  16690. // pp.AccessKey = miConfig.AccessKey
  16691. // pp.OpterName = curRoles.UserName
  16692. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  16693. // fmt.Println(requestLog)
  16694. // fmt.Println(errMsgLog)
  16695. //
  16696. // saveLog(result, requestLog, "4101a", "上传清单")
  16697. //
  16698. // var dat map[string]interface{}
  16699. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16700. // fmt.Println(dat)
  16701. // } else {
  16702. // fmt.Println(err)
  16703. // }
  16704. // userJSONBytes, _ := json.Marshal(dat)
  16705. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16706. // utils.ErrorLog("解析失败:%v", err)
  16707. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16708. // return
  16709. // }
  16710. //
  16711. // } else {
  16712. //
  16713. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  16714. // var dat map[string]interface{}
  16715. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16716. // fmt.Println(dat)
  16717. // } else {
  16718. // fmt.Println(err)
  16719. // }
  16720. // userJSONBytes, _ := json.Marshal(dat)
  16721. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16722. // utils.ErrorLog("解析失败:%v", err)
  16723. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16724. // return
  16725. // }
  16726. // }
  16727. //
  16728. // if res.Infcode != 0 {
  16729. // adminUser := c.GetAdminUserInfo()
  16730. // errlog := &models.HisOrderError{
  16731. // UserOrgId: adminUser.CurrentOrgId,
  16732. // Ctime: time.Now().Unix(),
  16733. // Mtime: time.Now().Unix(),
  16734. // ErrMsg: res.ErrMsg,
  16735. // Status: 1,
  16736. // PatientId: order.ID,
  16737. // Stage: 10265,
  16738. // }
  16739. // service.CreateErrMsgLog(errlog)
  16740. // continue
  16741. // } else {
  16742. // //order.FaPiaoNumber = zero
  16743. // //order.FaPiaoCode = last_order.FaPiaoCode
  16744. // //service.UpdateOrder(order)
  16745. // hisFundSettleListResult := &models.HisFundSettleListResult{
  16746. // Number: res.Output.SetlListId,
  16747. // Status: 1,
  16748. // Ctime: time.Now().Unix(),
  16749. // Mtime: time.Now().Unix(),
  16750. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16751. // IsUpload: 1,
  16752. // OrderId: order.ID,
  16753. // }
  16754. // service.CreateUploadRecord(hisFundSettleListResult)
  16755. // c.ServeSuccessJSON(map[string]interface{}{
  16756. // "msg": "上传成功",
  16757. // "result": hisFundSettleListResult,
  16758. // })
  16759. // continue
  16760. // }
  16761. // }
  16762. //}
  16763. func (c *HisApiController) GetbatchSettleList() {
  16764. //order_id, _ := c.GetInt64("order_id")
  16765. admin_user_id, _ := c.GetInt64("admin_user_id")
  16766. orders, _ := service.GetAllHisOrderTwo10485()
  16767. for _, item := range orders {
  16768. order, _ := service.GetHisOrderByIDTwo(item.ID)
  16769. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  16770. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  16771. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  16772. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  16773. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  16774. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16775. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  16776. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  16777. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  16778. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  16779. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  16780. //fmt.Println(count)
  16781. //var zero string
  16782. //number := count + 1
  16783. //if number >= 1000 {
  16784. // zero = "0000" + strconv.FormatInt(number, 10)
  16785. //} else if number >= 10000 {
  16786. // zero = "000" + strconv.FormatInt(number, 10)
  16787. //} else if number >= 100000 {
  16788. // zero = "00" + strconv.FormatInt(number, 10)
  16789. //} else if number >= 1000000 {
  16790. // zero = "0" + strconv.FormatInt(number, 10)
  16791. //} else {
  16792. // zero = strconv.FormatInt(number, 10)
  16793. //}
  16794. //fmt.Println(zero)
  16795. struct4101 := service.Struct4101{
  16796. PsnNo: order.PsnNo,
  16797. MdtrtId: order.MdtrtId,
  16798. SetlId: order.SetlId,
  16799. PsnName: order.PsnName,
  16800. Gend: order.Gend,
  16801. Brdy: his.Brdy,
  16802. Age: his.Age,
  16803. Naty: order.Naty,
  16804. PatnCertType: "01",
  16805. Certno: order.Certno,
  16806. Prfs: "90",
  16807. ConerName: roles[0].UserName,
  16808. PatnRlts: "99",
  16809. ConerAddr: miConfig.OrgName,
  16810. ConerTel: admin.Mobile,
  16811. HiType: order.Insutype,
  16812. Insuplc: miConfig.InsuplcAdmdvs,
  16813. MaindiagFlag: "1",
  16814. BillCode: order.SetlId,
  16815. BillNo: order.SetlId,
  16816. BizSn: order.Number,
  16817. PsnSelfPay: order.PsnPartAmt,
  16818. PsnOwnPay: order.PsnPartAmt,
  16819. AcctPay: order.AcctPay,
  16820. PsnCashpay: order.PsnCashPay,
  16821. HiPaymtd: "1",
  16822. Hsorg: miConfig.InsuplcAdmdvs,
  16823. HsorgOpter: miConfig.InsuplcAdmdvs,
  16824. MedinsFillPsn: curRoles.UserName,
  16825. MedinsFillDept: miConfig.OrgName,
  16826. IptMedType: "2",
  16827. }
  16828. struct4101.SetlBegnDate = order.SetlTime
  16829. struct4101.SetlEndDate = order.SetlTime
  16830. time_arr := strings.Split(order.SetlTime, " ")
  16831. struct4101.AdmTime = time_arr[0]
  16832. struct4101.AdmEndTime = time_arr[0]
  16833. //var rf []CustomFundPay
  16834. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  16835. //
  16836. //var tempFunPays []service.CustomStruct
  16837. //for _, item := range rf {
  16838. // var tempFunPay service.CustomStruct
  16839. // tempFunPay.FundPayamt = item.FundPayamt
  16840. // tempFunPay.FundPayType = item.FundPayType
  16841. // tempFunPays = append(tempFunPays, tempFunPay)
  16842. //}
  16843. //struct4101.CustomStruct = tempFunPays
  16844. var tempDiaginfos []service.DiaginfoStructTwo
  16845. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  16846. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  16847. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  16848. var config []*models.HisXtDiagnoseConfig
  16849. for _, item := range diagnosis_ids {
  16850. id, _ := strconv.ParseInt(item, 10, 64)
  16851. diagnosisConfig, _ := service.FindDiagnoseById(id)
  16852. config = append(config, &diagnosisConfig)
  16853. }
  16854. for index, item := range config {
  16855. if index == 0 {
  16856. var tempDiaginfo service.DiaginfoStructTwo
  16857. tempDiaginfo.DiagCode = item.CountryCode
  16858. tempDiaginfo.DiagName = item.CountryContentName
  16859. tempDiaginfo.DiagType = "1"
  16860. tempDiaginfo.MaindiagFlag = "1"
  16861. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  16862. } else {
  16863. var tempDiaginfo service.DiaginfoStructTwo
  16864. tempDiaginfo.DiagCode = item.CountryCode
  16865. tempDiaginfo.DiagName = item.CountryContentName
  16866. tempDiaginfo.DiagType = "1"
  16867. tempDiaginfo.MaindiagFlag = "0"
  16868. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  16869. }
  16870. }
  16871. struct4101.Diseinfo = tempDiaginfos
  16872. sickConfigTwo, _ := service.FindSickById(his.SickType)
  16873. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  16874. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  16875. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  16876. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  16877. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  16878. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  16879. var iteminfo service.IteminfoStruct
  16880. var bedCostTotal float64 = 0 //床位总费
  16881. var bedCostSelfTotal float64 = 0 //床位自费
  16882. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  16883. var operationCostTotal float64 = 0 //手术费
  16884. var operationCostSelfTotal float64 = 0 //手术费
  16885. var operationCostPartSelfTotal float64 = 0 //手术费
  16886. var otherCostTotal float64 = 0 //其他费用
  16887. var otherCostSelfTotal float64 = 0 //其他费用
  16888. var otherCostPartSelfTotal float64 = 0 //其他费用
  16889. var materialCostTotal float64 = 0 //材料费
  16890. var materialCostSelfTotal float64 = 0 //材料费
  16891. var materialCostPartSelfTotal float64 = 0 //材料费
  16892. var westernMedicineCostTotal float64 = 0 //西药费
  16893. var westernMedicineCostSelfTotal float64 = 0 //西药费
  16894. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  16895. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  16896. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  16897. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  16898. var checkCostTotal float64 = 0 //检查费
  16899. var checkCostSelfTotal float64 = 0 //检查费
  16900. var checkCostPartSelfTotal float64 = 0 //检查费
  16901. var laboratoryCostTotal float64 = 0 //化验费
  16902. var laboratoryCostSelfTotal float64 = 0 //化验费
  16903. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  16904. var treatCostTotal float64 = 0 //治疗费用
  16905. var treatCostSelfTotal float64 = 0 //治疗费用
  16906. var treatCostPartSelfTotal float64 = 0 //治疗费用
  16907. decimal.DivisionPrecision = 2
  16908. var bed_fulamt_ownpay_amt float64 = 0
  16909. var operation_fulamt_ownpay_amt float64 = 0
  16910. var other_fulamt_ownpay_amt float64 = 0
  16911. var westernMedicine_fulamt_ownpay_amt float64 = 0
  16912. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  16913. var check_fulamt_ownpay_amt float64 = 0
  16914. var material_fulamt_ownpay_amt float64 = 0
  16915. var laboratory_fulamt_ownpay_amt float64 = 0
  16916. var treat_fulamt_ownpay_amt float64 = 0
  16917. var bed_claa_sunmfee float64 = 0
  16918. var bed_clab_amt float64 = 0
  16919. var bed_other_amt float64 = 0
  16920. var operation_claa_sunmfee float64 = 0
  16921. var operation_clab_amt float64 = 0
  16922. var operation_other_amt float64 = 0
  16923. var other_claa_sunmfee float64 = 0
  16924. var other_clab_amt float64 = 0
  16925. var other_other_amt float64 = 0
  16926. var westernMedicine_claa_sunmfee float64 = 0
  16927. var westernMedicine_clab_amt float64 = 0
  16928. var westernMedicine_other_amt float64 = 0
  16929. var chineseTraditional_claa_sunmfee float64 = 0
  16930. var chineseTraditional_clab_amt float64 = 0
  16931. var chineseTraditional_other_amt float64 = 0
  16932. var check_claa_sunmfee float64 = 0
  16933. var check_clab_amt float64 = 0
  16934. var check_other_amt float64 = 0
  16935. var material_claa_sunmfee float64 = 0
  16936. var material_clab_amt float64 = 0
  16937. var material_other_amt float64 = 0
  16938. var laboratory_claa_sunmfee float64 = 0
  16939. var laboratory_clab_amt float64 = 0
  16940. var laboratory_other_amt float64 = 0
  16941. var treat_claa_sunmfee float64 = 0
  16942. var treat_clab_amt float64 = 0
  16943. var treat_other_amt float64 = 0
  16944. for _, item := range order.HisOrderInfo {
  16945. if item.MedChrgitmType == "01" { //床位费
  16946. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16947. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16948. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16949. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16950. if item.ChrgitmLv == "1" {
  16951. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16952. }
  16953. if item.ChrgitmLv == "2" {
  16954. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16955. }
  16956. if item.ChrgitmLv == "3" {
  16957. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16958. }
  16959. }
  16960. if item.MedChrgitmType == "03" { //检查费
  16961. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16962. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16963. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16964. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16965. if item.ChrgitmLv == "1" {
  16966. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16967. }
  16968. if item.ChrgitmLv == "2" {
  16969. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16970. }
  16971. if item.ChrgitmLv == "3" {
  16972. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16973. }
  16974. }
  16975. if item.MedChrgitmType == "04" { //化验费
  16976. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16977. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16978. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16979. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16980. if item.ChrgitmLv == "1" {
  16981. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16982. }
  16983. if item.ChrgitmLv == "2" {
  16984. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16985. }
  16986. if item.ChrgitmLv == "3" {
  16987. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16988. }
  16989. }
  16990. if item.MedChrgitmType == "05" { //治疗费
  16991. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16992. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16993. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16994. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16995. if item.ChrgitmLv == "1" {
  16996. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16997. }
  16998. if item.ChrgitmLv == "2" {
  16999. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17000. }
  17001. if item.ChrgitmLv == "3" {
  17002. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17003. }
  17004. }
  17005. if item.MedChrgitmType == "06" { //手术费
  17006. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17007. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17008. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17009. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17010. if item.ChrgitmLv == "1" {
  17011. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17012. }
  17013. if item.ChrgitmLv == "2" {
  17014. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17015. }
  17016. if item.ChrgitmLv == "3" {
  17017. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17018. }
  17019. }
  17020. if item.MedChrgitmType == "08" { //材料费
  17021. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17022. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17023. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17024. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17025. if item.ChrgitmLv == "1" {
  17026. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17027. }
  17028. if item.ChrgitmLv == "2" {
  17029. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17030. }
  17031. if item.ChrgitmLv == "3" {
  17032. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17033. }
  17034. }
  17035. if item.MedChrgitmType == "09" { //西药费
  17036. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17037. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17038. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17039. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17040. if item.ChrgitmLv == "1" {
  17041. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17042. }
  17043. if item.ChrgitmLv == "2" {
  17044. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17045. }
  17046. if item.ChrgitmLv == "3" {
  17047. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17048. }
  17049. }
  17050. if item.MedChrgitmType == "11" { //中成费
  17051. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17052. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17053. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17054. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17055. if item.ChrgitmLv == "1" {
  17056. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17057. }
  17058. if item.ChrgitmLv == "2" {
  17059. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17060. }
  17061. if item.ChrgitmLv == "3" {
  17062. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17063. }
  17064. }
  17065. if item.MedChrgitmType == "14" { //其他费
  17066. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17067. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17068. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17069. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17070. if item.ChrgitmLv == "1" {
  17071. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17072. }
  17073. if item.ChrgitmLv == "2" {
  17074. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17075. }
  17076. if item.ChrgitmLv == "3" {
  17077. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17078. }
  17079. }
  17080. }
  17081. var iteminfoStructs []service.IteminfoStruct
  17082. if bedCostTotal != 0 {
  17083. iteminfo.MedChrgitm = "01"
  17084. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17085. iteminfo.Amt = bedCostTotal
  17086. iteminfo.ClaaSumfee = bed_claa_sunmfee
  17087. iteminfo.ClabAmt = bed_clab_amt
  17088. iteminfo.OthAmt = bed_other_amt
  17089. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17090. }
  17091. if checkCostTotal != 0 {
  17092. iteminfo.MedChrgitm = "03"
  17093. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  17094. iteminfo.Amt = checkCostTotal
  17095. iteminfo.ClaaSumfee = check_claa_sunmfee
  17096. iteminfo.ClabAmt = check_clab_amt
  17097. iteminfo.OthAmt = check_other_amt
  17098. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17099. }
  17100. if laboratoryCostTotal != 0 {
  17101. iteminfo.MedChrgitm = "04"
  17102. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  17103. iteminfo.Amt = laboratoryCostTotal
  17104. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  17105. iteminfo.ClabAmt = laboratory_clab_amt
  17106. iteminfo.OthAmt = laboratory_other_amt
  17107. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17108. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17109. }
  17110. if treatCostTotal != 0 {
  17111. iteminfo.MedChrgitm = "05"
  17112. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  17113. iteminfo.Amt = treatCostTotal
  17114. iteminfo.ClaaSumfee = treat_claa_sunmfee
  17115. iteminfo.ClabAmt = treat_clab_amt
  17116. iteminfo.OthAmt = treat_other_amt
  17117. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17118. //(struct4101.IteminfoStruct, iteminfo)
  17119. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17120. }
  17121. if operationCostTotal != 0 {
  17122. iteminfo.MedChrgitm = "06"
  17123. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17124. iteminfo.Amt = operationCostTotal
  17125. iteminfo.ClaaSumfee = operation_claa_sunmfee
  17126. iteminfo.ClabAmt = operation_clab_amt
  17127. iteminfo.OthAmt = operation_other_amt
  17128. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17129. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17130. }
  17131. if materialCostTotal != 0 {
  17132. iteminfo.MedChrgitm = "08"
  17133. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  17134. iteminfo.Amt = materialCostTotal
  17135. iteminfo.ClaaSumfee = material_claa_sunmfee
  17136. iteminfo.ClabAmt = material_clab_amt
  17137. iteminfo.OthAmt = material_other_amt
  17138. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17139. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17140. }
  17141. if westernMedicineCostTotal != 0 {
  17142. iteminfo.MedChrgitm = "09"
  17143. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  17144. iteminfo.Amt = westernMedicineCostTotal
  17145. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  17146. iteminfo.ClabAmt = westernMedicine_clab_amt
  17147. iteminfo.OthAmt = westernMedicine_other_amt
  17148. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17149. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17150. }
  17151. if chineseTraditionalMedicineCostTotal != 0 {
  17152. iteminfo.MedChrgitm = "11"
  17153. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  17154. iteminfo.Amt = westernMedicineCostTotal
  17155. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  17156. iteminfo.ClabAmt = westernMedicine_clab_amt
  17157. iteminfo.OthAmt = westernMedicine_other_amt
  17158. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17159. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17160. }
  17161. if otherCostTotal != 0 {
  17162. iteminfo.MedChrgitm = "14"
  17163. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  17164. iteminfo.Amt = otherCostTotal
  17165. iteminfo.ClaaSumfee = other_claa_sunmfee
  17166. iteminfo.ClabAmt = other_clab_amt
  17167. iteminfo.OthAmt = other_other_amt
  17168. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17169. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17170. }
  17171. struct4101.IteminfoStruct = iteminfoStructs
  17172. struct4101.Ntly = "中国"
  17173. struct4101.AdmCaty = "A03.06"
  17174. struct4101.DoctorName = doctor.UserName
  17175. struct4101.DoctorCode = doctor.DoctorNumber
  17176. var res ResultSeventeen
  17177. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17178. struct4101.BillCode = order.Number
  17179. struct4101.BillNo = order.SetlId
  17180. var resOther ResultSeventeenOther
  17181. var pp models.PublicParams
  17182. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17183. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17184. pp.FixmedinsName = miConfig.OrgName
  17185. pp.FixmedinsCode = miConfig.Code
  17186. pp.RequestUrl = miConfig.Url
  17187. pp.Cainfo = miConfig.Cainfo
  17188. pp.SecretKey = miConfig.SecretKey
  17189. pp.AccessKey = miConfig.AccessKey
  17190. pp.OpterName = curRoles.UserName
  17191. client := &http.Client{}
  17192. var req *http.Request
  17193. data := make(map[string]interface{})
  17194. data["struct4101"] = struct4101
  17195. data["pp"] = pp
  17196. bytesData, _ := json.Marshal(data)
  17197. if miConfig.MdtrtareaAdmvs == "320921" {
  17198. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  17199. } else {
  17200. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  17201. }
  17202. resp, _ := client.Do(req)
  17203. defer resp.Body.Close()
  17204. body, ioErr := ioutil.ReadAll(resp.Body)
  17205. if ioErr != nil {
  17206. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17208. return
  17209. }
  17210. var respJSON map[string]interface{}
  17211. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17212. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17214. return
  17215. }
  17216. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17217. userJSONBytes, _ := json.Marshal(respJSON)
  17218. fmt.Println("log")
  17219. fmt.Println(string(userJSONBytes))
  17220. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  17221. utils.ErrorLog("解析失败:%v", err)
  17222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17223. return
  17224. }
  17225. res.InfRefmsgid = resOther.InfRefmsgid
  17226. res.Output = resOther.Output
  17227. res.ErrMsg = resOther.ErrMsg
  17228. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  17229. res.Infcode = infocode
  17230. } else if miConfig.MdtrtareaAdmvs == "360302" {
  17231. var pp models.PublicParams
  17232. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  17233. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17234. pp.FixmedinsName = miConfig.OrgName
  17235. pp.FixmedinsCode = miConfig.Code
  17236. pp.RequestUrl = miConfig.Url
  17237. pp.Cainfo = miConfig.Cainfo
  17238. pp.SecretKey = miConfig.SecretKey
  17239. pp.AccessKey = miConfig.AccessKey
  17240. pp.OpterName = curRoles.UserName
  17241. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  17242. result, _ := service.Jxyb4101(struct4101, pp)
  17243. var dat map[string]interface{}
  17244. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17245. fmt.Println(dat)
  17246. } else {
  17247. fmt.Println(err)
  17248. }
  17249. userJSONBytes, _ := json.Marshal(dat)
  17250. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17251. utils.ErrorLog("解析失败:%v", err)
  17252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17253. return
  17254. }
  17255. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17256. var pp models.PublicParams
  17257. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17258. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17259. pp.FixmedinsName = miConfig.OrgName
  17260. pp.FixmedinsCode = miConfig.Code
  17261. pp.RequestUrl = miConfig.Url
  17262. pp.Cainfo = miConfig.Cainfo
  17263. pp.SecretKey = miConfig.SecretKey
  17264. pp.AccessKey = miConfig.AccessKey
  17265. pp.OpterName = curRoles.UserName
  17266. result, _ := service.Hnyb4101(struct4101, pp)
  17267. var dat map[string]interface{}
  17268. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17269. fmt.Println(dat)
  17270. } else {
  17271. fmt.Println(err)
  17272. }
  17273. userJSONBytes, _ := json.Marshal(dat)
  17274. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17275. utils.ErrorLog("解析失败:%v", err)
  17276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17277. return
  17278. }
  17279. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17280. var resOther ResultSeventeenOther
  17281. var pp models.PublicParams
  17282. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17283. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17284. pp.FixmedinsName = miConfig.OrgName
  17285. pp.FixmedinsCode = miConfig.Code
  17286. pp.RequestUrl = miConfig.Url
  17287. pp.Cainfo = miConfig.Cainfo
  17288. pp.SecretKey = miConfig.SecretKey
  17289. pp.AccessKey = miConfig.AccessKey
  17290. pp.OpterName = curRoles.UserName
  17291. client := &http.Client{}
  17292. var req *http.Request
  17293. data := make(map[string]interface{})
  17294. data["struct4101"] = struct4101
  17295. data["pp"] = pp
  17296. bytesData, _ := json.Marshal(data)
  17297. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  17298. resp, _ := client.Do(req)
  17299. defer resp.Body.Close()
  17300. body, ioErr := ioutil.ReadAll(resp.Body)
  17301. if ioErr != nil {
  17302. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17304. return
  17305. }
  17306. var respJSON map[string]interface{}
  17307. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17308. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17310. return
  17311. }
  17312. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17313. userJSONBytes, _ := json.Marshal(respJSON)
  17314. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  17315. utils.ErrorLog("解析失败:%v", err)
  17316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17317. return
  17318. }
  17319. res.InfRefmsgid = resOther.InfRefmsgid
  17320. res.Output = resOther.Output
  17321. res.ErrMsg = resOther.ErrMsg
  17322. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  17323. res.Infcode = infocode
  17324. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17325. var pp models.PublicParams
  17326. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17327. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17328. pp.FixmedinsName = miConfig.OrgName
  17329. pp.FixmedinsCode = miConfig.Code
  17330. pp.RequestUrl = miConfig.Url
  17331. pp.Cainfo = miConfig.Cainfo
  17332. pp.SecretKey = miConfig.SecretKey
  17333. pp.AccessKey = miConfig.AccessKey
  17334. pp.OpterName = curRoles.UserName
  17335. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  17336. fmt.Println(requestLog)
  17337. fmt.Println(errMsgLog)
  17338. saveLog(result, requestLog, "4101a", "上传清单")
  17339. var dat map[string]interface{}
  17340. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17341. fmt.Println(dat)
  17342. } else {
  17343. fmt.Println(err)
  17344. }
  17345. userJSONBytes, _ := json.Marshal(dat)
  17346. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17347. utils.ErrorLog("解析失败:%v", err)
  17348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17349. return
  17350. }
  17351. } else if miConfig.MdtrtareaAdmvs == "441799" {
  17352. var pp models.PublicParams
  17353. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17354. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17355. pp.FixmedinsName = miConfig.OrgName
  17356. pp.FixmedinsCode = miConfig.Code
  17357. pp.RequestUrl = miConfig.Url
  17358. pp.Cainfo = miConfig.Cainfo
  17359. pp.SecretKey = miConfig.SecretKey
  17360. pp.AccessKey = miConfig.AccessKey
  17361. pp.OpterName = curRoles.UserName
  17362. client := &http.Client{}
  17363. var req *http.Request
  17364. data := make(map[string]interface{})
  17365. data["struct4101"] = struct4101
  17366. data["pp"] = pp
  17367. bytesData, _ := json.Marshal(data)
  17368. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  17369. resp, _ := client.Do(req)
  17370. defer resp.Body.Close()
  17371. body, ioErr := ioutil.ReadAll(resp.Body)
  17372. if ioErr != nil {
  17373. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17375. return
  17376. }
  17377. var respJSON map[string]interface{}
  17378. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17379. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17381. return
  17382. }
  17383. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17384. userJSONBytes, _ := json.Marshal(respJSON)
  17385. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17386. utils.ErrorLog("解析失败:%v", err)
  17387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17388. return
  17389. }
  17390. } else {
  17391. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  17392. var dat map[string]interface{}
  17393. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17394. fmt.Println(dat)
  17395. } else {
  17396. fmt.Println(err)
  17397. }
  17398. userJSONBytes, _ := json.Marshal(dat)
  17399. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17400. utils.ErrorLog("解析失败:%v", err)
  17401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17402. return
  17403. }
  17404. }
  17405. if res.Infcode != 0 {
  17406. errlog := &models.HisOrderError{
  17407. UserOrgId: order.UserOrgId,
  17408. Ctime: time.Now().Unix(),
  17409. Mtime: time.Now().Unix(),
  17410. ErrMsg: res.ErrMsg + "解析失败",
  17411. Status: 1,
  17412. PatientId: order.ID,
  17413. Stage: 10485,
  17414. }
  17415. service.CreateErrMsgLog(errlog)
  17416. continue
  17417. //c.ServeSuccessJSON(map[string]interface{}{
  17418. // "failed_code": -10,
  17419. // "msg": res.ErrMsg,
  17420. //})
  17421. } else {
  17422. //order.FaPiaoNumber = zero
  17423. //order.FaPiaoCode = last_order.FaPiaoCode
  17424. //service.UpdateOrder(order)
  17425. hisFundSettleListResult := &models.HisFundSettleListResult{
  17426. Number: res.Output.SetlListId,
  17427. Status: 1,
  17428. Ctime: time.Now().Unix(),
  17429. Mtime: time.Now().Unix(),
  17430. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17431. IsUpload: 1,
  17432. OrderId: order.ID,
  17433. }
  17434. service.CreateUploadRecord(hisFundSettleListResult)
  17435. continue
  17436. }
  17437. }
  17438. }
  17439. func (c *HisApiController) GetSettleList() {
  17440. order_id, _ := c.GetInt64("order_id")
  17441. admin_user_id, _ := c.GetInt64("admin_user_id")
  17442. order, _ := service.GetHisOrderByIDTwo(order_id)
  17443. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17444. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17445. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17446. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17447. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17448. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17449. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  17450. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  17451. if order.ID == 0 {
  17452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  17453. return
  17454. }
  17455. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17456. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17457. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  17458. //fmt.Println(count)
  17459. //var zero string
  17460. //number := count + 1
  17461. //if number >= 1000 {
  17462. // zero = "0000" + strconv.FormatInt(number, 10)
  17463. //} else if number >= 10000 {
  17464. // zero = "000" + strconv.FormatInt(number, 10)
  17465. //} else if number >= 100000 {
  17466. // zero = "00" + strconv.FormatInt(number, 10)
  17467. //} else if number >= 1000000 {
  17468. // zero = "0" + strconv.FormatInt(number, 10)
  17469. //} else {
  17470. // zero = strconv.FormatInt(number, 10)
  17471. //}
  17472. //fmt.Println(zero)
  17473. struct4101 := service.Struct4101{
  17474. PsnNo: order.PsnNo,
  17475. MdtrtId: order.MdtrtId,
  17476. SetlId: order.SetlId,
  17477. PsnName: order.PsnName,
  17478. Gend: order.Gend,
  17479. Brdy: his.Brdy,
  17480. Age: his.Age,
  17481. Naty: order.Naty,
  17482. PatnCertType: "01",
  17483. Certno: order.Certno,
  17484. Prfs: "90",
  17485. ConerName: roles[0].UserName,
  17486. PatnRlts: "99",
  17487. ConerAddr: miConfig.OrgName,
  17488. ConerTel: admin.Mobile,
  17489. HiType: order.Insutype,
  17490. Insuplc: miConfig.InsuplcAdmdvs,
  17491. MaindiagFlag: "1",
  17492. BillCode: order.SetlId,
  17493. BillNo: order.SetlId,
  17494. BizSn: order.Number,
  17495. PsnSelfPay: order.PsnPartAmt,
  17496. PsnOwnPay: order.PsnPartAmt,
  17497. AcctPay: order.AcctPay,
  17498. PsnCashpay: order.PsnCashPay,
  17499. HiPaymtd: "1",
  17500. Hsorg: miConfig.InsuplcAdmdvs,
  17501. HsorgOpter: miConfig.InsuplcAdmdvs,
  17502. MedinsFillPsn: curRoles.UserName,
  17503. MedinsFillDept: miConfig.OrgName,
  17504. IptMedType: "2",
  17505. }
  17506. struct4101.SetlBegnDate = order.SetlTime
  17507. struct4101.SetlEndDate = order.SetlTime
  17508. time_arr := strings.Split(order.SetlTime, " ")
  17509. struct4101.AdmTime = time_arr[0]
  17510. struct4101.AdmEndTime = time_arr[0]
  17511. //
  17512. //var rf []CustomFundPay
  17513. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  17514. //
  17515. //var tempFunPays []service.CustomStruct
  17516. //for _, item := range rf {
  17517. // var tempFunPay service.CustomStruct
  17518. // tempFunPay.FundPayamt = item.FundPayamt
  17519. // tempFunPay.FundPayType = item.FundPayType
  17520. // tempFunPays = append(tempFunPays, tempFunPay)
  17521. //}
  17522. //struct4101.CustomStruct = tempFunPays
  17523. var tempDiaginfos []service.DiaginfoStructTwo
  17524. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  17525. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  17526. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  17527. var config []*models.HisXtDiagnoseConfig
  17528. for _, item := range diagnosis_ids {
  17529. id, _ := strconv.ParseInt(item, 10, 64)
  17530. diagnosisConfig, _ := service.FindDiagnoseById(id)
  17531. config = append(config, &diagnosisConfig)
  17532. }
  17533. if miConfig.Code == "H15049901371" {
  17534. //for _, item := range config {
  17535. // if item.ID == 138 {
  17536. diagnosisConfig, _ := service.FindDiagnoseById(138)
  17537. var tempDiaginfo service.DiaginfoStructTwo
  17538. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  17539. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  17540. tempDiaginfo.DiagType = "1"
  17541. tempDiaginfo.MaindiagFlag = "1"
  17542. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17543. //}
  17544. //}
  17545. for _, item := range config {
  17546. if item.ID != 138 {
  17547. var tempDiaginfo service.DiaginfoStructTwo
  17548. tempDiaginfo.DiagCode = item.CountryCode
  17549. tempDiaginfo.DiagName = item.CountryContentName
  17550. tempDiaginfo.DiagType = "1"
  17551. tempDiaginfo.MaindiagFlag = "0"
  17552. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17553. }
  17554. }
  17555. } else {
  17556. for index, item := range config {
  17557. if index == 0 {
  17558. var tempDiaginfo service.DiaginfoStructTwo
  17559. tempDiaginfo.DiagCode = item.CountryCode
  17560. tempDiaginfo.DiagName = item.CountryContentName
  17561. tempDiaginfo.DiagType = "1"
  17562. tempDiaginfo.MaindiagFlag = "1"
  17563. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17564. } else {
  17565. var tempDiaginfo service.DiaginfoStructTwo
  17566. tempDiaginfo.DiagCode = item.CountryCode
  17567. tempDiaginfo.DiagName = item.CountryContentName
  17568. tempDiaginfo.DiagType = "1"
  17569. tempDiaginfo.MaindiagFlag = "0"
  17570. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17571. }
  17572. }
  17573. }
  17574. struct4101.Diseinfo = tempDiaginfos
  17575. sickConfigTwo, _ := service.FindSickById(his.SickType)
  17576. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  17577. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  17578. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  17579. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  17580. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  17581. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  17582. var iteminfo service.IteminfoStruct
  17583. var bedCostTotal float64 = 0 //床位总费
  17584. var bedCostSelfTotal float64 = 0 //床位自费
  17585. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  17586. var operationCostTotal float64 = 0 //手术费
  17587. var operationCostSelfTotal float64 = 0 //手术费
  17588. var operationCostPartSelfTotal float64 = 0 //手术费
  17589. var otherCostTotal float64 = 0 //其他费用
  17590. var otherCostSelfTotal float64 = 0 //其他费用
  17591. var otherCostPartSelfTotal float64 = 0 //其他费用
  17592. var materialCostTotal float64 = 0 //材料费
  17593. var materialCostSelfTotal float64 = 0 //材料费
  17594. var materialCostPartSelfTotal float64 = 0 //材料费
  17595. var westernMedicineCostTotal float64 = 0 //西药费
  17596. var westernMedicineCostSelfTotal float64 = 0 //西药费
  17597. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  17598. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  17599. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  17600. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  17601. var checkCostTotal float64 = 0 //检查费
  17602. var checkCostSelfTotal float64 = 0 //检查费
  17603. var checkCostPartSelfTotal float64 = 0 //检查费
  17604. var laboratoryCostTotal float64 = 0 //化验费
  17605. var laboratoryCostSelfTotal float64 = 0 //化验费
  17606. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  17607. var treatCostTotal float64 = 0 //治疗费用
  17608. var treatCostSelfTotal float64 = 0 //治疗费用
  17609. var treatCostPartSelfTotal float64 = 0 //治疗费用
  17610. decimal.DivisionPrecision = 2
  17611. var bed_fulamt_ownpay_amt float64 = 0
  17612. var operation_fulamt_ownpay_amt float64 = 0
  17613. var other_fulamt_ownpay_amt float64 = 0
  17614. var westernMedicine_fulamt_ownpay_amt float64 = 0
  17615. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  17616. var check_fulamt_ownpay_amt float64 = 0
  17617. var material_fulamt_ownpay_amt float64 = 0
  17618. var laboratory_fulamt_ownpay_amt float64 = 0
  17619. var treat_fulamt_ownpay_amt float64 = 0
  17620. var bed_claa_sunmfee float64 = 0
  17621. var bed_clab_amt float64 = 0
  17622. var bed_other_amt float64 = 0
  17623. var operation_claa_sunmfee float64 = 0
  17624. var operation_clab_amt float64 = 0
  17625. var operation_other_amt float64 = 0
  17626. var other_claa_sunmfee float64 = 0
  17627. var other_clab_amt float64 = 0
  17628. var other_other_amt float64 = 0
  17629. var westernMedicine_claa_sunmfee float64 = 0
  17630. var westernMedicine_clab_amt float64 = 0
  17631. var westernMedicine_other_amt float64 = 0
  17632. var chineseTraditional_claa_sunmfee float64 = 0
  17633. var chineseTraditional_clab_amt float64 = 0
  17634. var chineseTraditional_other_amt float64 = 0
  17635. var check_claa_sunmfee float64 = 0
  17636. var check_clab_amt float64 = 0
  17637. var check_other_amt float64 = 0
  17638. var material_claa_sunmfee float64 = 0
  17639. var material_clab_amt float64 = 0
  17640. var material_other_amt float64 = 0
  17641. var laboratory_claa_sunmfee float64 = 0
  17642. var laboratory_clab_amt float64 = 0
  17643. var laboratory_other_amt float64 = 0
  17644. var treat_claa_sunmfee float64 = 0
  17645. var treat_clab_amt float64 = 0
  17646. var treat_other_amt float64 = 0
  17647. for _, item := range order.HisOrderInfo {
  17648. if item.MedChrgitmType == "01" { //床位费
  17649. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17650. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17651. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17652. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17653. if item.ChrgitmLv == "1" {
  17654. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17655. }
  17656. if item.ChrgitmLv == "2" {
  17657. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17658. }
  17659. if item.ChrgitmLv == "3" {
  17660. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17661. }
  17662. }
  17663. if item.MedChrgitmType == "03" { //检查费
  17664. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17665. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17666. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17667. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17668. if item.ChrgitmLv == "1" {
  17669. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17670. }
  17671. if item.ChrgitmLv == "2" {
  17672. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17673. }
  17674. if item.ChrgitmLv == "3" {
  17675. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17676. }
  17677. }
  17678. if item.MedChrgitmType == "04" { //化验费
  17679. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17680. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17681. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17682. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17683. if item.ChrgitmLv == "1" {
  17684. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17685. }
  17686. if item.ChrgitmLv == "2" {
  17687. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17688. }
  17689. if item.ChrgitmLv == "3" {
  17690. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17691. }
  17692. }
  17693. if item.MedChrgitmType == "05" { //治疗费
  17694. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17695. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17696. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17697. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17698. if item.ChrgitmLv == "1" {
  17699. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17700. }
  17701. if item.ChrgitmLv == "2" {
  17702. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17703. }
  17704. if item.ChrgitmLv == "3" {
  17705. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17706. }
  17707. }
  17708. if item.MedChrgitmType == "06" { //手术费
  17709. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17710. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17711. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17712. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17713. if item.ChrgitmLv == "1" {
  17714. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17715. }
  17716. if item.ChrgitmLv == "2" {
  17717. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17718. }
  17719. if item.ChrgitmLv == "3" {
  17720. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17721. }
  17722. }
  17723. if item.MedChrgitmType == "08" { //材料费
  17724. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17725. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17726. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17727. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17728. if item.ChrgitmLv == "1" {
  17729. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17730. }
  17731. if item.ChrgitmLv == "2" {
  17732. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17733. }
  17734. if item.ChrgitmLv == "3" {
  17735. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17736. }
  17737. }
  17738. if item.MedChrgitmType == "09" { //西药费
  17739. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17740. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17741. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17742. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17743. if item.ChrgitmLv == "1" {
  17744. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17745. }
  17746. if item.ChrgitmLv == "2" {
  17747. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17748. }
  17749. if item.ChrgitmLv == "3" {
  17750. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17751. }
  17752. }
  17753. if item.MedChrgitmType == "11" { //中成费
  17754. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17755. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17756. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17757. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17758. if item.ChrgitmLv == "1" {
  17759. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17760. }
  17761. if item.ChrgitmLv == "2" {
  17762. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17763. }
  17764. if item.ChrgitmLv == "3" {
  17765. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17766. }
  17767. }
  17768. if item.MedChrgitmType == "14" { //其他费
  17769. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17770. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17771. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17772. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17773. if item.ChrgitmLv == "1" {
  17774. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17775. }
  17776. if item.ChrgitmLv == "2" {
  17777. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17778. }
  17779. if item.ChrgitmLv == "3" {
  17780. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17781. }
  17782. }
  17783. }
  17784. var iteminfoStructs []service.IteminfoStruct
  17785. if bedCostTotal != 0 {
  17786. iteminfo.MedChrgitm = "01"
  17787. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17788. iteminfo.Amt = bedCostTotal
  17789. iteminfo.ClaaSumfee = bed_claa_sunmfee
  17790. iteminfo.ClabAmt = bed_clab_amt
  17791. iteminfo.OthAmt = bed_other_amt
  17792. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17793. }
  17794. if checkCostTotal != 0 {
  17795. iteminfo.MedChrgitm = "03"
  17796. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  17797. iteminfo.Amt = checkCostTotal
  17798. iteminfo.ClaaSumfee = check_claa_sunmfee
  17799. iteminfo.ClabAmt = check_clab_amt
  17800. iteminfo.OthAmt = check_other_amt
  17801. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17802. }
  17803. if laboratoryCostTotal != 0 {
  17804. iteminfo.MedChrgitm = "04"
  17805. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  17806. iteminfo.Amt = laboratoryCostTotal
  17807. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  17808. iteminfo.ClabAmt = laboratory_clab_amt
  17809. iteminfo.OthAmt = laboratory_other_amt
  17810. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17811. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17812. }
  17813. if treatCostTotal != 0 {
  17814. iteminfo.MedChrgitm = "05"
  17815. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  17816. iteminfo.Amt = treatCostTotal
  17817. iteminfo.ClaaSumfee = treat_claa_sunmfee
  17818. iteminfo.ClabAmt = treat_clab_amt
  17819. iteminfo.OthAmt = treat_other_amt
  17820. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17821. //(struct4101.IteminfoStruct, iteminfo)
  17822. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17823. }
  17824. if operationCostTotal != 0 {
  17825. iteminfo.MedChrgitm = "06"
  17826. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17827. iteminfo.Amt = operationCostTotal
  17828. iteminfo.ClaaSumfee = operation_claa_sunmfee
  17829. iteminfo.ClabAmt = operation_clab_amt
  17830. iteminfo.OthAmt = operation_other_amt
  17831. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17832. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17833. }
  17834. if materialCostTotal != 0 {
  17835. iteminfo.MedChrgitm = "08"
  17836. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  17837. iteminfo.Amt = materialCostTotal
  17838. iteminfo.ClaaSumfee = material_claa_sunmfee
  17839. iteminfo.ClabAmt = material_clab_amt
  17840. iteminfo.OthAmt = material_other_amt
  17841. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17842. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17843. }
  17844. if westernMedicineCostTotal != 0 {
  17845. iteminfo.MedChrgitm = "09"
  17846. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  17847. iteminfo.Amt = westernMedicineCostTotal
  17848. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  17849. iteminfo.ClabAmt = westernMedicine_clab_amt
  17850. iteminfo.OthAmt = westernMedicine_other_amt
  17851. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17852. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17853. }
  17854. if chineseTraditionalMedicineCostTotal != 0 {
  17855. iteminfo.MedChrgitm = "11"
  17856. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  17857. iteminfo.Amt = westernMedicineCostTotal
  17858. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  17859. iteminfo.ClabAmt = westernMedicine_clab_amt
  17860. iteminfo.OthAmt = westernMedicine_other_amt
  17861. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17862. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17863. }
  17864. if otherCostTotal != 0 {
  17865. iteminfo.MedChrgitm = "14"
  17866. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  17867. iteminfo.Amt = otherCostTotal
  17868. iteminfo.ClaaSumfee = other_claa_sunmfee
  17869. iteminfo.ClabAmt = other_clab_amt
  17870. iteminfo.OthAmt = other_other_amt
  17871. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17872. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17873. }
  17874. struct4101.IteminfoStruct = iteminfoStructs
  17875. struct4101.Ntly = "中国"
  17876. struct4101.AdmCaty = "A03.06"
  17877. struct4101.DoctorName = doctor.UserName
  17878. struct4101.DoctorCode = doctor.DoctorNumber
  17879. var res ResultSeventeen
  17880. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17881. struct4101.BillCode = order.Number
  17882. struct4101.BillNo = order.SetlId
  17883. var resOther ResultSeventeenOther
  17884. var pp models.PublicParams
  17885. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17886. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17887. pp.FixmedinsName = miConfig.OrgName
  17888. pp.FixmedinsCode = miConfig.Code
  17889. pp.RequestUrl = miConfig.Url
  17890. pp.Cainfo = miConfig.Cainfo
  17891. pp.SecretKey = miConfig.SecretKey
  17892. pp.AccessKey = miConfig.AccessKey
  17893. pp.OpterName = curRoles.UserName
  17894. client := &http.Client{}
  17895. var req *http.Request
  17896. data := make(map[string]interface{})
  17897. data["struct4101"] = struct4101
  17898. data["pp"] = pp
  17899. bytesData, _ := json.Marshal(data)
  17900. if miConfig.MdtrtareaAdmvs == "320921" {
  17901. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  17902. } else {
  17903. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  17904. }
  17905. resp, _ := client.Do(req)
  17906. defer resp.Body.Close()
  17907. body, ioErr := ioutil.ReadAll(resp.Body)
  17908. if ioErr != nil {
  17909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17911. return
  17912. }
  17913. var respJSON map[string]interface{}
  17914. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17917. return
  17918. }
  17919. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17920. userJSONBytes, _ := json.Marshal(respJSON)
  17921. fmt.Println("log")
  17922. fmt.Println(string(userJSONBytes))
  17923. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  17924. utils.ErrorLog("解析失败:%v", err)
  17925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17926. return
  17927. }
  17928. res.InfRefmsgid = resOther.InfRefmsgid
  17929. res.Output = resOther.Output
  17930. res.ErrMsg = resOther.ErrMsg
  17931. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  17932. res.Infcode = infocode
  17933. } else if miConfig.MdtrtareaAdmvs == "360302" {
  17934. var pp models.PublicParams
  17935. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  17936. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17937. pp.FixmedinsName = miConfig.OrgName
  17938. pp.FixmedinsCode = miConfig.Code
  17939. pp.RequestUrl = miConfig.Url
  17940. pp.Cainfo = miConfig.Cainfo
  17941. pp.SecretKey = miConfig.SecretKey
  17942. pp.AccessKey = miConfig.AccessKey
  17943. pp.OpterName = curRoles.UserName
  17944. result, _ := service.Jxyb4101(struct4101, pp)
  17945. var dat map[string]interface{}
  17946. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17947. fmt.Println(dat)
  17948. } else {
  17949. fmt.Println(err)
  17950. }
  17951. userJSONBytes, _ := json.Marshal(dat)
  17952. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17953. utils.ErrorLog("解析失败:%v", err)
  17954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17955. return
  17956. }
  17957. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17958. var pp models.PublicParams
  17959. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17960. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17961. pp.FixmedinsName = miConfig.OrgName
  17962. pp.FixmedinsCode = miConfig.Code
  17963. pp.RequestUrl = miConfig.Url
  17964. pp.Cainfo = miConfig.Cainfo
  17965. pp.SecretKey = miConfig.SecretKey
  17966. pp.AccessKey = miConfig.AccessKey
  17967. pp.OpterName = curRoles.UserName
  17968. result, _ := service.Hnyb4101(struct4101, pp)
  17969. var dat map[string]interface{}
  17970. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17971. fmt.Println(dat)
  17972. } else {
  17973. fmt.Println(err)
  17974. }
  17975. userJSONBytes, _ := json.Marshal(dat)
  17976. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17977. utils.ErrorLog("解析失败:%v", err)
  17978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17979. return
  17980. }
  17981. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17982. var resOther ResultSeventeenOther
  17983. var pp models.PublicParams
  17984. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17985. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17986. pp.FixmedinsName = miConfig.OrgName
  17987. pp.FixmedinsCode = miConfig.Code
  17988. pp.RequestUrl = miConfig.Url
  17989. pp.Cainfo = miConfig.Cainfo
  17990. pp.SecretKey = miConfig.SecretKey
  17991. pp.AccessKey = miConfig.AccessKey
  17992. pp.OpterName = curRoles.UserName
  17993. client := &http.Client{}
  17994. var req *http.Request
  17995. data := make(map[string]interface{})
  17996. data["struct4101"] = struct4101
  17997. data["pp"] = pp
  17998. bytesData, _ := json.Marshal(data)
  17999. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18000. resp, _ := client.Do(req)
  18001. defer resp.Body.Close()
  18002. body, ioErr := ioutil.ReadAll(resp.Body)
  18003. if ioErr != nil {
  18004. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18006. return
  18007. }
  18008. var respJSON map[string]interface{}
  18009. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18010. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18012. return
  18013. }
  18014. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18015. userJSONBytes, _ := json.Marshal(respJSON)
  18016. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18017. utils.ErrorLog("解析失败:%v", err)
  18018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18019. return
  18020. }
  18021. res.InfRefmsgid = resOther.InfRefmsgid
  18022. res.Output = resOther.Output
  18023. res.ErrMsg = resOther.ErrMsg
  18024. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18025. res.Infcode = infocode
  18026. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18027. var pp models.PublicParams
  18028. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18029. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18030. pp.FixmedinsName = miConfig.OrgName
  18031. pp.FixmedinsCode = miConfig.Code
  18032. pp.RequestUrl = miConfig.Url
  18033. pp.Cainfo = miConfig.Cainfo
  18034. pp.SecretKey = miConfig.SecretKey
  18035. pp.AccessKey = miConfig.AccessKey
  18036. pp.OpterName = curRoles.UserName
  18037. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  18038. fmt.Println(requestLog)
  18039. fmt.Println(errMsgLog)
  18040. saveLog(result, requestLog, "4101a", "上传清单")
  18041. var dat map[string]interface{}
  18042. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18043. fmt.Println(dat)
  18044. } else {
  18045. fmt.Println(err)
  18046. }
  18047. userJSONBytes, _ := json.Marshal(dat)
  18048. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18049. utils.ErrorLog("解析失败:%v", err)
  18050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18051. return
  18052. }
  18053. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18054. var pp models.PublicParams
  18055. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18056. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18057. pp.FixmedinsName = miConfig.OrgName
  18058. pp.FixmedinsCode = miConfig.Code
  18059. pp.RequestUrl = miConfig.Url
  18060. pp.Cainfo = miConfig.Cainfo
  18061. pp.SecretKey = miConfig.SecretKey
  18062. pp.AccessKey = miConfig.AccessKey
  18063. pp.OpterName = curRoles.UserName
  18064. client := &http.Client{}
  18065. var req *http.Request
  18066. data := make(map[string]interface{})
  18067. data["struct4101"] = struct4101
  18068. data["pp"] = pp
  18069. bytesData, _ := json.Marshal(data)
  18070. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  18071. resp, _ := client.Do(req)
  18072. defer resp.Body.Close()
  18073. body, ioErr := ioutil.ReadAll(resp.Body)
  18074. if ioErr != nil {
  18075. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18077. return
  18078. }
  18079. var respJSON map[string]interface{}
  18080. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18081. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18083. return
  18084. }
  18085. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18086. userJSONBytes, _ := json.Marshal(respJSON)
  18087. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18088. utils.ErrorLog("解析失败:%v", err)
  18089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18090. return
  18091. }
  18092. } else {
  18093. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  18094. var dat map[string]interface{}
  18095. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18096. fmt.Println(dat)
  18097. } else {
  18098. fmt.Println(err)
  18099. }
  18100. userJSONBytes, _ := json.Marshal(dat)
  18101. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18102. utils.ErrorLog("解析失败:%v", err)
  18103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18104. return
  18105. }
  18106. }
  18107. if res.Infcode != 0 {
  18108. c.ServeSuccessJSON(map[string]interface{}{
  18109. "failed_code": -10,
  18110. "msg": res.ErrMsg,
  18111. })
  18112. return
  18113. } else {
  18114. //order.FaPiaoNumber = zero
  18115. //order.FaPiaoCode = last_order.FaPiaoCode
  18116. //service.UpdateOrder(order)
  18117. hisFundSettleListResult := &models.HisFundSettleListResult{
  18118. Number: res.Output.SetlListId,
  18119. Status: 1,
  18120. Ctime: time.Now().Unix(),
  18121. Mtime: time.Now().Unix(),
  18122. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18123. IsUpload: 1,
  18124. OrderId: order_id,
  18125. }
  18126. service.CreateUploadRecord(hisFundSettleListResult)
  18127. c.ServeSuccessJSON(map[string]interface{}{
  18128. "msg": "上传成功",
  18129. "result": hisFundSettleListResult,
  18130. })
  18131. return
  18132. }
  18133. }
  18134. func (c *HisApiController) GetSettleListHospital() {
  18135. order_id, _ := c.GetInt64("order_id")
  18136. admin_user_id, _ := c.GetInt64("admin_user_id")
  18137. order, _ := service.GetHisOrderByIDTwo(order_id)
  18138. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18139. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  18140. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18141. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18142. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18143. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18144. if order.ID == 0 {
  18145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  18146. return
  18147. }
  18148. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18149. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18150. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18151. fmt.Println(count)
  18152. var zero string
  18153. number := count + 1
  18154. if number >= 1000 {
  18155. zero = "0000" + strconv.FormatInt(number, 10)
  18156. } else if number >= 10000 {
  18157. zero = "000" + strconv.FormatInt(number, 10)
  18158. } else if number >= 100000 {
  18159. zero = "00" + strconv.FormatInt(number, 10)
  18160. } else if number >= 1000000 {
  18161. zero = "0" + strconv.FormatInt(number, 10)
  18162. } else {
  18163. zero = strconv.FormatInt(number, 10)
  18164. }
  18165. fmt.Println(zero)
  18166. struct4101 := service.Struct4101{
  18167. PsnNo: order.PsnNo,
  18168. MdtrtId: order.MdtrtId,
  18169. SetlId: order.SetlId,
  18170. PsnName: order.PsnName,
  18171. Gend: order.Gend,
  18172. Brdy: his.Brdy,
  18173. Age: int64(order.Age),
  18174. Naty: order.Naty,
  18175. PatnCertType: "01",
  18176. Certno: order.Certno,
  18177. Prfs: "90",
  18178. ConerName: roles[0].UserName,
  18179. PatnRlts: "99",
  18180. ConerAddr: miConfig.OrgName,
  18181. ConerTel: admin.Mobile,
  18182. HiType: order.Insutype,
  18183. Insuplc: miConfig.InsuplcAdmdvs,
  18184. MaindiagFlag: "1",
  18185. BillCode: order.SetlId,
  18186. BillNo: order.SetlId,
  18187. BizSn: order.Number,
  18188. PsnSelfPay: order.PsnPartAmt,
  18189. PsnOwnPay: order.PsnPartAmt,
  18190. AcctPay: order.AcctPay,
  18191. PsnCashpay: order.PsnCashPay,
  18192. HiPaymtd: "1",
  18193. Hsorg: miConfig.InsuplcAdmdvs,
  18194. HsorgOpter: miConfig.InsuplcAdmdvs,
  18195. MedinsFillPsn: curRoles.UserName,
  18196. MedinsFillDept: depart.Name,
  18197. IptMedType: "2",
  18198. AdmTime: his.InHosptialTime,
  18199. AdmEndTime: his.OutHosptialTime,
  18200. }
  18201. struct4101.SetlBegnDate = order.SetlTime
  18202. struct4101.SetlEndDate = order.SetlTime
  18203. //var rf []CustomFundPay
  18204. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  18205. //
  18206. //var tempFunPays []service.CustomStruct
  18207. //for _, item := range rf {
  18208. // var tempFunPay service.CustomStruct
  18209. // tempFunPay.FundPayamt = item.FundPayamt
  18210. // tempFunPay.FundPayType = item.FundPayType
  18211. // tempFunPays = append(tempFunPays, tempFunPay)
  18212. //}
  18213. //struct4101.CustomStruct = tempFunPays
  18214. var tempDiaginfos []service.DiaginfoStructTwo
  18215. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18216. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18217. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  18218. //for _, item := range infos {
  18219. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  18220. //}
  18221. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  18222. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  18223. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18224. fmt.Println(diagnosis_ids_arr)
  18225. if order.UserOrgId == 10210 {
  18226. var diagnosis_ids_arr_two []int64
  18227. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  18228. var config []*models.HisXtDiagnoseConfig
  18229. for _, id := range diagnosis_ids_arr_two {
  18230. //id, _ := strconv.ParseInt(item, 10, 64)
  18231. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18232. if diagnosisConfig.ID > 0 {
  18233. config = append(config, &diagnosisConfig)
  18234. }
  18235. }
  18236. for index, item := range config {
  18237. if item.ID > 0 {
  18238. if index == 0 {
  18239. var tempDiaginfo service.DiaginfoStructTwo
  18240. tempDiaginfo.DiagCode = item.CountryCode
  18241. tempDiaginfo.DiagName = item.CountryContentName
  18242. tempDiaginfo.DiagType = "1"
  18243. tempDiaginfo.MaindiagFlag = "1"
  18244. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18245. } else {
  18246. var tempDiaginfo service.DiaginfoStructTwo
  18247. tempDiaginfo.DiagCode = item.CountryCode
  18248. tempDiaginfo.DiagName = item.CountryContentName
  18249. tempDiaginfo.DiagType = "1"
  18250. tempDiaginfo.MaindiagFlag = "0"
  18251. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18252. }
  18253. }
  18254. }
  18255. struct4101.Diseinfo = tempDiaginfos
  18256. } else {
  18257. var config []*models.HisXtDiagnoseConfig
  18258. for _, item := range diagnosis_ids_arr {
  18259. id, _ := strconv.ParseInt(item, 10, 64)
  18260. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18261. if diagnosisConfig.ID > 0 {
  18262. config = append(config, &diagnosisConfig)
  18263. }
  18264. }
  18265. for index, item := range config {
  18266. if item.ID > 0 {
  18267. if index == 0 {
  18268. var tempDiaginfo service.DiaginfoStructTwo
  18269. tempDiaginfo.DiagCode = item.CountryCode
  18270. tempDiaginfo.DiagName = item.CountryContentName
  18271. tempDiaginfo.DiagType = "1"
  18272. tempDiaginfo.MaindiagFlag = "1"
  18273. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18274. } else {
  18275. var tempDiaginfo service.DiaginfoStructTwo
  18276. tempDiaginfo.DiagCode = item.CountryCode
  18277. tempDiaginfo.DiagName = item.CountryContentName
  18278. tempDiaginfo.DiagType = "1"
  18279. tempDiaginfo.MaindiagFlag = "0"
  18280. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18281. }
  18282. }
  18283. }
  18284. struct4101.Diseinfo = tempDiaginfos
  18285. }
  18286. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18287. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18288. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18289. tempOpspdiseinfo2.OprnOprtCode = ""
  18290. tempOpspdiseinfo2.OprnOprtName = ""
  18291. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18292. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18293. var iteminfo service.IteminfoStruct
  18294. var bedCostTotal float64 = 0 //床位总费
  18295. var bedCostSelfTotal float64 = 0 //床位自费
  18296. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18297. var operationCostTotal float64 = 0 //手术费
  18298. var operationCostSelfTotal float64 = 0 //手术费
  18299. var operationCostPartSelfTotal float64 = 0 //手术费
  18300. var otherCostTotal float64 = 0 //其他费用
  18301. var otherCostSelfTotal float64 = 0 //其他费用
  18302. var otherCostPartSelfTotal float64 = 0 //其他费用
  18303. var materialCostTotal float64 = 0 //材料费
  18304. var materialCostSelfTotal float64 = 0 //材料费
  18305. var materialCostPartSelfTotal float64 = 0 //材料费
  18306. var westernMedicineCostTotal float64 = 0 //西药费
  18307. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18308. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18309. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18310. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18311. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18312. var checkCostTotal float64 = 0 //检查费
  18313. var checkCostSelfTotal float64 = 0 //检查费
  18314. var checkCostPartSelfTotal float64 = 0 //检查费
  18315. var laboratoryCostTotal float64 = 0 //化验费
  18316. var laboratoryCostSelfTotal float64 = 0 //化验费
  18317. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18318. var treatCostTotal float64 = 0 //治疗费用
  18319. var treatCostSelfTotal float64 = 0 //治疗费用
  18320. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18321. decimal.DivisionPrecision = 2
  18322. var bed_fulamt_ownpay_amt float64 = 0
  18323. var operation_fulamt_ownpay_amt float64 = 0
  18324. var other_fulamt_ownpay_amt float64 = 0
  18325. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18326. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18327. var check_fulamt_ownpay_amt float64 = 0
  18328. var material_fulamt_ownpay_amt float64 = 0
  18329. var laboratory_fulamt_ownpay_amt float64 = 0
  18330. var treat_fulamt_ownpay_amt float64 = 0
  18331. var bed_claa_sunmfee float64 = 0
  18332. var bed_clab_amt float64 = 0
  18333. var bed_other_amt float64 = 0
  18334. var operation_claa_sunmfee float64 = 0
  18335. var operation_clab_amt float64 = 0
  18336. var operation_other_amt float64 = 0
  18337. var other_claa_sunmfee float64 = 0
  18338. var other_clab_amt float64 = 0
  18339. var other_other_amt float64 = 0
  18340. var westernMedicine_claa_sunmfee float64 = 0
  18341. var westernMedicine_clab_amt float64 = 0
  18342. var westernMedicine_other_amt float64 = 0
  18343. var chineseTraditional_claa_sunmfee float64 = 0
  18344. var chineseTraditional_clab_amt float64 = 0
  18345. var chineseTraditional_other_amt float64 = 0
  18346. var check_claa_sunmfee float64 = 0
  18347. var check_clab_amt float64 = 0
  18348. var check_other_amt float64 = 0
  18349. var material_claa_sunmfee float64 = 0
  18350. var material_clab_amt float64 = 0
  18351. var material_other_amt float64 = 0
  18352. var laboratory_claa_sunmfee float64 = 0
  18353. var laboratory_clab_amt float64 = 0
  18354. var laboratory_other_amt float64 = 0
  18355. var treat_claa_sunmfee float64 = 0
  18356. var treat_clab_amt float64 = 0
  18357. var treat_other_amt float64 = 0
  18358. for _, item := range order.HisOrderInfo {
  18359. if item.MedChrgitmType == "01" { //床位费
  18360. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18361. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18362. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18363. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18364. if item.ChrgitmLv == "1" {
  18365. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18366. }
  18367. if item.ChrgitmLv == "2" {
  18368. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18369. }
  18370. if item.ChrgitmLv == "3" {
  18371. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18372. }
  18373. }
  18374. if item.MedChrgitmType == "03" { //检查费
  18375. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18376. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18377. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18378. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18379. if item.ChrgitmLv == "1" {
  18380. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18381. }
  18382. if item.ChrgitmLv == "2" {
  18383. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18384. }
  18385. if item.ChrgitmLv == "3" {
  18386. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18387. }
  18388. }
  18389. if item.MedChrgitmType == "04" { //化验费
  18390. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18391. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18392. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18393. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18394. if item.ChrgitmLv == "1" {
  18395. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18396. }
  18397. if item.ChrgitmLv == "2" {
  18398. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18399. }
  18400. if item.ChrgitmLv == "3" {
  18401. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18402. }
  18403. }
  18404. if item.MedChrgitmType == "05" { //治疗费
  18405. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18406. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18407. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18408. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18409. if item.ChrgitmLv == "1" {
  18410. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18411. }
  18412. if item.ChrgitmLv == "2" {
  18413. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18414. }
  18415. if item.ChrgitmLv == "3" {
  18416. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18417. }
  18418. }
  18419. if item.MedChrgitmType == "06" { //手术费
  18420. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18421. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18422. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18423. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18424. if item.ChrgitmLv == "1" {
  18425. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18426. }
  18427. if item.ChrgitmLv == "2" {
  18428. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18429. }
  18430. if item.ChrgitmLv == "3" {
  18431. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18432. }
  18433. }
  18434. if item.MedChrgitmType == "08" { //材料费
  18435. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18436. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18437. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18438. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18439. if item.ChrgitmLv == "1" {
  18440. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18441. }
  18442. if item.ChrgitmLv == "2" {
  18443. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18444. }
  18445. if item.ChrgitmLv == "3" {
  18446. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18447. }
  18448. }
  18449. if item.MedChrgitmType == "09" { //西药费
  18450. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18451. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18452. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18453. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18454. if item.ChrgitmLv == "1" {
  18455. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18456. }
  18457. if item.ChrgitmLv == "2" {
  18458. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18459. }
  18460. if item.ChrgitmLv == "3" {
  18461. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18462. }
  18463. }
  18464. if item.MedChrgitmType == "11" { //中成费
  18465. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18466. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18467. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18468. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18469. if item.ChrgitmLv == "1" {
  18470. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18471. }
  18472. if item.ChrgitmLv == "2" {
  18473. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18474. }
  18475. if item.ChrgitmLv == "3" {
  18476. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18477. }
  18478. }
  18479. if item.MedChrgitmType == "14" { //其他费
  18480. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18481. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18482. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18483. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18484. if item.ChrgitmLv == "1" {
  18485. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18486. }
  18487. if item.ChrgitmLv == "2" {
  18488. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18489. }
  18490. if item.ChrgitmLv == "3" {
  18491. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18492. }
  18493. }
  18494. }
  18495. var iteminfoStructs []service.IteminfoStruct
  18496. if bedCostTotal != 0 {
  18497. iteminfo.MedChrgitm = "01"
  18498. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18499. iteminfo.Amt = bedCostTotal
  18500. iteminfo.ClaaSumfee = bed_claa_sunmfee
  18501. iteminfo.ClabAmt = bed_clab_amt
  18502. iteminfo.OthAmt = bed_other_amt
  18503. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18504. }
  18505. if checkCostTotal != 0 {
  18506. iteminfo.MedChrgitm = "03"
  18507. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18508. iteminfo.Amt = checkCostTotal
  18509. iteminfo.ClaaSumfee = check_claa_sunmfee
  18510. iteminfo.ClabAmt = check_clab_amt
  18511. iteminfo.OthAmt = check_other_amt
  18512. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18513. }
  18514. if laboratoryCostTotal != 0 {
  18515. iteminfo.MedChrgitm = "04"
  18516. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18517. iteminfo.Amt = laboratoryCostTotal
  18518. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18519. iteminfo.ClabAmt = laboratory_clab_amt
  18520. iteminfo.OthAmt = laboratory_other_amt
  18521. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18522. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18523. }
  18524. if treatCostTotal != 0 {
  18525. iteminfo.MedChrgitm = "05"
  18526. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18527. iteminfo.Amt = treatCostTotal
  18528. iteminfo.ClaaSumfee = treat_claa_sunmfee
  18529. iteminfo.ClabAmt = treat_clab_amt
  18530. iteminfo.OthAmt = treat_other_amt
  18531. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18532. //(struct4101.IteminfoStruct, iteminfo)
  18533. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18534. }
  18535. if operationCostTotal != 0 {
  18536. iteminfo.MedChrgitm = "06"
  18537. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18538. iteminfo.Amt = operationCostTotal
  18539. iteminfo.ClaaSumfee = operation_claa_sunmfee
  18540. iteminfo.ClabAmt = operation_clab_amt
  18541. iteminfo.OthAmt = operation_other_amt
  18542. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18543. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18544. }
  18545. if materialCostTotal != 0 {
  18546. iteminfo.MedChrgitm = "08"
  18547. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18548. iteminfo.Amt = materialCostTotal
  18549. iteminfo.ClaaSumfee = material_claa_sunmfee
  18550. iteminfo.ClabAmt = material_clab_amt
  18551. iteminfo.OthAmt = material_other_amt
  18552. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18553. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18554. }
  18555. if westernMedicineCostTotal != 0 {
  18556. iteminfo.MedChrgitm = "09"
  18557. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18558. iteminfo.Amt = westernMedicineCostTotal
  18559. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18560. iteminfo.ClabAmt = westernMedicine_clab_amt
  18561. iteminfo.OthAmt = westernMedicine_other_amt
  18562. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18563. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18564. }
  18565. if chineseTraditionalMedicineCostTotal != 0 {
  18566. iteminfo.MedChrgitm = "11"
  18567. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18568. iteminfo.Amt = westernMedicineCostTotal
  18569. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18570. iteminfo.ClabAmt = westernMedicine_clab_amt
  18571. iteminfo.OthAmt = westernMedicine_other_amt
  18572. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18573. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18574. }
  18575. if otherCostTotal != 0 {
  18576. iteminfo.MedChrgitm = "14"
  18577. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18578. iteminfo.Amt = otherCostTotal
  18579. iteminfo.ClaaSumfee = other_claa_sunmfee
  18580. iteminfo.ClabAmt = other_clab_amt
  18581. iteminfo.OthAmt = other_other_amt
  18582. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18583. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18584. }
  18585. struct4101.IteminfoStruct = iteminfoStructs
  18586. struct4101.Ntly = "中国"
  18587. struct4101.AdmCaty = "A03.06"
  18588. var resOther ResultSeventeenOther
  18589. var res ResultSeventeen
  18590. if miConfig.MdtrtareaAdmvs == "150499" {
  18591. var pp models.PublicParams
  18592. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18593. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18594. pp.FixmedinsName = miConfig.OrgName
  18595. pp.FixmedinsCode = miConfig.Code
  18596. pp.RequestUrl = miConfig.Url
  18597. pp.Cainfo = miConfig.Cainfo
  18598. pp.SecretKey = miConfig.SecretKey
  18599. pp.AccessKey = miConfig.AccessKey
  18600. pp.OpterName = curRoles.UserName
  18601. client := &http.Client{}
  18602. var req *http.Request
  18603. data := make(map[string]interface{})
  18604. data["struct4101"] = struct4101
  18605. data["pp"] = pp
  18606. bytesData, _ := json.Marshal(data)
  18607. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18608. resp, _ := client.Do(req)
  18609. defer resp.Body.Close()
  18610. body, ioErr := ioutil.ReadAll(resp.Body)
  18611. if ioErr != nil {
  18612. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18614. return
  18615. }
  18616. var respJSON map[string]interface{}
  18617. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18620. return
  18621. }
  18622. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18623. userJSONBytes, _ := json.Marshal(respJSON)
  18624. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18625. utils.ErrorLog("解析失败:%v", err)
  18626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18627. return
  18628. }
  18629. res.InfRefmsgid = resOther.InfRefmsgid
  18630. res.Output = resOther.Output
  18631. res.ErrMsg = resOther.ErrMsg
  18632. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18633. res.Infcode = infocode
  18634. } else if miConfig.MdtrtareaAdmvs == "360302" {
  18635. var pp models.PublicParams
  18636. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18637. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18638. pp.FixmedinsName = miConfig.OrgName
  18639. pp.FixmedinsCode = miConfig.Code
  18640. pp.RequestUrl = miConfig.Url
  18641. pp.Cainfo = miConfig.Cainfo
  18642. pp.SecretKey = miConfig.SecretKey
  18643. pp.AccessKey = miConfig.AccessKey
  18644. pp.OpterName = curRoles.UserName
  18645. result, _ := service.Jxyb4101(struct4101, pp)
  18646. var dat map[string]interface{}
  18647. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18648. fmt.Println(dat)
  18649. } else {
  18650. fmt.Println(err)
  18651. }
  18652. userJSONBytes, _ := json.Marshal(dat)
  18653. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18654. utils.ErrorLog("解析失败:%v", err)
  18655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18656. return
  18657. }
  18658. } else {
  18659. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  18660. var dat map[string]interface{}
  18661. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18662. fmt.Println(dat)
  18663. } else {
  18664. fmt.Println(err)
  18665. }
  18666. userJSONBytes, _ := json.Marshal(dat)
  18667. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18668. utils.ErrorLog("解析失败:%v", err)
  18669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18670. return
  18671. }
  18672. }
  18673. if res.Infcode != 0 {
  18674. c.ServeSuccessJSON(map[string]interface{}{
  18675. "failed_code": -10,
  18676. "msg": res.ErrMsg,
  18677. })
  18678. return
  18679. } else {
  18680. if miConfig.MdtrtareaAdmvs != "150499" {
  18681. order.FaPiaoNumber = zero
  18682. order.FaPiaoCode = last_order.FaPiaoCode
  18683. service.UpdateOrder(order)
  18684. }
  18685. hisFundSettleListResult := &models.HisFundSettleListResult{
  18686. Number: res.Output.SetlListId,
  18687. Status: 1,
  18688. Ctime: time.Now().Unix(),
  18689. Mtime: time.Now().Unix(),
  18690. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18691. IsUpload: 1,
  18692. OrderId: order_id,
  18693. }
  18694. service.CreateUploadRecord(hisFundSettleListResult)
  18695. c.ServeSuccessJSON(map[string]interface{}{
  18696. "msg": "上传成功",
  18697. "result": hisFundSettleListResult,
  18698. })
  18699. return
  18700. }
  18701. }
  18702. //func (c *HisApiController) GetBatchSettleList() {
  18703. // orders, _ := service.GetAllHisOrder(10106)
  18704. // for _, item := range orders {
  18705. // order_id := item.ID
  18706. // order, _ := service.GetHisOrderByIDTwo(order_id)
  18707. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18708. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18709. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18710. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  18711. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18712. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18713. //
  18714. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18715. //
  18716. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18717. //
  18718. // if order.ID == 0 {
  18719. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  18720. // return
  18721. // }
  18722. // if his.BalanceAccountsType == 2 {
  18723. // continue
  18724. // }
  18725. // struct4101 := service.Struct4101{
  18726. // PsnNo: order.PsnNo,
  18727. // MdtrtId: order.MdtrtId,
  18728. // SetlId: order.SetlId,
  18729. // PsnName: order.PsnName,
  18730. // Gend: order.Gend,
  18731. // Brdy: his.Brdy,
  18732. // Age: his.Age,
  18733. // Naty: order.Naty,
  18734. // PatnCertType: "01",
  18735. // Certno: order.Certno,
  18736. // Prfs: "90",
  18737. // ConerName: roles[0].UserName,
  18738. // PatnRlts: "99",
  18739. // ConerAddr: miConfig.OrgName,
  18740. // ConerTel: admin.Mobile,
  18741. // HiType: order.Insutype,
  18742. // Insuplc: his.InsuplcAdmdvs,
  18743. // MaindiagFlag: "1",
  18744. // BillCode: order.SetlId,
  18745. // BillNo: order.SetlId,
  18746. // BizSn: order.Number,
  18747. // PsnSelfPay: order.PsnPartAmt,
  18748. // PsnOwnPay: order.PsnPartAmt,
  18749. // AcctPay: order.AcctPay,
  18750. // PsnCashpay: order.PsnCashPay,
  18751. // HiPaymtd: "1",
  18752. // Hsorg: his.InsuplcAdmdvs,
  18753. // HsorgOpter: his.InsuplcAdmdvs,
  18754. // MedinsFillPsn: curRoles.UserName,
  18755. // MedinsFillDept: depart.Name,
  18756. // IptMedType: "2",
  18757. // }
  18758. // struct4101.SetlBegnDate = order.SetlTime
  18759. // struct4101.SetlEndDate = order.SetlTime
  18760. // //if order.SettleType == 1 {
  18761. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  18762. // // dateStr := t.Format("2006-01-02")
  18763. // // struct4101.SetlBegnDate = dateStr
  18764. // // struct4101.SetlEndDate = dateStr
  18765. // //} else {
  18766. // // t := time.Unix(int64(order.SettleStartTime), 0)
  18767. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  18768. // // dateStartStr := t.Format("2006-01-02")
  18769. // // dateEndStr := t2.Format("2006-01-02")
  18770. // // struct4101.SetlBegnDate = dateStartStr
  18771. // // struct4101.SetlEndDate = dateEndStr
  18772. // //}
  18773. //
  18774. // var rf []CustomFundPay
  18775. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  18776. //
  18777. // var tempFunPays []service.CustomStruct
  18778. // var tempFunPay610100 service.CustomStruct
  18779. //
  18780. // for _, item := range rf {
  18781. // if item.FundPayType == "610100" {
  18782. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  18783. // tempFunPay610100.FundPayType = item.FundPayType
  18784. // } else {
  18785. // var tempFunPay service.CustomStruct
  18786. // tempFunPay.FundPayamt = item.FundPayamt
  18787. // tempFunPay.FundPayType = item.FundPayType
  18788. // tempFunPays = append(tempFunPays, tempFunPay)
  18789. // }
  18790. // }
  18791. // tempFunPays = append(tempFunPays, tempFunPay610100)
  18792. // struct4101.CustomStruct = tempFunPays
  18793. //
  18794. // var tempDiaginfos []service.DiaginfoStructTwo
  18795. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18796. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18797. //
  18798. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18799. // var config []*models.HisXtDiagnoseConfig
  18800. // for _, item := range diagnosis_ids {
  18801. // id, _ := strconv.ParseInt(item, 10, 64)
  18802. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  18803. // config = append(config, &diagnosisConfig)
  18804. // }
  18805. //
  18806. // for index, item := range config {
  18807. // if index == 0 {
  18808. // var tempDiaginfo service.DiaginfoStructTwo
  18809. // tempDiaginfo.DiagCode = item.CountryCode
  18810. // tempDiaginfo.DiagName = item.CountryContentName
  18811. // tempDiaginfo.DiagType = "1"
  18812. // tempDiaginfo.MaindiagFlag = "1"
  18813. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18814. // } else {
  18815. //
  18816. // var tempDiaginfo service.DiaginfoStructTwo
  18817. // tempDiaginfo.DiagCode = item.CountryCode
  18818. // tempDiaginfo.DiagName = item.CountryContentName
  18819. // tempDiaginfo.DiagType = "2"
  18820. // tempDiaginfo.MaindiagFlag = "0"
  18821. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18822. // }
  18823. // }
  18824. // struct4101.Diseinfo = tempDiaginfos
  18825. //
  18826. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  18827. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18828. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18829. // tempOpspdiseinfo2.OprnOprtCode = ""
  18830. // tempOpspdiseinfo2.OprnOprtName = ""
  18831. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18832. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18833. //
  18834. // var iteminfo service.IteminfoStruct
  18835. //
  18836. // var bedCostTotal float64 = 0 //床位总费
  18837. // var bedCostSelfTotal float64 = 0 //床位自费
  18838. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18839. //
  18840. // var examineCostTotal float64 = 0 //诊查总费
  18841. // var examineCostSelfTotal float64 = 0 //诊查自费
  18842. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  18843. //
  18844. // var nursingCostTotal float64 = 0 //护理总费
  18845. // var nursingCostSelfTotal float64 = 0 //护理自费
  18846. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  18847. //
  18848. // var chineseMedicineCostTotal float64 = 0 //中成药
  18849. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  18850. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  18851. //
  18852. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  18853. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  18854. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  18855. //
  18856. // var registerCostTotal float64 = 0 //一般诊疗费
  18857. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  18858. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  18859. //
  18860. // var operationCostTotal float64 = 0 //手术费
  18861. // var operationCostSelfTotal float64 = 0 //手术费
  18862. // var operationCostPartSelfTotal float64 = 0 //手术费
  18863. //
  18864. // var otherCostTotal float64 = 0 //其他费用
  18865. // var otherCostSelfTotal float64 = 0 //其他费用
  18866. // var otherCostPartSelfTotal float64 = 0 //其他费用
  18867. //
  18868. // var materialCostTotal float64 = 0 //材料费
  18869. // var materialCostSelfTotal float64 = 0 //材料费
  18870. // var materialCostPartSelfTotal float64 = 0 //材料费
  18871. //
  18872. // var westernMedicineCostTotal float64 = 0 //西药费
  18873. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  18874. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18875. //
  18876. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18877. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18878. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18879. //
  18880. // var checkCostTotal float64 = 0 //检查费
  18881. // var checkCostSelfTotal float64 = 0 //检查费
  18882. // var checkCostPartSelfTotal float64 = 0 //检查费
  18883. //
  18884. // var laboratoryCostTotal float64 = 0 //化验费
  18885. // var laboratoryCostSelfTotal float64 = 0 //化验费
  18886. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18887. //
  18888. // var treatCostTotal float64 = 0 //治疗费用
  18889. // var treatCostSelfTotal float64 = 0 //治疗费用
  18890. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  18891. //
  18892. // decimal.DivisionPrecision = 2
  18893. //
  18894. // var bed_fulamt_ownpay_amt float64 = 0
  18895. //
  18896. // var examine_fulamt_ownpay_amt float64 = 0
  18897. //
  18898. // var nursing_fulamt_ownpay_amt float64 = 0
  18899. //
  18900. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  18901. //
  18902. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  18903. //
  18904. // var register_fulamt_ownpay_amt float64 = 0
  18905. //
  18906. // var operation_fulamt_ownpay_amt float64 = 0
  18907. // var other_fulamt_ownpay_amt float64 = 0
  18908. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  18909. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18910. // var check_fulamt_ownpay_amt float64 = 0
  18911. // var material_fulamt_ownpay_amt float64 = 0
  18912. // var laboratory_fulamt_ownpay_amt float64 = 0
  18913. // var treat_fulamt_ownpay_amt float64 = 0
  18914. //
  18915. // var bed_claa_sunmfee float64 = 0
  18916. // var bed_clab_amt float64 = 0
  18917. // var bed_other_amt float64 = 0
  18918. //
  18919. // var examine_claa_sunmfee float64 = 0
  18920. // var examine_clab_amt float64 = 0
  18921. // var examine_other_amt float64 = 0
  18922. //
  18923. // var nursing_claa_sunmfee float64 = 0
  18924. // var nursing_clab_amt float64 = 0
  18925. // var nursing_other_amt float64 = 0
  18926. //
  18927. // var chinese_medicine_claa_sunmfee float64 = 0
  18928. // var chinese_medicine_clab_amt float64 = 0
  18929. // var chinese_medicine_other_amt float64 = 0
  18930. //
  18931. // var commonly_treatment_claa_sunmfee float64 = 0
  18932. // var commonly_treatment_clab_amt float64 = 0
  18933. // var commonly_treatment_other_amt float64 = 0
  18934. //
  18935. // var operation_claa_sunmfee float64 = 0
  18936. // var operation_clab_amt float64 = 0
  18937. // var operation_other_amt float64 = 0
  18938. //
  18939. // var other_claa_sunmfee float64 = 0
  18940. // var other_clab_amt float64 = 0
  18941. // var other_other_amt float64 = 0
  18942. //
  18943. // var westernMedicine_claa_sunmfee float64 = 0
  18944. // var westernMedicine_clab_amt float64 = 0
  18945. // var westernMedicine_other_amt float64 = 0
  18946. //
  18947. // var chineseTraditional_claa_sunmfee float64 = 0
  18948. // var chineseTraditional_clab_amt float64 = 0
  18949. // var chineseTraditional_other_amt float64 = 0
  18950. //
  18951. // var check_claa_sunmfee float64 = 0
  18952. // var check_clab_amt float64 = 0
  18953. // var check_other_amt float64 = 0
  18954. //
  18955. // var material_claa_sunmfee float64 = 0
  18956. // var material_clab_amt float64 = 0
  18957. // var material_other_amt float64 = 0
  18958. //
  18959. // var laboratory_claa_sunmfee float64 = 0
  18960. // var laboratory_clab_amt float64 = 0
  18961. // var laboratory_other_amt float64 = 0
  18962. //
  18963. // var treat_claa_sunmfee float64 = 0
  18964. // var treat_clab_amt float64 = 0
  18965. // var treat_other_amt float64 = 0
  18966. //
  18967. // var register_claa_sunmfee float64 = 0
  18968. // var register_clab_amt float64 = 0
  18969. // var register_other_amt float64 = 0
  18970. //
  18971. // for _, item := range order.HisOrderInfo {
  18972. // if item.MedChrgitmType == "01" { //床位费
  18973. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18974. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18975. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18976. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18977. // if item.ChrgitmLv == "1" {
  18978. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18979. // }
  18980. // if item.ChrgitmLv == "2" {
  18981. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18982. //
  18983. // }
  18984. // if item.ChrgitmLv == "3" {
  18985. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18986. // }
  18987. //
  18988. // }
  18989. //
  18990. // if item.MedChrgitmType == "02" { //诊查
  18991. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18992. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18993. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18994. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18995. // if item.ChrgitmLv == "1" {
  18996. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18997. // }
  18998. // if item.ChrgitmLv == "2" {
  18999. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19000. //
  19001. // }
  19002. // if item.ChrgitmLv == "3" {
  19003. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19004. // }
  19005. //
  19006. // }
  19007. //
  19008. // if item.MedChrgitmType == "03" { //检查费
  19009. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19010. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19011. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19012. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19013. // if item.ChrgitmLv == "1" {
  19014. //
  19015. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19016. //
  19017. // }
  19018. // if item.ChrgitmLv == "2" {
  19019. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19020. //
  19021. // }
  19022. // if item.ChrgitmLv == "3" {
  19023. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19024. // }
  19025. // }
  19026. //
  19027. // if item.MedChrgitmType == "04" { //化验费
  19028. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19029. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19030. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19031. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19032. // if item.ChrgitmLv == "1" {
  19033. //
  19034. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19035. //
  19036. // }
  19037. // if item.ChrgitmLv == "2" {
  19038. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19039. //
  19040. // }
  19041. // if item.ChrgitmLv == "3" {
  19042. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19043. // }
  19044. // }
  19045. //
  19046. // if item.MedChrgitmType == "05" { //治疗费
  19047. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19048. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19049. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19050. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19051. // if item.ChrgitmLv == "1" {
  19052. //
  19053. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19054. //
  19055. // }
  19056. // if item.ChrgitmLv == "2" {
  19057. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19058. //
  19059. // }
  19060. // if item.ChrgitmLv == "3" {
  19061. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19062. // }
  19063. // }
  19064. //
  19065. // if item.MedChrgitmType == "06" { //手术费
  19066. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19067. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19068. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19069. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19070. //
  19071. // if item.ChrgitmLv == "1" {
  19072. //
  19073. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19074. //
  19075. // }
  19076. // if item.ChrgitmLv == "2" {
  19077. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19078. //
  19079. // }
  19080. // if item.ChrgitmLv == "3" {
  19081. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19082. // }
  19083. // }
  19084. //
  19085. // if item.MedChrgitmType == "07" { //手术费
  19086. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19087. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19088. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19089. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19090. //
  19091. // if item.ChrgitmLv == "1" {
  19092. //
  19093. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19094. //
  19095. // }
  19096. // if item.ChrgitmLv == "2" {
  19097. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19098. //
  19099. // }
  19100. // if item.ChrgitmLv == "3" {
  19101. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19102. // }
  19103. // }
  19104. //
  19105. // if item.MedChrgitmType == "08" { //材料费
  19106. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19107. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19108. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19109. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19110. // if item.ChrgitmLv == "1" {
  19111. //
  19112. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19113. //
  19114. // }
  19115. // if item.ChrgitmLv == "2" {
  19116. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19117. //
  19118. // }
  19119. // if item.ChrgitmLv == "3" {
  19120. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19121. // }
  19122. // }
  19123. // if item.MedChrgitmType == "09" { //西药费
  19124. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19125. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19126. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19127. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19128. // if item.ChrgitmLv == "1" {
  19129. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19130. // }
  19131. // if item.ChrgitmLv == "2" {
  19132. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19133. // }
  19134. // if item.ChrgitmLv == "3" {
  19135. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19136. // }
  19137. // }
  19138. // if item.MedChrgitmType == "10" { //中药饮片
  19139. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19140. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19141. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19142. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19143. // if item.ChrgitmLv == "1" {
  19144. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19145. // }
  19146. // if item.ChrgitmLv == "2" {
  19147. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19148. // }
  19149. // if item.ChrgitmLv == "3" {
  19150. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19151. // }
  19152. // }
  19153. //
  19154. // if item.MedChrgitmType == "11" { //中成费
  19155. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19156. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19157. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19158. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19159. // if item.ChrgitmLv == "1" {
  19160. //
  19161. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19162. //
  19163. // }
  19164. // if item.ChrgitmLv == "2" {
  19165. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19166. //
  19167. // }
  19168. // if item.ChrgitmLv == "3" {
  19169. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19170. // }
  19171. // }
  19172. //
  19173. // if item.MedChrgitmType == "12" { //中成费
  19174. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19175. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19176. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19177. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19178. // if item.ChrgitmLv == "1" {
  19179. //
  19180. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19181. //
  19182. // }
  19183. // if item.ChrgitmLv == "2" {
  19184. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19185. //
  19186. // }
  19187. // if item.ChrgitmLv == "3" {
  19188. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19189. // }
  19190. // }
  19191. //
  19192. // if item.MedChrgitmType == "13" { //中成费
  19193. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19194. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19195. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19196. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19197. // if item.ChrgitmLv == "1" {
  19198. //
  19199. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19200. //
  19201. // }
  19202. // if item.ChrgitmLv == "2" {
  19203. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19204. //
  19205. // }
  19206. // if item.ChrgitmLv == "3" {
  19207. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19208. // }
  19209. // }
  19210. //
  19211. // if item.MedChrgitmType == "14" { //其他费
  19212. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19213. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19214. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19215. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19216. // if item.ChrgitmLv == "1" {
  19217. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19218. //
  19219. // }
  19220. // if item.ChrgitmLv == "2" {
  19221. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19222. //
  19223. // }
  19224. // if item.ChrgitmLv == "3" {
  19225. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19226. // }
  19227. // }
  19228. //
  19229. // }
  19230. //
  19231. // var iteminfoStructs []service.IteminfoStruct
  19232. //
  19233. // if bedCostTotal != 0 {
  19234. // iteminfo.MedChrgitm = "01"
  19235. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19236. // iteminfo.Amt = bedCostTotal
  19237. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  19238. // iteminfo.ClabAmt = bed_clab_amt
  19239. // iteminfo.OthAmt = bed_other_amt
  19240. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19241. // }
  19242. //
  19243. // if examineCostTotal != 0 {
  19244. // iteminfo.MedChrgitm = "02"
  19245. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  19246. // iteminfo.Amt = examineCostTotal
  19247. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  19248. // iteminfo.ClabAmt = examine_clab_amt
  19249. // iteminfo.OthAmt = examine_other_amt
  19250. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19251. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19252. // }
  19253. //
  19254. // if checkCostTotal != 0 {
  19255. // iteminfo.MedChrgitm = "03"
  19256. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19257. // iteminfo.Amt = checkCostTotal
  19258. // iteminfo.ClaaSumfee = check_claa_sunmfee
  19259. // iteminfo.ClabAmt = check_clab_amt
  19260. // iteminfo.OthAmt = check_other_amt
  19261. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19262. //
  19263. // }
  19264. //
  19265. // if laboratoryCostTotal != 0 {
  19266. // iteminfo.MedChrgitm = "04"
  19267. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19268. // iteminfo.Amt = laboratoryCostTotal
  19269. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19270. // iteminfo.ClabAmt = laboratory_clab_amt
  19271. // iteminfo.OthAmt = laboratory_other_amt
  19272. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19273. //
  19274. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19275. //
  19276. // }
  19277. //
  19278. // if treatCostTotal != 0 {
  19279. // iteminfo.MedChrgitm = "05"
  19280. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19281. // iteminfo.Amt = treatCostTotal
  19282. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  19283. // iteminfo.ClabAmt = treat_clab_amt
  19284. // iteminfo.OthAmt = treat_other_amt
  19285. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19286. // //(struct4101.IteminfoStruct, iteminfo)
  19287. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19288. // }
  19289. //
  19290. // if operationCostTotal != 0 {
  19291. // iteminfo.MedChrgitm = "06"
  19292. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19293. // iteminfo.Amt = operationCostTotal
  19294. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  19295. // iteminfo.ClabAmt = operation_clab_amt
  19296. // iteminfo.OthAmt = operation_other_amt
  19297. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19298. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19299. // }
  19300. //
  19301. // if nursingCostTotal != 0 {
  19302. // iteminfo.MedChrgitm = "07"
  19303. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  19304. // iteminfo.Amt = nursingCostTotal
  19305. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  19306. // iteminfo.ClabAmt = nursing_clab_amt
  19307. // iteminfo.OthAmt = nursing_other_amt
  19308. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19309. // }
  19310. //
  19311. // if materialCostTotal != 0 {
  19312. // iteminfo.MedChrgitm = "08"
  19313. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19314. // iteminfo.Amt = materialCostTotal
  19315. // iteminfo.ClaaSumfee = material_claa_sunmfee
  19316. // iteminfo.ClabAmt = material_clab_amt
  19317. // iteminfo.OthAmt = material_other_amt
  19318. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19319. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19320. // }
  19321. //
  19322. // if westernMedicineCostTotal != 0 {
  19323. // iteminfo.MedChrgitm = "09"
  19324. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19325. // iteminfo.Amt = westernMedicineCostTotal
  19326. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19327. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19328. // iteminfo.OthAmt = westernMedicine_other_amt
  19329. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19330. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19331. //
  19332. // }
  19333. //
  19334. // if chineseMedicineCostTotal != 0 {
  19335. // iteminfo.MedChrgitm = "10"
  19336. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  19337. // iteminfo.Amt = chineseMedicineCostTotal
  19338. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  19339. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  19340. // iteminfo.OthAmt = chinese_medicine_other_amt
  19341. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19342. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19343. //
  19344. // }
  19345. //
  19346. // if chineseTraditionalMedicineCostTotal != 0 {
  19347. // iteminfo.MedChrgitm = "11"
  19348. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19349. // iteminfo.Amt = westernMedicineCostTotal
  19350. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19351. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19352. // iteminfo.OthAmt = westernMedicine_other_amt
  19353. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19354. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19355. //
  19356. // }
  19357. //
  19358. // if commonlyTreatmentCostTotal != 0 {
  19359. // iteminfo.MedChrgitm = "12"
  19360. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  19361. // iteminfo.Amt = commonlyTreatmentCostTotal
  19362. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  19363. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  19364. // iteminfo.OthAmt = commonly_treatment_other_amt
  19365. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19366. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19367. //
  19368. // }
  19369. //
  19370. // if registerCostTotal != 0 {
  19371. // iteminfo.MedChrgitm = "13"
  19372. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  19373. // iteminfo.Amt = registerCostTotal
  19374. // iteminfo.ClaaSumfee = register_claa_sunmfee
  19375. // iteminfo.ClabAmt = register_clab_amt
  19376. // iteminfo.OthAmt = register_other_amt
  19377. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19378. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19379. //
  19380. // }
  19381. //
  19382. // if otherCostTotal != 0 {
  19383. // iteminfo.MedChrgitm = "14"
  19384. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19385. // iteminfo.Amt = otherCostTotal
  19386. // iteminfo.ClaaSumfee = other_claa_sunmfee
  19387. // iteminfo.ClabAmt = other_clab_amt
  19388. // iteminfo.OthAmt = other_other_amt
  19389. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19390. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19391. //
  19392. // }
  19393. // struct4101.IteminfoStruct = iteminfoStructs
  19394. // time_arr := strings.Split(order.SetlTime, " ")
  19395. // struct4101.AdmTime = time_arr[0]
  19396. // struct4101.AdmEndTime = time_arr[0]
  19397. //
  19398. // struct4101.DoctorName = doctor.UserName
  19399. // struct4101.DoctorCode = doctor.DoctorNumber
  19400. //
  19401. // struct4101.Ntly = "中国"
  19402. // struct4101.AdmCaty = "A03.06"
  19403. // var res ResultSeventeen
  19404. // if miConfig.MdtrtareaAdmvs == "421300" {
  19405. // data := make(map[string]interface{})
  19406. // data["struct4101"] = struct4101
  19407. // data["secret_key"] = miConfig.SecretKey
  19408. // data["org_name"] = miConfig.OrgName
  19409. // data["opera"] = curRoles.UserName
  19410. // data["code"] = miConfig.Code
  19411. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  19412. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19413. //
  19414. // client := &http.Client{}
  19415. // bytesData, _ := json.Marshal(data)
  19416. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  19417. // resp, _ := client.Do(req)
  19418. // defer resp.Body.Close()
  19419. // body, ioErr := ioutil.ReadAll(resp.Body)
  19420. // if ioErr != nil {
  19421. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19422. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19423. // return
  19424. // }
  19425. // var respJSON map[string]interface{}
  19426. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19427. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19428. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19429. // return
  19430. // }
  19431. //
  19432. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19433. // userJSONBytes, _ := json.Marshal(respJSON)
  19434. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19435. // utils.ErrorLog("解析失败:%v", err)
  19436. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19437. // adminUser := c.GetAdminUserInfo()
  19438. // errlog := &models.HisOrderError{
  19439. // UserOrgId: adminUser.CurrentOrgId,
  19440. // Ctime: time.Now().Unix(),
  19441. // Mtime: time.Now().Unix(),
  19442. // ErrMsg: res.ErrMsg + "解析失败",
  19443. // Status: 1,
  19444. // PatientId: order_id,
  19445. // Stage: 10088,
  19446. // }
  19447. // service.CreateErrMsgLog(errlog)
  19448. // continue
  19449. // }
  19450. //
  19451. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  19452. // data := make(map[string]interface{})
  19453. // data["struct4101"] = struct4101
  19454. // data["secret_key"] = miConfig.SecretKey
  19455. // data["org_name"] = miConfig.OrgName
  19456. // data["opera"] = curRoles.UserName
  19457. // data["code"] = miConfig.Code
  19458. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  19459. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19460. //
  19461. // client := &http.Client{}
  19462. // bytesData, _ := json.Marshal(data)
  19463. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  19464. // resp, _ := client.Do(req)
  19465. // defer resp.Body.Close()
  19466. // body, ioErr := ioutil.ReadAll(resp.Body)
  19467. // if ioErr != nil {
  19468. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19469. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19470. // return
  19471. // }
  19472. // var respJSON map[string]interface{}
  19473. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19474. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19475. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19476. // return
  19477. // }
  19478. //
  19479. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19480. // userJSONBytes, _ := json.Marshal(respJSON)
  19481. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19482. // utils.ErrorLog("解析失败:%v", err)
  19483. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19484. // adminUser := c.GetAdminUserInfo()
  19485. // errlog := &models.HisOrderError{
  19486. // UserOrgId: adminUser.CurrentOrgId,
  19487. // Ctime: time.Now().Unix(),
  19488. // Mtime: time.Now().Unix(),
  19489. // ErrMsg: res.ErrMsg + "解析失败",
  19490. // Status: 1,
  19491. // PatientId: order_id,
  19492. // Stage: 10088,
  19493. // }
  19494. // service.CreateErrMsgLog(errlog)
  19495. // continue
  19496. // }
  19497. //
  19498. // } else {
  19499. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  19500. // fmt.Println(result)
  19501. //
  19502. // var dat map[string]interface{}
  19503. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19504. // fmt.Println(dat)
  19505. // } else {
  19506. // fmt.Println(err)
  19507. // }
  19508. // userJSONBytes, _ := json.Marshal(dat)
  19509. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19510. // utils.ErrorLog("解析失败:%v", err)
  19511. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19512. // adminUser := c.GetAdminUserInfo()
  19513. // errlog := &models.HisOrderError{
  19514. // UserOrgId: adminUser.CurrentOrgId,
  19515. // Ctime: time.Now().Unix(),
  19516. // Mtime: time.Now().Unix(),
  19517. // ErrMsg: res.ErrMsg + "解析失败",
  19518. // Status: 1,
  19519. // PatientId: order_id,
  19520. // Stage: 10106,
  19521. // }
  19522. // service.CreateErrMsgLog(errlog)
  19523. // continue
  19524. // }
  19525. // }
  19526. //
  19527. // if res.Infcode != 0 {
  19528. // adminUser := c.GetAdminUserInfo()
  19529. // errlog := &models.HisOrderError{
  19530. // UserOrgId: adminUser.CurrentOrgId,
  19531. // Ctime: time.Now().Unix(),
  19532. // Mtime: time.Now().Unix(),
  19533. // ErrMsg: res.ErrMsg,
  19534. // Status: 1,
  19535. // PatientId: order_id,
  19536. // Stage: 10106,
  19537. // }
  19538. // service.CreateErrMsgLog(errlog)
  19539. // continue
  19540. // } else {
  19541. // hisFundSettleListResult := &models.HisFundSettleListResult{
  19542. // Number: res.Output.SetlListId,
  19543. // Status: 1,
  19544. // Ctime: time.Now().Unix(),
  19545. // Mtime: time.Now().Unix(),
  19546. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19547. // IsUpload: 1,
  19548. // OrderId: order_id,
  19549. // }
  19550. // service.CreateUploadRecord(hisFundSettleListResult)
  19551. // continue
  19552. // }
  19553. // }
  19554. //}
  19555. func (c *HisApiController) GetOrgInfo() {
  19556. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  19557. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  19558. }
  19559. func (c *HisApiController) GetHisPatientInfo() {
  19560. medical_insurance_card := c.GetString("medical_insurance_card")
  19561. id_card_type, _ := c.GetInt64("id_card_type")
  19562. id_card := c.GetString("id_card")
  19563. adminInfo := c.GetAdminUserInfo()
  19564. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  19565. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  19566. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  19567. IdCardNo := ""
  19568. if id_card_type == 1 {
  19569. IdCardNo = medical_insurance_card
  19570. } else if id_card_type == 2 {
  19571. IdCardNo = id_card
  19572. }
  19573. if config.IsOpen == 1 {
  19574. 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
  19575. resp, requestErr := http.Get(api)
  19576. if requestErr != nil {
  19577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19578. return
  19579. }
  19580. defer resp.Body.Close()
  19581. body, ioErr := ioutil.ReadAll(resp.Body)
  19582. if ioErr != nil {
  19583. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19585. return
  19586. }
  19587. var respJSON map[string]interface{}
  19588. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19589. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19591. return
  19592. }
  19593. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19594. userJSONBytes, _ := json.Marshal(userJSON)
  19595. var res ResultTwo
  19596. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19597. utils.ErrorLog("解析失败:%v", err)
  19598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19599. return
  19600. }
  19601. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  19602. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  19603. infoStr := string(Iinfos)
  19604. idetinfoStr := string(Idetinfos)
  19605. if res.Infcode == 0 {
  19606. his := models.VMHisPatient{
  19607. Status: 1,
  19608. Ctime: time.Now().Unix(),
  19609. Mtime: time.Now().Unix(),
  19610. PsnNo: res.Output.Baseinfo.PsnNo,
  19611. PsnCertType: res.Output.Baseinfo.PsnCertType,
  19612. Certno: res.Output.Baseinfo.Certno,
  19613. PsnName: res.Output.Baseinfo.PsnName,
  19614. Gend: res.Output.Baseinfo.Gend,
  19615. Naty: res.Output.Baseinfo.Naty,
  19616. Iinfo: infoStr,
  19617. Idetinfo: idetinfoStr,
  19618. UserOrgId: adminInfo.CurrentOrgId,
  19619. IsReturn: 1,
  19620. IdCardType: id_card_type,
  19621. }
  19622. c.ServeSuccessJSON(map[string]interface{}{
  19623. "info": his,
  19624. })
  19625. } else {
  19626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  19627. return
  19628. }
  19629. }
  19630. }
  19631. //func GetBasBaseInfo() (jsonStr string, err error) {
  19632. //
  19633. // handle := syscall.NewLazyDLL("SSCard.dll")
  19634. // add := handle.NewProc("ReadCardBas")
  19635. // str := make([]byte, 1024)
  19636. // str1 := make([]byte, 1024)
  19637. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  19638. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  19639. //
  19640. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  19641. //
  19642. // fmt.Println("> Add(4,5)的结果为:", ret)
  19643. // handle.Release()
  19644. //
  19645. // return "", nil
  19646. //
  19647. //}
  19648. //func GetQRBaseInfo() (jsonStr string, err error) {
  19649. // handle := syscall.LoadDLL("SSCard.dll")
  19650. // ReadCardBas := handle.FindProc("GetQRBase")
  19651. //
  19652. // str := make([]byte, 256)
  19653. // str1 := make([]byte, 256)
  19654. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  19655. //
  19656. // fmt.Println(string(str))
  19657. // fmt.Println(r)
  19658. // return string(str), nil
  19659. //}
  19660. //func CardInit() int {
  19661. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  19662. // add := DllTestDef.MustFindProc("Init")
  19663. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  19664. // if err != nil {
  19665. // fmt.Println("SSCard的运算结果为:", ret)
  19666. // }
  19667. // result := int(ret)
  19668. // return result
  19669. //}
  19670. //func CardInit() int {
  19671. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  19672. // if err != nil {
  19673. // fmt.Println("SSCard的运算结果为:", ret)
  19674. // }
  19675. // fmt.Println(err)
  19676. // result := int(ret)
  19677. // return result
  19678. //}
  19679. func IntPtr(n int) uintptr {
  19680. return uintptr(n)
  19681. }
  19682. func StrPtr(s string) uintptr {
  19683. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  19684. }
  19685. type Result2001 struct {
  19686. Cainfo interface{} `json:"cainfo"`
  19687. ErrMsg string `json:"err_msg"`
  19688. InfRefmsgid string `json:"inf_refmsgid"`
  19689. Infcode int64 `json:"infcode"`
  19690. Output struct {
  19691. Trtinfo struct {
  19692. PsnNo string `json:"psn_no"`
  19693. TrtChkType string `json:"trt_chk_type"`
  19694. FundPayType string `json:"fund_pay_type"`
  19695. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  19696. Begndate string `json:"begndate"`
  19697. Enddate string `json:"enddate"`
  19698. TrtChkRslt string `json:"trt_chk_rslt"`
  19699. } `json:"trtinfo"`
  19700. } `json:"output"`
  19701. RefmsgTime string `json:"refmsg_time"`
  19702. RespondTime string `json:"respond_time"`
  19703. Signtype interface{} `json:"signtype"`
  19704. WarnMsg interface{} `json:"warn_msg"`
  19705. }
  19706. type Result2001Org10265 struct {
  19707. Cainfo interface{} `json:"cainfo"`
  19708. ErrMsg string `json:"err_msg"`
  19709. InfRefmsgid string `json:"inf_refmsgid"`
  19710. Infcode string `json:"infcode"`
  19711. Output struct {
  19712. Trtinfo struct {
  19713. PsnNo string `json:"psn_no"`
  19714. TrtChkType string `json:"trt_chk_type"`
  19715. FundPayType string `json:"fund_pay_type"`
  19716. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  19717. Begndate string `json:"begndate"`
  19718. Enddate string `json:"enddate"`
  19719. TrtChkRslt string `json:"trt_chk_rslt"`
  19720. } `json:"trtinfo"`
  19721. } `json:"output"`
  19722. RefmsgTime string `json:"refmsg_time"`
  19723. RespondTime string `json:"respond_time"`
  19724. Signtype interface{} `json:"signtype"`
  19725. WarnMsg interface{} `json:"warn_msg"`
  19726. }
  19727. type ResultTwo struct {
  19728. ErrMsg string `json:"err_msg"`
  19729. InfRefmsgid string `json:"inf_refmsgid"`
  19730. Infcode int64 `json:"infcode"`
  19731. Output struct {
  19732. Baseinfo struct {
  19733. //Brdy string `json:"brdy"`
  19734. Certno string `json:"certno"`
  19735. Gend string `json:"gend"`
  19736. Naty string `json:"naty"`
  19737. PsnCertType string `json:"psn_cert_type"`
  19738. PsnName string `json:"psn_name"`
  19739. PsnNo string `json:"psn_no"`
  19740. } `json:"baseinfo"`
  19741. Idetinfo []interface{} `json:"idetinfo"`
  19742. Iinfo []struct {
  19743. Balc float64 `json:"balc"`
  19744. CvlservFlag string `json:"cvlserv_flag"`
  19745. EmpName string `json:"emp_name"`
  19746. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  19747. Insutype string `json:"insutype"`
  19748. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  19749. //PausInsuDate string `json:"paus_insu_date"`
  19750. //PsnInsuDate string `json:"psn_insu_date"`
  19751. PsnInsuStas string `json:"psn_insu_stas"`
  19752. PsnType string `json:"psn_type"`
  19753. } `json:"insuinfo"`
  19754. } `json:"output"`
  19755. RefmsgTime string `json:"refmsg_time"`
  19756. RespondTime string `json:"respond_time"`
  19757. Signtype interface{} `json:"signtype"`
  19758. WarnInfo interface{} `json:"warn_info"`
  19759. }
  19760. type ResultTwo10265 struct {
  19761. ErrMsg string `json:"err_msg"`
  19762. InfRefmsgid string `json:"inf_refmsgid"`
  19763. Infcode string `json:"infcode"`
  19764. Output struct {
  19765. Baseinfo struct {
  19766. //Brdy string `json:"brdy"`
  19767. Certno string `json:"certno"`
  19768. Gend string `json:"gend"`
  19769. Naty string `json:"naty"`
  19770. PsnCertType string `json:"psn_cert_type"`
  19771. PsnName string `json:"psn_name"`
  19772. PsnNo string `json:"psn_no"`
  19773. } `json:"baseinfo"`
  19774. Idetinfo []interface{} `json:"idetinfo"`
  19775. Iinfo []struct {
  19776. Balc float64 `json:"balc"`
  19777. CvlservFlag string `json:"cvlserv_flag"`
  19778. EmpName string `json:"emp_name"`
  19779. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  19780. Insutype string `json:"insutype"`
  19781. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  19782. PsnInsuStas string `json:"psn_insu_stas"`
  19783. PsnType string `json:"psn_type"`
  19784. } `json:"insuinfo"`
  19785. } `json:"output"`
  19786. RefmsgTime string `json:"refmsg_time"`
  19787. RespondTime string `json:"respond_time"`
  19788. Signtype interface{} `json:"signtype"`
  19789. WarnInfo interface{} `json:"warn_info"`
  19790. }
  19791. type ResultThree struct {
  19792. Cainfo interface{} `json:"cainfo"`
  19793. ErrMsg string `json:"err_msg"`
  19794. InfRefmsgid string `json:"inf_refmsgid"`
  19795. Infcode int64 `json:"infcode"`
  19796. Output struct {
  19797. Data struct {
  19798. IptOtpNo string `json:"ipt_otp_no"`
  19799. MdtrtID string `json:"mdtrt_id"`
  19800. PsnNo string `json:"psn_no"`
  19801. } `json:"data"`
  19802. } `json:"output"`
  19803. RefmsgTime string `json:"refmsg_time"`
  19804. RespondTime string `json:"respond_time"`
  19805. Signtype interface{} `json:"signtype"`
  19806. WarnMsg interface{} `json:"warn_msg"`
  19807. }
  19808. type ResultThree10265 struct {
  19809. Cainfo interface{} `json:"cainfo"`
  19810. ErrMsg string `json:"err_msg"`
  19811. InfRefmsgid string `json:"inf_refmsgid"`
  19812. Infcode string `json:"infcode"`
  19813. Output struct {
  19814. Data struct {
  19815. IptOtpNo string `json:"ipt_otp_no"`
  19816. MdtrtID string `json:"mdtrt_id"`
  19817. PsnNo string `json:"psn_no"`
  19818. } `json:"data"`
  19819. } `json:"output"`
  19820. RefmsgTime string `json:"refmsg_time"`
  19821. RespondTime string `json:"respond_time"`
  19822. Signtype interface{} `json:"signtype"`
  19823. WarnMsg interface{} `json:"warn_msg"`
  19824. }
  19825. type ResultFour struct {
  19826. Cainfo string `json:"cainfo"`
  19827. ErrMsg string `json:"err_msg"`
  19828. InfRefmsgid string `json:"inf_refmsgid"`
  19829. Infcode int64 `json:"infcode"`
  19830. Output struct {
  19831. Result []struct {
  19832. BasMednFlag string `json:"bas_medn_flag"`
  19833. ChldMedcFlag string `json:"chld_medc_flag"`
  19834. ChrgitmLv string `json:"chrgitm_lv"`
  19835. Cnt float64 `json:"cnt"`
  19836. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  19837. DrtReimFlag string `json:"drt_reim_flag"`
  19838. FeedetlSn string `json:"feedetl_sn"`
  19839. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  19840. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  19841. InscpScpAmt float64 `json:"inscp_scp_amt"`
  19842. ListSpItemFlag string `json:"list_sp_item_flag"`
  19843. LmtUsedFlag string `json:"lmt_used_flag"`
  19844. MedChrgitmType string `json:"med_chrgitm_type"`
  19845. Memo string `json:"memo"`
  19846. OverlmtAmt float64 `json:"overlmt_amt"`
  19847. PreselfpayAmt float64 `json:"preselfpay_amt"`
  19848. Pric float64 `json:"pric"`
  19849. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  19850. SelfpayProp float64 `json:"selfpay_prop"`
  19851. } `json:"result"`
  19852. } `json:"output"`
  19853. RefmsgTime string `json:"refmsg_time"`
  19854. RespondTime string `json:"respond_time"`
  19855. Signtype string `json:"signtype"`
  19856. WarnMsg string `json:"warn_msg"`
  19857. }
  19858. type ResultFour10265 struct {
  19859. Cainfo string `json:"cainfo"`
  19860. ErrMsg string `json:"err_msg"`
  19861. InfRefmsgid string `json:"inf_refmsgid"`
  19862. Infcode string `json:"infcode"`
  19863. Output struct {
  19864. Result []struct {
  19865. BasMednFlag string `json:"bas_medn_flag"`
  19866. ChldMedcFlag string `json:"chld_medc_flag"`
  19867. ChrgitmLv string `json:"chrgitm_lv"`
  19868. Cnt float64 `json:"cnt"`
  19869. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  19870. DrtReimFlag string `json:"drt_reim_flag"`
  19871. FeedetlSn string `json:"feedetl_sn"`
  19872. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  19873. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  19874. InscpScpAmt float64 `json:"inscp_scp_amt"`
  19875. ListSpItemFlag string `json:"list_sp_item_flag"`
  19876. LmtUsedFlag string `json:"lmt_used_flag"`
  19877. MedChrgitmType string `json:"med_chrgitm_type"`
  19878. Memo string `json:"memo"`
  19879. OverlmtAmt float64 `json:"overlmt_amt"`
  19880. PreselfpayAmt float64 `json:"preselfpay_amt"`
  19881. Pric float64 `json:"pric"`
  19882. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  19883. SelfpayProp float64 `json:"selfpay_prop"`
  19884. } `json:"result"`
  19885. } `json:"output"`
  19886. RefmsgTime string `json:"refmsg_time"`
  19887. RespondTime string `json:"respond_time"`
  19888. Signtype string `json:"signtype"`
  19889. WarnMsg string `json:"warn_msg"`
  19890. }
  19891. type ResultMemo struct {
  19892. InsuAdmdvs string `json:"insuAdmdvs"`
  19893. }
  19894. // [{"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}]
  19895. type ResultIDInfo struct {
  19896. Begntime string `json:"begntime"`
  19897. Endtime string `json:"endtime"`
  19898. Memo string `json:"memo"`
  19899. }
  19900. type ResultFive struct {
  19901. Balc float64 `json:"balc"`
  19902. CvlservFlag string `json:"cvlserv_flag"`
  19903. EmpName string `json:"emp_name"`
  19904. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  19905. Insutype string `json:"insutype"`
  19906. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  19907. PausInsuDate string `json:"paus_insu_date"`
  19908. PsnInsuDate string `json:"psn_insu_date"`
  19909. PsnInsuStas string `json:"psn_insu_stas"`
  19910. PsnType string `json:"psn_type"`
  19911. }
  19912. type ResultSix struct {
  19913. Cainfo interface{} `json:"cainfo"`
  19914. ErrMsg string `json:"err_msg"`
  19915. InfRefmsgid string `json:"inf_refmsgid"`
  19916. Infcode int64 `json:"infcode"`
  19917. Output struct {
  19918. } `json:"output"`
  19919. RefmsgTime string `json:"refmsg_time"`
  19920. RespondTime string `json:"respond_time"`
  19921. Signtype interface{} `json:"signtype"`
  19922. WarnMsg interface{} `json:"warn_msg"`
  19923. }
  19924. type FJ3507Result struct {
  19925. Cainfo interface{} `json:"cainfo"`
  19926. ErrMsg string `json:"err_msg"`
  19927. InfRefmsgid string `json:"inf_refmsgid"`
  19928. Infcode int64 `json:"infcode"`
  19929. Output struct {
  19930. retRslt string `json:"retRslt"`
  19931. msgRslt string `json:"msgRslt"`
  19932. } `json:"output"`
  19933. RefmsgTime string `json:"refmsg_time"`
  19934. RespondTime string `json:"respond_time"`
  19935. Signtype interface{} `json:"signtype"`
  19936. WarnMsg interface{} `json:"warn_msg"`
  19937. }
  19938. type FJ3507ResultFor10188 struct {
  19939. Cainfo interface{} `json:"cainfo"`
  19940. ErrMsg string `json:"err_msg"`
  19941. InfRefmsgid string `json:"inf_refmsgid"`
  19942. Infcode string `json:"infcode"`
  19943. RefmsgTime string `json:"refmsg_time"`
  19944. RespondTime string `json:"respond_time"`
  19945. Signtype interface{} `json:"signtype"`
  19946. WarnMsg interface{} `json:"warn_msg"`
  19947. }
  19948. type Result2406 struct {
  19949. Cainfo interface{} `json:"cainfo"`
  19950. ErrMsg string `json:"err_msg"`
  19951. InfRefmsgid string `json:"inf_refmsgid"`
  19952. Infcode int64 `json:"infcode"`
  19953. Output struct {
  19954. Result struct {
  19955. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  19956. } `json:"result"`
  19957. } `json:"output"`
  19958. RefmsgTime string `json:"refmsg_time"`
  19959. RespondTime string `json:"respond_time"`
  19960. Signtype interface{} `json:"signtype"`
  19961. WarnMsg interface{} `json:"warn_msg"`
  19962. }
  19963. type GZResultSix struct {
  19964. Cainfo interface{} `json:"cainfo"`
  19965. ErrMsg string `json:"err_msg"`
  19966. InfRefmsgid string `json:"inf_refmsgid"`
  19967. Infcode int64 `json:"infcode"`
  19968. Output string `json:"output"`
  19969. RefmsgTime string `json:"refmsg_time"`
  19970. RespondTime string `json:"respond_time"`
  19971. Signtype interface{} `json:"signtype"`
  19972. WarnMsg interface{} `json:"warn_msg"`
  19973. }
  19974. type ResultSix10265 struct {
  19975. Cainfo interface{} `json:"cainfo"`
  19976. ErrMsg string `json:"err_msg"`
  19977. InfRefmsgid string `json:"inf_refmsgid"`
  19978. Infcode string `json:"infcode"`
  19979. Output struct {
  19980. } `json:"output"`
  19981. RefmsgTime string `json:"refmsg_time"`
  19982. RespondTime string `json:"respond_time"`
  19983. Signtype interface{} `json:"signtype"`
  19984. WarnMsg interface{} `json:"warn_msg"`
  19985. }
  19986. type ResultSeven struct {
  19987. Cainfo string `json:"cainfo"`
  19988. ErrMsg string `json:"err_msg"`
  19989. InfRefmsgid string `json:"inf_refmsgid"`
  19990. Infcode int64 `json:"infcode"`
  19991. Output struct {
  19992. Setlinfo struct {
  19993. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  19994. AcctPay float64 `json:"acct_pay"`
  19995. ActPayDedc float64 `json:"act_pay_dedc"`
  19996. Age float64 `json:"age"`
  19997. Balc float64 `json:"balc"`
  19998. Certno string `json:"certno"`
  19999. ClrOptins string `json:"clr_optins"`
  20000. ClrType string `json:"clr_type"`
  20001. ClrWay string `json:"clr_way"`
  20002. CvlservFlag string `json:"cvlserv_flag"`
  20003. CvlservPay float64 `json:"cvlserv_pay"`
  20004. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20005. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20006. Gend string `json:"gend"`
  20007. HifesPay float64 `json:"hifes_pay"`
  20008. HifmiPay float64 `json:"hifmi_pay"`
  20009. HifpPay float64 `json:"hifp_pay"`
  20010. HospPartAmt float64 `json:"hosp_part_amt"`
  20011. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20012. Insutype string `json:"insutype"`
  20013. MafPay float64 `json:"maf_pay"`
  20014. MdtrtCertType string `json:"mdtrt_cert_type"`
  20015. HifobPay float64 `json:"hifob_pay"`
  20016. MdtrtID string `json:"mdtrt_id"`
  20017. MedType string `json:"med_type"`
  20018. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20019. MedinsSetlID string `json:"medins_setl_id"`
  20020. Naty string `json:"naty"`
  20021. OthPay float64 `json:"oth_pay"`
  20022. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20023. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  20024. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20025. PsnCashPay float64 `json:"psn_cash_pay"`
  20026. PsnCertType string `json:"psn_cert_type"`
  20027. PsnName string `json:"psn_name"`
  20028. PsnNo string `json:"psn_no"`
  20029. PsnPartAmt float64 `json:"psn_part_amt"`
  20030. PsnType string `json:"psn_type"`
  20031. SetlID string `json:"setl_id"`
  20032. SetlTime string `json:"setl_time"`
  20033. } `json:"setlinfo"`
  20034. Setldetail interface{} `json:"setldetail"`
  20035. } `json:"output"`
  20036. RefmsgTime string `json:"refmsg_time"`
  20037. RespondTime string `json:"respond_time"`
  20038. Signtype interface{} `json:"signtype"`
  20039. WarnMsg interface{} `json:"warn_msg"`
  20040. }
  20041. type ResultSevenAH struct {
  20042. Cainfo string `json:"cainfo"`
  20043. ErrMsg string `json:"err_msg"`
  20044. InfRefmsgid string `json:"inf_refmsgid"`
  20045. Infcode int64 `json:"infcode"`
  20046. Output struct {
  20047. Setlinfo struct {
  20048. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  20049. AcctPay float64 `json:"acct_pay"`
  20050. ActPayDedc float64 `json:"act_pay_dedc"`
  20051. Age float64 `json:"age"`
  20052. Balc float64 `json:"balc"`
  20053. Certno string `json:"certno"`
  20054. ClrOptins string `json:"clr_optins"`
  20055. ClrType string `json:"clr_type"`
  20056. ClrWay string `json:"clr_way"`
  20057. CvlservFlag string `json:"cvlserv_flag"`
  20058. CvlservPay float64 `json:"cvlserv_pay"`
  20059. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20060. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20061. Gend string `json:"gend"`
  20062. HifesPay float64 `json:"hifes_pay"`
  20063. HifmiPay float64 `json:"hifmi_pay"`
  20064. HifpPay float64 `json:"hifp_pay"`
  20065. HospPartAmt float64 `json:"hosp_part_amt"`
  20066. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20067. Insutype string `json:"insutype"`
  20068. MafPay float64 `json:"maf_pay"`
  20069. MdtrtCertType string `json:"mdtrt_cert_type"`
  20070. HifobPay float64 `json:"hifob_pay"`
  20071. MdtrtID string `json:"mdtrt_id"`
  20072. MedType string `json:"med_type"`
  20073. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20074. MedinsSetlID string `json:"medins_setl_id"`
  20075. Naty string `json:"naty"`
  20076. OthPay float64 `json:"oth_pay"`
  20077. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20078. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  20079. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20080. PsnCashPay float64 `json:"psn_cash_pay"`
  20081. PsnCertType string `json:"psn_cert_type"`
  20082. PsnName string `json:"psn_name"`
  20083. PsnNo string `json:"psn_no"`
  20084. PsnPartAmt float64 `json:"psn_part_amt"`
  20085. PsnType string `json:"psn_type"`
  20086. SetlID string `json:"setl_id"`
  20087. SetlTime int64 `json:"setl_time"`
  20088. } `json:"setlinfo"`
  20089. Setldetail interface{} `json:"setldetail"`
  20090. } `json:"output"`
  20091. RefmsgTime string `json:"refmsg_time"`
  20092. RespondTime string `json:"respond_time"`
  20093. Signtype interface{} `json:"signtype"`
  20094. WarnMsg interface{} `json:"warn_msg"`
  20095. }
  20096. type ResultSeven10265 struct {
  20097. Cainfo string `json:"cainfo"`
  20098. ErrMsg string `json:"err_msg"`
  20099. InfRefmsgid string `json:"inf_refmsgid"`
  20100. Infcode string `json:"infcode"`
  20101. Output struct {
  20102. Setlinfo struct {
  20103. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  20104. AcctPay float64 `json:"acct_pay"`
  20105. ActPayDedc float64 `json:"act_pay_dedc"`
  20106. Age float64 `json:"age"`
  20107. Balc float64 `json:"balc"`
  20108. Certno string `json:"certno"`
  20109. ClrOptins string `json:"clr_optins"`
  20110. ClrType string `json:"clr_type"`
  20111. ClrWay string `json:"clr_way"`
  20112. CvlservFlag string `json:"cvlserv_flag"`
  20113. CvlservPay float64 `json:"cvlserv_pay"`
  20114. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20115. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20116. Gend string `json:"gend"`
  20117. HifesPay float64 `json:"hifes_pay"`
  20118. HifmiPay float64 `json:"hifmi_pay"`
  20119. HifpPay float64 `json:"hifp_pay"`
  20120. HospPartAmt float64 `json:"hosp_part_amt"`
  20121. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20122. Insutype string `json:"insutype"`
  20123. MafPay float64 `json:"maf_pay"`
  20124. MdtrtCertType string `json:"mdtrt_cert_type"`
  20125. HifobPay float64 `json:"hifob_pay"`
  20126. MdtrtID string `json:"mdtrt_id"`
  20127. MedType string `json:"med_type"`
  20128. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20129. MedinsSetlID string `json:"medins_setl_id"`
  20130. Naty string `json:"naty"`
  20131. OthPay float64 `json:"oth_pay"`
  20132. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20133. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  20134. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20135. PsnCashPay float64 `json:"psn_cash_pay"`
  20136. PsnCertType string `json:"psn_cert_type"`
  20137. PsnName string `json:"psn_name"`
  20138. PsnNo string `json:"psn_no"`
  20139. PsnPartAmt float64 `json:"psn_part_amt"`
  20140. PsnType string `json:"psn_type"`
  20141. SetlID string `json:"setl_id"`
  20142. SetlTime string `json:"setl_time"`
  20143. } `json:"setlinfo"`
  20144. Setldetail interface{} `json:"setldetail"`
  20145. } `json:"output"`
  20146. RefmsgTime string `json:"refmsg_time"`
  20147. RespondTime string `json:"respond_time"`
  20148. Signtype interface{} `json:"signtype"`
  20149. WarnMsg interface{} `json:"warn_msg"`
  20150. }
  20151. type ResultSeven10265Two struct {
  20152. Cainfo string `json:"cainfo"`
  20153. ErrMsg string `json:"err_msg"`
  20154. InfRefmsgid string `json:"inf_refmsgid"`
  20155. Infcode string `json:"infcode"`
  20156. Output struct {
  20157. Setlinfo struct {
  20158. AcctMulaidPay string `json:"acct_mulaid_pay"`
  20159. AcctPay float64 `json:"acct_pay"`
  20160. ActPayDedc float64 `json:"act_pay_dedc"`
  20161. Age float64 `json:"age"`
  20162. Balc float64 `json:"balc"`
  20163. Certno string `json:"certno"`
  20164. ClrOptins string `json:"clr_optins"`
  20165. ClrType string `json:"clr_type"`
  20166. ClrWay string `json:"clr_way"`
  20167. CvlservFlag string `json:"cvlserv_flag"`
  20168. CvlservPay float64 `json:"cvlserv_pay"`
  20169. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20170. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20171. Gend string `json:"gend"`
  20172. HifesPay float64 `json:"hifes_pay"`
  20173. HifmiPay float64 `json:"hifmi_pay"`
  20174. HifpPay float64 `json:"hifp_pay"`
  20175. HospPartAmt string `json:"hosp_part_amt"`
  20176. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20177. Insutype string `json:"insutype"`
  20178. MafPay float64 `json:"maf_pay"`
  20179. MdtrtCertType string `json:"mdtrt_cert_type"`
  20180. HifobPay float64 `json:"hifob_pay"`
  20181. MdtrtID string `json:"mdtrt_id"`
  20182. MedType string `json:"med_type"`
  20183. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20184. MedinsSetlID string `json:"medins_setl_id"`
  20185. Naty string `json:"naty"`
  20186. OthPay float64 `json:"oth_pay"`
  20187. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20188. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  20189. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20190. PsnCashPay float64 `json:"psn_cash_pay"`
  20191. PsnCertType string `json:"psn_cert_type"`
  20192. PsnName string `json:"psn_name"`
  20193. PsnNo string `json:"psn_no"`
  20194. PsnPartAmt float64 `json:"psn_part_amt"`
  20195. PsnType string `json:"psn_type"`
  20196. SetlID string `json:"setl_id"`
  20197. SetlTime string `json:"setl_time"`
  20198. } `json:"setlinfo"`
  20199. Setldetail interface{} `json:"setldetail"`
  20200. } `json:"output"`
  20201. RefmsgTime string `json:"refmsg_time"`
  20202. RespondTime string `json:"respond_time"`
  20203. Signtype interface{} `json:"signtype"`
  20204. WarnMsg interface{} `json:"warn_msg"`
  20205. }
  20206. type GZResultSeven10265Two struct {
  20207. Cainfo string `json:"cainfo"`
  20208. ErrMsg string `json:"err_msg"`
  20209. InfRefmsgid string `json:"inf_refmsgid"`
  20210. Infcode int64 `json:"infcode"`
  20211. Output struct {
  20212. Setlinfo struct {
  20213. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  20214. AcctPay float64 `json:"acct_pay"`
  20215. ActPayDedc float64 `json:"act_pay_dedc"`
  20216. Age float64 `json:"age"`
  20217. Balc float64 `json:"balc"`
  20218. Certno string `json:"certno"`
  20219. ClrOptins string `json:"clr_optins"`
  20220. ClrType string `json:"clr_type"`
  20221. ClrWay string `json:"clr_way"`
  20222. CvlservFlag string `json:"cvlserv_flag"`
  20223. CvlservPay float64 `json:"cvlserv_pay"`
  20224. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20225. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20226. Gend string `json:"gend"`
  20227. HifesPay float64 `json:"hifes_pay"`
  20228. HifmiPay float64 `json:"hifmi_pay"`
  20229. HifpPay float64 `json:"hifp_pay"`
  20230. HospPartAmt float64 `json:"hosp_part_amt"`
  20231. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20232. Insutype string `json:"insutype"`
  20233. MafPay float64 `json:"maf_pay"`
  20234. MdtrtCertType string `json:"mdtrt_cert_type"`
  20235. HifobPay float64 `json:"hifob_pay"`
  20236. MdtrtID string `json:"mdtrt_id"`
  20237. MedType string `json:"med_type"`
  20238. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20239. MedinsSetlID string `json:"medins_setl_id"`
  20240. Naty string `json:"naty"`
  20241. OthPay float64 `json:"oth_pay"`
  20242. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20243. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  20244. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20245. PsnCashPay float64 `json:"psn_cash_pay"`
  20246. PsnCertType string `json:"psn_cert_type"`
  20247. PsnName string `json:"psn_name"`
  20248. PsnNo string `json:"psn_no"`
  20249. PsnPartAmt float64 `json:"psn_part_amt"`
  20250. PsnType string `json:"psn_type"`
  20251. SetlID string `json:"setl_id"`
  20252. SetlTime string `json:"setl_time"`
  20253. } `json:"setlinfo"`
  20254. Setldetail interface{} `json:"setldetail"`
  20255. } `json:"output"`
  20256. RefmsgTime string `json:"refmsg_time"`
  20257. RespondTime string `json:"respond_time"`
  20258. Signtype interface{} `json:"signtype"`
  20259. WarnMsg interface{} `json:"warn_msg"`
  20260. }
  20261. type ResultEight struct {
  20262. Cainfo string `json:"cainfo"`
  20263. ErrMsg string `json:"err_msg"`
  20264. InfRefmsgid string `json:"inf_refmsgid"`
  20265. Infcode int64 `json:"infcode"`
  20266. Output struct {
  20267. Stmtinfo struct {
  20268. SetlOptins string `json:"setl_optins"`
  20269. StmtRslt string `json:"stmt_rslt"`
  20270. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  20271. } `json:"stmtinfo"`
  20272. } `json:"output"`
  20273. RefmsgTime string `json:"refmsg_time"`
  20274. RespondTime string `json:"respond_time"`
  20275. Signtype interface{} `json:"signtype"`
  20276. WarnMsg interface{} `json:"warn_msg"`
  20277. }
  20278. type ResultEightFor10188 struct {
  20279. Cainfo string `json:"cainfo"`
  20280. ErrMsg string `json:"err_msg"`
  20281. InfRefmsgid string `json:"inf_refmsgid"`
  20282. Infcode string `json:"infcode"`
  20283. Output struct {
  20284. Stmtinfo struct {
  20285. SetlOptins string `json:"setl_optins"`
  20286. StmtRslt string `json:"stmt_rslt"`
  20287. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  20288. } `json:"stmtinfo"`
  20289. } `json:"output"`
  20290. RefmsgTime string `json:"refmsg_time"`
  20291. RespondTime string `json:"respond_time"`
  20292. Signtype interface{} `json:"signtype"`
  20293. WarnMsg interface{} `json:"warn_msg"`
  20294. }
  20295. type ResultNine struct {
  20296. Cainfo string `json:"cainfo"`
  20297. ErrMsg string `json:"err_msg"`
  20298. InfRefmsgid string `json:"inf_refmsgid"`
  20299. Infcode int64 `json:"infcode"`
  20300. Output struct {
  20301. FileQuryNo string `json:"file_qury_no"`
  20302. } `json:"output"`
  20303. RefmsgTime string `json:"refmsg_time"`
  20304. RespondTime string `json:"respond_time"`
  20305. Signtype interface{} `json:"signtype"`
  20306. WarnMsg interface{} `json:"warn_msg"`
  20307. }
  20308. type ResultTen struct {
  20309. Cainfo string `json:"cainfo"`
  20310. ErrMsg string `json:"err_msg"`
  20311. InfRefmsgid string `json:"inf_refmsgid"`
  20312. Infcode int64 `json:"infcode"`
  20313. Output struct {
  20314. Fileinfo struct {
  20315. DldEndtime string `json:"dld_endtime"`
  20316. FileQuryNo string `json:"file_qury_no"`
  20317. Filename string `json:"filename"`
  20318. } `json:"fileinfo"`
  20319. } `json:"output"`
  20320. RefmsgTime string `json:"refmsg_time"`
  20321. RespondTime string `json:"respond_time"`
  20322. Signtype interface{} `json:"signtype"`
  20323. WarnMsg interface{} `json:"warn_msg"`
  20324. }
  20325. type Result5262 struct {
  20326. ErrMsg string `json:"err_msg"`
  20327. InfRefmsgid string `json:"inf_refmsgid"`
  20328. Infcode int64 `json:"infcode"`
  20329. Output struct {
  20330. PageInfo struct {
  20331. Size int `json:"size"`
  20332. RecordCounts int `json:"record_counts"`
  20333. } `json:"page_info"`
  20334. Idetinfo []interface{} `json:"idetinfo"`
  20335. Result []struct {
  20336. SetlID string `json:"setl_id"`
  20337. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  20338. MdtrtID string `json:"mdtrt_id"`
  20339. InitSetlID string `json:"init_setl_id,omitempty"`
  20340. PsnNo string `json:"psn_no"`
  20341. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  20342. PsnName string `json:"psn_name"`
  20343. PsnCertType string `json:"psn_cert_type"`
  20344. Certno string `json:"certno"`
  20345. Gend string `json:"gend,omitempty"`
  20346. Naty string `json:"naty,omitempty"`
  20347. Brdy string `json:"brdy,omitempty"`
  20348. Age float64 `json:"age,omitempty"`
  20349. Insutype string `json:"insutype,omitempty"`
  20350. PsnType string `json:"psn_type"`
  20351. CvlservFlag string `json:"cvlserv_flag"`
  20352. CvlservLv string `json:"cvlserv_lv,omitempty"`
  20353. SpPsnType string `json:"sp_psn_type,omitempty"`
  20354. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  20355. ClctGrde string `json:"clct_grde,omitempty"`
  20356. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  20357. NwbFlag string `json:"nwb_flag,omitempty"`
  20358. InsuAdmdvs string `json:"insu_admdvs"`
  20359. EmpNo string `json:"emp_no,omitempty"`
  20360. EmpName string `json:"emp_name,omitempty"`
  20361. EmpType string `json:"emp_type,omitempty"`
  20362. EconType string `json:"econ_type,omitempty"`
  20363. AfilIndu string `json:"afil_indu,omitempty"`
  20364. AfilRlts string `json:"afil_rlts,omitempty"`
  20365. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  20366. PayLoc string `json:"pay_loc,omitempty"`
  20367. FixmedinsCode string `json:"fixmedins_code"`
  20368. FixmedinsName string `json:"fixmedins_name"`
  20369. HospLv string `json:"hosp_lv,omitempty"`
  20370. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  20371. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  20372. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  20373. Begndate string `json:"begndate"`
  20374. Enddate string `json:"enddate"`
  20375. SetlTime string `json:"setl_time"`
  20376. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  20377. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  20378. MedType string `json:"med_type"`
  20379. SetlType string `json:"setl_type,omitempty"`
  20380. ClrType string `json:"clr_type,omitempty"`
  20381. ClrWay string `json:"clr_way,omitempty"`
  20382. PsnSetlway string `json:"psn_setlway,omitempty"`
  20383. ClrOptins string `json:"clr_optins,omitempty"`
  20384. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  20385. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  20386. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  20387. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  20388. InscpAmt float64 `json:"inscp_amt,omitempty"`
  20389. DedcStd float64 `json:"dedc_std,omitempty"`
  20390. CrtDedc float64 `json:"crt_dedc,omitempty"`
  20391. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  20392. HifpPay float64 `json:"hifp_pay,omitempty"`
  20393. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  20394. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  20395. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  20396. HifesPay float64 `json:"hifes_pay,omitempty"`
  20397. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  20398. HifobPay float64 `json:"hifob_pay,omitempty"`
  20399. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  20400. MafPay float64 `json:"maf_pay,omitempty"`
  20401. OthfundPay float64 `json:"othfund_pay,omitempty"`
  20402. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  20403. PsnPay float64 `json:"psn_pay,omitempty"`
  20404. AcctPay float64 `json:"acct_pay,omitempty"`
  20405. CashPayamt float64 `json:"cash_payamt,omitempty"`
  20406. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  20407. Balc float64 `json:"balc,omitempty"`
  20408. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  20409. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  20410. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  20411. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  20412. Year string `json:"year,omitempty"`
  20413. DiseNo string `json:"dise_no,omitempty"`
  20414. DiseName string `json:"dise_name,omitempty"`
  20415. Invono string `json:"invono,omitempty"`
  20416. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  20417. ValiFlag string `json:"vali_flag,omitempty"`
  20418. Memo string `json:"memo,omitempty"`
  20419. Rid string `json:"rid"`
  20420. UpdtTime string `json:"updt_time,omitempty"`
  20421. CrterID string `json:"crter_id,omitempty"`
  20422. CrterName string `json:"crter_name,omitempty"`
  20423. CrteTime string `json:"crte_time,omitempty"`
  20424. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  20425. OpterID string `json:"opter_id,omitempty"`
  20426. OpterName string `json:"opter_name,omitempty"`
  20427. OptTime string `json:"opt_time,omitempty"`
  20428. OptinsNo string `json:"optins_no,omitempty"`
  20429. PoolareaNo string `json:"poolarea_no,omitempty"`
  20430. } `json:"result"`
  20431. } `json:"output"`
  20432. RefmsgTime string `json:"refmsg_time"`
  20433. RespondTime string `json:"respond_time"`
  20434. Signtype interface{} `json:"signtype"`
  20435. WarnInfo interface{} `json:"warn_info"`
  20436. }
  20437. type Result5267 struct {
  20438. ErrMsg string `json:"err_msg"`
  20439. InfRefmsgid string `json:"inf_refmsgid"`
  20440. Infcode int64 `json:"infcode"`
  20441. Output struct {
  20442. PageInfo struct {
  20443. Size int `json:"size"`
  20444. RecordCounts int `json:"record_counts"`
  20445. } `json:"pageinfo"`
  20446. Result []struct {
  20447. SetlID string `json:"setl_id"`
  20448. ClrOptins string `json:"clr_optins"`
  20449. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  20450. MdtrtID string `json:"mdtrt_id"`
  20451. InitSetlID string `json:"init_setl_id,omitempty"`
  20452. PsnNo string `json:"psn_no"`
  20453. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  20454. PsnName string `json:"psn_name"`
  20455. PsnCertType string `json:"psn_cert_type"`
  20456. Certno string `json:"certno"`
  20457. Gend string `json:"gend,omitempty"`
  20458. Naty string `json:"naty,omitempty"`
  20459. Brdy string `json:"brdy,omitempty"`
  20460. Age float64 `json:"age,omitempty"`
  20461. Insutype string `json:"insutype,omitempty"`
  20462. PsnType string `json:"psn_type"`
  20463. CvlservFlag string `json:"cvlserv_flag"`
  20464. CvlservLv string `json:"cvlserv_lv,omitempty"`
  20465. SpPsnType string `json:"sp_psn_type,omitempty"`
  20466. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  20467. ClctGrde string `json:"clct_grde,omitempty"`
  20468. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  20469. NwbFlag string `json:"nwb_flag,omitempty"`
  20470. InsuAdmdvs string `json:"insu_admdvs"`
  20471. EmpNo string `json:"emp_no,omitempty"`
  20472. EmpName string `json:"emp_name,omitempty"`
  20473. EmpType string `json:"emp_type,omitempty"`
  20474. EconType string `json:"econ_type,omitempty"`
  20475. AfilIndu string `json:"afil_indu,omitempty"`
  20476. AfilRlts string `json:"afil_rlts,omitempty"`
  20477. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  20478. PayLoc string `json:"pay_loc,omitempty"`
  20479. FixmedinsCode string `json:"fixmedins_code"`
  20480. FixmedinsName string `json:"fixmedins_name"`
  20481. HospLv string `json:"hosp_lv,omitempty"`
  20482. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  20483. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  20484. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  20485. Begndate string `json:"begndate,omitempty"`
  20486. Enddate string `json:"enddate,omitempty"`
  20487. SetlTime string `json:"setl_time,omitempty"`
  20488. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  20489. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  20490. MedType string `json:"med_type"`
  20491. SetlType string `json:"setl_type,omitempty"`
  20492. ClrType string `json:"clr_type,omitempty"`
  20493. ClrWay string `json:"clr_way,omitempty"`
  20494. PsnSetlway string `json:"psn_setlway,omitempty"`
  20495. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  20496. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  20497. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  20498. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  20499. InscpAmt float64 `json:"inscp_amt,omitempty"`
  20500. DedcStd float64 `json:"dedc_std,omitempty"`
  20501. CrtDedc float64 `json:"crt_dedc,omitempty"`
  20502. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  20503. HifpPay float64 `json:"hifp_pay,omitempty"`
  20504. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  20505. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  20506. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  20507. HifesPay float64 `json:"hifes_pay,omitempty"`
  20508. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  20509. HifobPay float64 `json:"hifob_pay,omitempty"`
  20510. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  20511. MafPay float64 `json:"maf_pay,omitempty"`
  20512. OthfundPay float64 `json:"othfund_pay,omitempty"`
  20513. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  20514. PsnPay float64 `json:"psn_pay,omitempty"`
  20515. AcctPay float64 `json:"acct_pay,omitempty"`
  20516. CashPayamt float64 `json:"cash_payamt,omitempty"`
  20517. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  20518. Balc float64 `json:"balc,omitempty"`
  20519. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  20520. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  20521. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  20522. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  20523. Year string `json:"year,omitempty"`
  20524. DiseNo string `json:"dise_no,omitempty"`
  20525. DiseName string `json:"dise_name,omitempty"`
  20526. Invono string `json:"invono,omitempty"`
  20527. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  20528. Memo string `json:"memo,omitempty"`
  20529. UpdtTime string `json:"updt_time,omitempty"`
  20530. OpterID string `json:"opter_id,omitempty"`
  20531. OpterName string `json:"opter_name,omitempty"`
  20532. OptTime string `json:"opt_time,omitempty"`
  20533. OptinsNo string `json:"optins_no,omitempty"`
  20534. PoolareaNo string `json:"poolarea_no,omitempty"`
  20535. } `json:"result"`
  20536. } `json:"output"`
  20537. RefmsgTime string `json:"refmsg_time"`
  20538. RespondTime string `json:"respond_time"`
  20539. Signtype interface{} `json:"signtype"`
  20540. WarnInfo interface{} `json:"warn_info"`
  20541. }
  20542. // type Autogenerated struct {
  20543. // Output struct {
  20544. // Setlinfo struct {
  20545. // SetlTime string `json:"setl_time"`
  20546. // CvlservPay float64 `json:"cvlserv_pay"`
  20547. // Year string `json:"year"`
  20548. // MedType string `json:"med_type"`
  20549. // PsnPay float64 `json:"psn_pay"`
  20550. // OpterID string `json:"opter_id"`
  20551. // Begndate string `json:"begndate"`
  20552. // FlxempeFlag string `json:"flxempe_flag"`
  20553. // HifmiPay float64 `json:"hifmi_pay"`
  20554. // PsnNo string `json:"psn_no"`
  20555. // ActPayDedc float64 `json:"act_pay_dedc"`
  20556. // MedinsSetlID interface{} `json:"medins_setl_id"`
  20557. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  20558. // ClrWay string `json:"clr_way"`
  20559. // OthPay float64 `json:"oth_pay"`
  20560. // Gend string `json:"gend"`
  20561. // MdtrtID string `json:"mdtrt_id"`
  20562. // AcctPay float64 `json:"acct_pay"`
  20563. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  20564. // Insutype string `json:"insutype"`
  20565. // Invono interface{} `json:"invono"`
  20566. // Enddate string `json:"enddate"`
  20567. // CashPayamt float64 `json:"cash_payamt"`
  20568. // PsnType string `json:"psn_type"`
  20569. // FixmedinsName string `json:"fixmedins_name"`
  20570. // HifpPay float64 `json:"hifp_pay"`
  20571. // NewFlag interface{} `json:"new_flag"`
  20572. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20573. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  20574. // PayLoc string `json:"pay_loc"`
  20575. // ClrType string `json:"clr_type"`
  20576. // RefdSetlFlag string `json:"refd_setl_flag"`
  20577. // CvlservFlag string `json:"cvlserv_flag"`
  20578. // EmpName string `json:"emp_name"`
  20579. // Brdy string `json:"brdy"`
  20580. // Naty string `json:"naty"`
  20581. // Certno string `json:"certno"`
  20582. // DiseCode string `json:"dise_code"`
  20583. // FixmedinsCode string `json:"fixmedins_code"`
  20584. // DedcHospLv string `json:"dedc_hosp_lv"`
  20585. // OpterName string `json:"opter_name"`
  20586. // Balc float64 `json:"balc"`
  20587. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  20588. // PsnCertType string `json:"psn_cert_type"`
  20589. // HifobPay float64 `json:"hifob_pay"`
  20590. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  20591. // HifesPay float64 `json:"hifes_pay"`
  20592. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20593. // OptTime string `json:"opt_time"`
  20594. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20595. // SetlID string `json:"setl_id"`
  20596. // MafPay float64 `json:"maf_pay"`
  20597. // PsnName string `json:"psn_name"`
  20598. // InsuOptins interface{} `json:"insu_optins"`
  20599. // PrefFundPay interface{} `json:"pref_fund_pay"`
  20600. // ClrOptins string `json:"clr_optins"`
  20601. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  20602. // DiseName string `json:"dise_name"`
  20603. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  20604. // Age float64 `json:"age"`
  20605. // DtrtCertType string `json:"dtrt_cert_type"`
  20606. // HospLv string `json:"hosp_lv"`
  20607. // } `json:"setlinfo"`
  20608. // Setldetail []struct {
  20609. // FundPayType string `json:"fund_pay_type"`
  20610. // FundPayamt float64 `json:"fund_payamt"`
  20611. // SetlProcInfo interface{} `json:"setl_proc_info"`
  20612. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  20613. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  20614. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  20615. // PrefFundPay interface{} `json:"pref_fund_pay"`
  20616. // } `json:"setldetail"`
  20617. // } `json:"output"`
  20618. // Infcode int `json:"infcode"`
  20619. // WarnMsg interface{} `json:"warn_msg"`
  20620. // Cainfo interface{} `json:"cainfo"`
  20621. // ErrMsg interface{} `json:"err_msg"`
  20622. // RefmsgTime string `json:"refmsg_time"`
  20623. // Signtype interface{} `json:"signtype"`
  20624. // RespondTime string `json:"respond_time"`
  20625. // InfRefmsgid string `json:"inf_refmsgid"`
  20626. // }
  20627. type Result002 struct {
  20628. Cainfo interface{} `json:"cainfo"`
  20629. ErrMsg string `json:"err_msg"`
  20630. InfRefmsgid string `json:"inf_refmsgid"`
  20631. Infcode int64 `json:"infcode"`
  20632. Output struct {
  20633. RxFile string `json:"rx_file"`
  20634. SignDigest string `json:"sign_digest"`
  20635. SignCertSn string `json:"sign_cert_sn"`
  20636. SignCertDn string `json:"sign_cert_dn"`
  20637. } `json:"output"`
  20638. RefmsgTime string `json:"refmsg_time"`
  20639. RespondTime string `json:"respond_time"`
  20640. Signtype interface{} `json:"signtype"`
  20641. WarnMsg interface{} `json:"warn_msg"`
  20642. }
  20643. type Result003 struct {
  20644. Cainfo interface{} `json:"cainfo"`
  20645. ErrMsg string `json:"err_msg"`
  20646. InfRefmsgid string `json:"inf_refmsgid"`
  20647. Infcode int64 `json:"infcode"`
  20648. Output struct {
  20649. HiRxno string `json:"hi_rxno"`
  20650. RxStasCodg string `json:"rx_stas_codg"`
  20651. RxStasName string `json:"rx_stas_name"`
  20652. } `json:"output"`
  20653. RefmsgTime string `json:"refmsg_time"`
  20654. RespondTime string `json:"respond_time"`
  20655. Signtype interface{} `json:"signtype"`
  20656. WarnMsg interface{} `json:"warn_msg"`
  20657. }
  20658. type ResultEleven struct {
  20659. Cainfo string `json:"cainfo"`
  20660. ErrMsg string `json:"err_msg"`
  20661. InfRefmsgid string `json:"inf_refmsgid"`
  20662. Infcode int64 `json:"infcode"`
  20663. Output struct {
  20664. Setlinfo struct {
  20665. SetlTime string `json:"setl_time"`
  20666. CvlservPay float64 `json:"cvlserv_pay"`
  20667. Year string `json:"year"`
  20668. MedType string `json:"med_type"`
  20669. PsnPay float64 `json:"psn_pay"`
  20670. OpterID string `json:"opter_id"`
  20671. Begndate string `json:"begndate"`
  20672. FlxempeFlag string `json:"flxempe_flag"`
  20673. HifmiPay float64 `json:"hifmi_pay"`
  20674. PsnNo string `json:"psn_no"`
  20675. ActPayDedc float64 `json:"act_pay_dedc"`
  20676. MedinsSetlID interface{} `json:"medins_setl_id"`
  20677. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  20678. ClrWay string `json:"clr_way"`
  20679. OthPay float64 `json:"oth_pay"`
  20680. Gend string `json:"gend"`
  20681. MdtrtID string `json:"mdtrt_id"`
  20682. AcctPay float64 `json:"acct_pay"`
  20683. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20684. Insutype string `json:"insutype"`
  20685. Invono interface{} `json:"invono"`
  20686. Enddate string `json:"enddate"`
  20687. CashPayamt float64 `json:"cash_payamt"`
  20688. PsnType string `json:"psn_type"`
  20689. FixmedinsName string `json:"fixmedins_name"`
  20690. HifpPay float64 `json:"hifp_pay"`
  20691. NewFlag interface{} `json:"new_flag"`
  20692. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20693. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20694. PayLoc string `json:"pay_loc"`
  20695. ClrType string `json:"clr_type"`
  20696. RefdSetlFlag string `json:"refd_setl_flag"`
  20697. CvlservFlag string `json:"cvlserv_flag"`
  20698. EmpName string `json:"emp_name"`
  20699. Brdy string `json:"brdy"`
  20700. Naty string `json:"naty"`
  20701. Certno string `json:"certno"`
  20702. DiseCode string `json:"dise_code"`
  20703. FixmedinsCode string `json:"fixmedins_code"`
  20704. DedcHospLv string `json:"dedc_hosp_lv"`
  20705. OpterName string `json:"opter_name"`
  20706. Balc float64 `json:"balc"`
  20707. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  20708. PsnCertType string `json:"psn_cert_type"`
  20709. HifobPay float64 `json:"hifob_pay"`
  20710. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20711. HifesPay float64 `json:"hifes_pay"`
  20712. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20713. OptTime string `json:"opt_time"`
  20714. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20715. SetlID string `json:"setl_id"`
  20716. MafPay float64 `json:"maf_pay"`
  20717. PsnName string `json:"psn_name"`
  20718. InsuOptins interface{} `json:"insu_optins"`
  20719. PrefFundPay interface{} `json:"pref_fund_pay"`
  20720. ClrOptins string `json:"clr_optins"`
  20721. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  20722. DiseName string `json:"dise_name"`
  20723. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  20724. Age float64 `json:"age"`
  20725. DtrtCertType string `json:"dtrt_cert_type"`
  20726. HospLv string `json:"hosp_lv"`
  20727. PsnCashPay float64 `json:"psn_cash_pay"`
  20728. } `json:"setlinfo"`
  20729. } `json:"output"`
  20730. RefmsgTime string `json:"refmsg_time"`
  20731. RespondTime string `json:"respond_time"`
  20732. Signtype interface{} `json:"signtype"`
  20733. WarnMsg interface{} `json:"warn_msg"`
  20734. }
  20735. type ResultElevenah struct {
  20736. Cainfo string `json:"cainfo"`
  20737. ErrMsg string `json:"err_msg"`
  20738. InfRefmsgid string `json:"inf_refmsgid"`
  20739. Infcode int64 `json:"infcode"`
  20740. Output struct {
  20741. Setlinfo struct {
  20742. SetlTime int64 `json:"setl_time"`
  20743. CvlservPay float64 `json:"cvlserv_pay"`
  20744. Year string `json:"year"`
  20745. MedType string `json:"med_type"`
  20746. PsnPay float64 `json:"psn_pay"`
  20747. OpterID string `json:"opter_id"`
  20748. Begndate int64 `json:"begndate"`
  20749. FlxempeFlag string `json:"flxempe_flag"`
  20750. HifmiPay float64 `json:"hifmi_pay"`
  20751. PsnNo string `json:"psn_no"`
  20752. ActPayDedc float64 `json:"act_pay_dedc"`
  20753. MedinsSetlID interface{} `json:"medins_setl_id"`
  20754. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  20755. ClrWay string `json:"clr_way"`
  20756. OthPay float64 `json:"oth_pay"`
  20757. Gend string `json:"gend"`
  20758. MdtrtID string `json:"mdtrt_id"`
  20759. AcctPay float64 `json:"acct_pay"`
  20760. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20761. Insutype string `json:"insutype"`
  20762. Invono interface{} `json:"invono"`
  20763. Enddate int64 `json:"enddate"`
  20764. CashPayamt float64 `json:"cash_payamt"`
  20765. PsnType string `json:"psn_type"`
  20766. FixmedinsName string `json:"fixmedins_name"`
  20767. HifpPay float64 `json:"hifp_pay"`
  20768. NewFlag interface{} `json:"new_flag"`
  20769. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20770. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20771. PayLoc string `json:"pay_loc"`
  20772. ClrType string `json:"clr_type"`
  20773. RefdSetlFlag string `json:"refd_setl_flag"`
  20774. CvlservFlag string `json:"cvlserv_flag"`
  20775. EmpName string `json:"emp_name"`
  20776. Brdy int64 `json:"brdy"`
  20777. Naty string `json:"naty"`
  20778. Certno string `json:"certno"`
  20779. DiseCode string `json:"dise_code"`
  20780. FixmedinsCode string `json:"fixmedins_code"`
  20781. DedcHospLv string `json:"dedc_hosp_lv"`
  20782. OpterName string `json:"opter_name"`
  20783. Balc float64 `json:"balc"`
  20784. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  20785. PsnCertType string `json:"psn_cert_type"`
  20786. HifobPay float64 `json:"hifob_pay"`
  20787. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20788. HifesPay float64 `json:"hifes_pay"`
  20789. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20790. OptTime int64 `json:"opt_time"`
  20791. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20792. SetlID string `json:"setl_id"`
  20793. MafPay float64 `json:"maf_pay"`
  20794. PsnName string `json:"psn_name"`
  20795. InsuOptins interface{} `json:"insu_optins"`
  20796. PrefFundPay interface{} `json:"pref_fund_pay"`
  20797. ClrOptins string `json:"clr_optins"`
  20798. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  20799. DiseName string `json:"dise_name"`
  20800. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  20801. Age float64 `json:"age"`
  20802. DtrtCertType string `json:"dtrt_cert_type"`
  20803. HospLv string `json:"hosp_lv"`
  20804. PsnCashPay float64 `json:"psn_cash_pay"`
  20805. } `json:"setlinfo"`
  20806. } `json:"output"`
  20807. RefmsgTime string `json:"refmsg_time"`
  20808. RespondTime string `json:"respond_time"`
  20809. Signtype interface{} `json:"signtype"`
  20810. WarnMsg interface{} `json:"warn_msg"`
  20811. }
  20812. type ResultEleven10265 struct {
  20813. Cainfo string `json:"cainfo"`
  20814. ErrMsg string `json:"err_msg"`
  20815. InfRefmsgid string `json:"inf_refmsgid"`
  20816. Infcode string `json:"infcode"`
  20817. Output struct {
  20818. Setlinfo struct {
  20819. SetlTime string `json:"setl_time"`
  20820. CvlservPay float64 `json:"cvlserv_pay"`
  20821. Year string `json:"year"`
  20822. MedType string `json:"med_type"`
  20823. PsnPay float64 `json:"psn_pay"`
  20824. OpterID string `json:"opter_id"`
  20825. Begndate string `json:"begndate"`
  20826. FlxempeFlag string `json:"flxempe_flag"`
  20827. HifmiPay float64 `json:"hifmi_pay"`
  20828. PsnNo string `json:"psn_no"`
  20829. ActPayDedc float64 `json:"act_pay_dedc"`
  20830. MedinsSetlID interface{} `json:"medins_setl_id"`
  20831. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  20832. ClrWay string `json:"clr_way"`
  20833. OthPay float64 `json:"oth_pay"`
  20834. Gend string `json:"gend"`
  20835. MdtrtID string `json:"mdtrt_id"`
  20836. AcctPay float64 `json:"acct_pay"`
  20837. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20838. Insutype string `json:"insutype"`
  20839. Invono interface{} `json:"invono"`
  20840. Enddate string `json:"enddate"`
  20841. CashPayamt float64 `json:"cash_payamt"`
  20842. PsnType string `json:"psn_type"`
  20843. FixmedinsName string `json:"fixmedins_name"`
  20844. HifpPay float64 `json:"hifp_pay"`
  20845. NewFlag interface{} `json:"new_flag"`
  20846. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20847. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20848. PayLoc string `json:"pay_loc"`
  20849. ClrType string `json:"clr_type"`
  20850. RefdSetlFlag string `json:"refd_setl_flag"`
  20851. CvlservFlag string `json:"cvlserv_flag"`
  20852. EmpName string `json:"emp_name"`
  20853. Brdy string `json:"brdy"`
  20854. Naty string `json:"naty"`
  20855. Certno string `json:"certno"`
  20856. DiseCode string `json:"dise_code"`
  20857. FixmedinsCode string `json:"fixmedins_code"`
  20858. DedcHospLv string `json:"dedc_hosp_lv"`
  20859. OpterName string `json:"opter_name"`
  20860. Balc float64 `json:"balc"`
  20861. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  20862. PsnCertType string `json:"psn_cert_type"`
  20863. HifobPay float64 `json:"hifob_pay"`
  20864. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20865. HifesPay float64 `json:"hifes_pay"`
  20866. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20867. OptTime string `json:"opt_time"`
  20868. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20869. SetlID string `json:"setl_id"`
  20870. MafPay float64 `json:"maf_pay"`
  20871. PsnName string `json:"psn_name"`
  20872. InsuOptins interface{} `json:"insu_optins"`
  20873. PrefFundPay interface{} `json:"pref_fund_pay"`
  20874. ClrOptins string `json:"clr_optins"`
  20875. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  20876. DiseName string `json:"dise_name"`
  20877. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  20878. Age float64 `json:"age"`
  20879. DtrtCertType string `json:"dtrt_cert_type"`
  20880. HospLv string `json:"hosp_lv"`
  20881. PsnCashPay float64 `json:"psn_cash_pay"`
  20882. } `json:"setlinfo"`
  20883. } `json:"output"`
  20884. RefmsgTime string `json:"refmsg_time"`
  20885. RespondTime string `json:"respond_time"`
  20886. Signtype interface{} `json:"signtype"`
  20887. WarnMsg interface{} `json:"warn_msg"`
  20888. }
  20889. type ResultTwelve struct {
  20890. Cainfo string `json:"cainfo"`
  20891. ErrMsg string `json:"err_msg"`
  20892. InfRefmsgid string `json:"inf_refmsgid"`
  20893. Infcode int64 `json:"infcode"`
  20894. Output struct {
  20895. MdtrtId string `json:"mdtrt_id"`
  20896. ChrgBchno string `json:"chrg_bchno"`
  20897. PsnNo string `json:"psn_no"`
  20898. } `json:"output"`
  20899. RefmsgTime string `json:"refmsg_time"`
  20900. RespondTime string `json:"respond_time"`
  20901. Signtype interface{} `json:"signtype"`
  20902. WarnMsg interface{} `json:"warn_msg"`
  20903. }
  20904. type ResultThirteen struct {
  20905. ErrMsg string `json:"err_msg"`
  20906. InfRefmsgid string `json:"inf_refmsgid"`
  20907. Infcode int64 `json:"infcode"`
  20908. Output struct {
  20909. Result struct {
  20910. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  20911. } `json:"result"`
  20912. } `json:"output"`
  20913. RefmsgTime string `json:"refmsg_time"`
  20914. RespondTime string `json:"respond_time"`
  20915. Signtype interface{} `json:"signtype"`
  20916. WarnInfo interface{} `json:"warn_info"`
  20917. }
  20918. type ResultThirteen10265 struct {
  20919. ErrMsg string `json:"err_msg"`
  20920. InfRefmsgid string `json:"inf_refmsgid"`
  20921. Infcode string `json:"infcode"`
  20922. Output struct {
  20923. Result struct {
  20924. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  20925. } `json:"result"`
  20926. } `json:"output"`
  20927. RefmsgTime string `json:"refmsg_time"`
  20928. RespondTime string `json:"respond_time"`
  20929. Signtype interface{} `json:"signtype"`
  20930. WarnInfo interface{} `json:"warn_info"`
  20931. }
  20932. type ResultFourteen struct {
  20933. ErrMsg string `json:"err_msg"`
  20934. InfRefmsgid string `json:"inf_refmsgid"`
  20935. Infcode int64 `json:"infcode"`
  20936. Output struct {
  20937. } `json:"output"`
  20938. RefmsgTime string `json:"refmsg_time"`
  20939. RespondTime string `json:"respond_time"`
  20940. Signtype interface{} `json:"signtype"`
  20941. WarnInfo interface{} `json:"warn_info"`
  20942. }
  20943. type ResultCFYLJG001 struct {
  20944. ErrMsg string `json:"err_msg"`
  20945. InfRefmsgid string `json:"inf_refmsgid"`
  20946. Infcode int64 `json:"infcode"`
  20947. Output struct {
  20948. RxTraceCode string `json:"rx_trace_code"`
  20949. HiRxno string `json:"hi_rxno"`
  20950. } `json:"output"`
  20951. RefmsgTime string `json:"refmsg_time"`
  20952. RespondTime string `json:"respond_time"`
  20953. Signtype interface{} `json:"signtype"`
  20954. WarnInfo interface{} `json:"warn_info"`
  20955. }
  20956. type ResultCFYLJG007 struct {
  20957. ErrMsg string `json:"err_msg"`
  20958. InfRefmsgid string `json:"inf_refmsgid"`
  20959. Infcode int64 `json:"infcode"`
  20960. Output struct {
  20961. HiRxno string `json:"hi_rxno"`
  20962. RxStasName string `json:"rx_stas_name"`
  20963. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  20964. Seltdelts []interface{} `json:"seltdelts"`
  20965. RxUsedStasName string `json:"rx_used_stas_name"`
  20966. RxStasCodg string `json:"rx_stas_codg"`
  20967. } `json:"output"`
  20968. RefmsgTime string `json:"refmsg_time"`
  20969. RespondTime string `json:"respond_time"`
  20970. Signtype interface{} `json:"signtype"`
  20971. WarnInfo interface{} `json:"warn_info"`
  20972. }
  20973. type ResultCFYLJG002 struct {
  20974. ErrMsg string `json:"err_msg"`
  20975. InfRefmsgid string `json:"inf_refmsgid"`
  20976. Infcode int64 `json:"infcode"`
  20977. Output struct {
  20978. RxFile string `json:"rx_file"`
  20979. SignDigest string `json:"sign_digest"`
  20980. SignCertSn string `json:"sign_cert_sn"`
  20981. SignCertDn string `json:"sign_cert_dn"`
  20982. } `json:"output"`
  20983. RefmsgTime string `json:"refmsg_time"`
  20984. RespondTime string `json:"respond_time"`
  20985. Signtype interface{} `json:"signtype"`
  20986. WarnInfo interface{} `json:"warn_info"`
  20987. }
  20988. type ResultCFYLJG003 struct {
  20989. ErrMsg string `json:"err_msg"`
  20990. InfRefmsgid string `json:"inf_refmsgid"`
  20991. Infcode int64 `json:"infcode"`
  20992. Output struct {
  20993. HiRxno string `json:"hi_rxno"`
  20994. RxStasCodg string `json:"rx_stas_codg"`
  20995. RxStasName string `json:"rx_stas_name"`
  20996. } `json:"output"`
  20997. RefmsgTime string `json:"refmsg_time"`
  20998. RespondTime string `json:"respond_time"`
  20999. Signtype interface{} `json:"signtype"`
  21000. WarnInfo interface{} `json:"warn_info"`
  21001. }
  21002. type ResultCFYLJG004 struct {
  21003. ErrMsg string `json:"err_msg"`
  21004. InfRefmsgid string `json:"inf_refmsgid"`
  21005. Infcode int64 `json:"infcode"`
  21006. Output struct {
  21007. HiRxno string `json:"hi_rxno"`
  21008. RxStasCodg string `json:"rx_stas_codg"`
  21009. RxStasName string `json:"rx_stas_name"`
  21010. } `json:"output"`
  21011. RefmsgTime string `json:"refmsg_time"`
  21012. RespondTime string `json:"respond_time"`
  21013. Signtype interface{} `json:"signtype"`
  21014. WarnInfo interface{} `json:"warn_info"`
  21015. }
  21016. type ResultCFYLJG008 struct {
  21017. ErrMsg string `json:"err_msg"`
  21018. InfRefmsgid string `json:"inf_refmsgid"`
  21019. Infcode int64 `json:"infcode"`
  21020. Output struct {
  21021. PoolareaNo string `json:"poolareaNo"`
  21022. AdmdvsName string `json:"admdvsName"`
  21023. Count string `json:"count"`
  21024. } `json:"output"`
  21025. RefmsgTime string `json:"refmsg_time"`
  21026. RespondTime string `json:"respond_time"`
  21027. Signtype interface{} `json:"signtype"`
  21028. WarnInfo interface{} `json:"warn_info"`
  21029. }
  21030. type ResultCFYLJG005 struct {
  21031. ErrMsg string `json:"err_msg"`
  21032. InfRefmsgid string `json:"inf_refmsgid"`
  21033. Infcode int64 `json:"infcode"`
  21034. Output struct {
  21035. HiRxNo string `json:"hi_rxno"`
  21036. FixMedinsCode string `json:"fixmedins_code"`
  21037. FixMedinsName string `json:"fixmedins_name"`
  21038. RxStasCodg string `json:"rx_stas_codg"`
  21039. RxStasName string `json:"rx_stas_name"`
  21040. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  21041. RxUserdStasName string `json:"rx_userd_stas_name"`
  21042. PrscTime string `json:"prsc_time"`
  21043. RxDrugCnt float64 `json:"rx_drug_cnt"`
  21044. RxUsedWayCodg string `json:"rx_used_way_codg"`
  21045. RxUsedWayName string `json:"rx_used_way_name"`
  21046. RxFrquCodg string `json:"rx_frqu_codg"`
  21047. RxFrquName string `json:"rx_frqu_name"`
  21048. RxDosunt string `json:"rx_dosunt"`
  21049. RxDoscnt float64 `json:"rx_doscnt"`
  21050. RxDrordDscr string `json:"rx_drord_dscr"`
  21051. ValiDays int64 `json:"vali_days"`
  21052. ValiEndTime string `json:"vali_end_time"`
  21053. ReptFlag string `json:"rept_flag"`
  21054. MaxReptCnt int64 `json:"max_rept_cnt"`
  21055. ReptdCnt int64 `json:"reptd_cnt"`
  21056. MinInrvDays int64 `json:"min_inrv_days"`
  21057. RxTypeCode string `json:"rx_type_code"`
  21058. RxTypeName string `json:"rx_type_name"`
  21059. LongRxFlag string `json:"long_rx_flag"`
  21060. RxDetlList []struct {
  21061. MedListCodg string `json:"med_list_codg"`
  21062. MedinsListCodg string `json:"medins_list_codg"`
  21063. HospPrepFlag string `json:"hosp_prep_flag"`
  21064. RxItemTypeCode string `json:"rx_item_type_code"`
  21065. RxItemTypeName string `json:"rx_item_type_name"`
  21066. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  21067. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  21068. TcmHerbFoote string `json:"tcmherb_foote"`
  21069. MednTypeCode string `json:"medn_type_code"`
  21070. MednTypeName string `json:"medn_type_name"`
  21071. MainMedcFlag string `json:"main_medc_flag"`
  21072. UrgtFlag string `json:"urgt_flag"`
  21073. BasMednFlag string `json:"bas_medn_flag"`
  21074. ImpDrugFlag string `json:"imp_drug_flag"`
  21075. ProdBarc string `json:"prod_barc"`
  21076. DrugProdname string `json:"drug_prodname"`
  21077. GennameCodg string `json:"genname_codg"`
  21078. DrugGenname string `json:"drug_genname"`
  21079. DrugDosform string `json:"drug_dosform"`
  21080. DrugSpec string `json:"drug_spec"`
  21081. PrdrName string `json:"prdr_name"`
  21082. MedcWayCodg string `json:"medc_way_codg"`
  21083. MedcWayDscr string `json:"medc_way_dscr"`
  21084. MedcBegntime string `json:"medc_begntime"`
  21085. MedcEndtime string `json:"medc_endtime"`
  21086. MedcDays float64 `json:"medc_days"`
  21087. DrugPric float64 `json:"drug_pric"`
  21088. DrugSumamt float64 `json:"drug_sumamt"`
  21089. DrugCnt float64 `json:"drug_cnt"`
  21090. DrugDosunt string `json:"drug_dosunt"`
  21091. SinDoscnt float64 `json:"sin_doscnt"`
  21092. SinDosunt string `json:"sin_dosunt"`
  21093. UsedFrquCodg string `json:"used_frqu_codg"`
  21094. UsedFrquName string `json:"used_frqu_name"`
  21095. DrugTotlcnt string `json:"drug_totlcnt"`
  21096. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  21097. DiseCodg string `json:"dise_codg"`
  21098. HospApprFlag string `json:"hosp_appr_flag"`
  21099. } `json:"rx_detl_list"`
  21100. RxOtpinfo struct {
  21101. MedType string `json:"med_type"`
  21102. IptOtpNo string `json:"ipt_otp_no"`
  21103. OtpIptFlag string `json:"otp_ipt_flag"`
  21104. PatnName string `json:"patn_name"`
  21105. PatnAge float64 `json:"patn_age"`
  21106. PatnHgt float64 `json:"patn_hgt"`
  21107. PatnWt float64 `json:"patn_wt"`
  21108. Gend string `json:"gend"`
  21109. GesoVal float64 `json:"geso_val"`
  21110. NwbFlag string `json:"nwb_flag"`
  21111. NwbAge string `json:"nwb_age"`
  21112. SuckPrdFlag string `json:"suck_prd_flag"`
  21113. AlgsHis string `json:"algs_his"`
  21114. Insutype string `json:"insutype"`
  21115. PrscDeptName string `json:"prsc_dept_name"`
  21116. PrscDrName string `json:"prsc_dr_name"`
  21117. PharName string `json:"phar_name"`
  21118. PharChkTime string `json:"phar_chk_time"`
  21119. MdtrtTime string `json:"mdtrt_time"`
  21120. DiseCodg string `json:"dise_codg"`
  21121. DiseName string `json:"dise_name"`
  21122. SpDiseFlag string `json:"sp_dise_flag"`
  21123. MaindiagCode string `json:"maindiag_code"`
  21124. MaindiagName string `json:"maindiag_name"`
  21125. DiseCondDscr string `json:"dise_cond_dscr"`
  21126. FstdiagFlag string `json:"fstdiag_flag"`
  21127. } `json:"rx_otpinfo"`
  21128. RxDiseList []struct {
  21129. DiagType string `json:"diag_type"`
  21130. MaindiagFlag string `json:"maindiag_flag"`
  21131. DiagSrtNo string `json:"diag_srt_no"`
  21132. DiagCode string `json:"diag_code"`
  21133. DiagName string `json:"diag_name"`
  21134. DiagDept string `json:"diag_dept"`
  21135. DiagDrNo string `json:"diag_dr_no"`
  21136. DiagDrName string `json:"diag_dr_name"`
  21137. DiagTime string `json:"diag_time"`
  21138. TcmDiseCode string `json:"tcm_dise_code"`
  21139. TcmDiseName string `json:"tcm_dise_name"`
  21140. TcmSympCode string `json:"tcmsymp_code"`
  21141. TcmSymp string `json:"tcmsymp"`
  21142. } `json:"rx_dise_list"`
  21143. } `json:"output"`
  21144. RefmsgTime string `json:"refmsg_time"`
  21145. RespondTime string `json:"respond_time"`
  21146. Signtype interface{} `json:"signtype"`
  21147. WarnInfo interface{} `json:"warn_info"`
  21148. }
  21149. type ResultCFYLJG006 struct {
  21150. ErrMsg string `json:"err_msg"`
  21151. InfRefmsgid string `json:"inf_refmsgid"`
  21152. Infcode int64 `json:"infcode"`
  21153. Output struct {
  21154. HiRxNo string `json:"hi_rxno"`
  21155. PharCode string `json:"phar_code"`
  21156. PharName string `json:"phar_name"`
  21157. RxChkOpnn string `json:"rx_chk_opnn"`
  21158. RxChkTime string `json:"rx_chk_time"`
  21159. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  21160. RxChkStasName string `json:"rx_chk_stas_name"`
  21161. RxStasCodg string `json:"rx_stas_codg"`
  21162. RxStasName string `json:"rx_stas_name"`
  21163. } `json:"output"`
  21164. RefmsgTime string `json:"refmsg_time"`
  21165. RespondTime string `json:"respond_time"`
  21166. Signtype interface{} `json:"signtype"`
  21167. WarnInfo interface{} `json:"warn_info"`
  21168. }
  21169. type ResultFourteen10265 struct {
  21170. ErrMsg string `json:"err_msg"`
  21171. InfRefmsgid string `json:"inf_refmsgid"`
  21172. Infcode string `json:"infcode"`
  21173. Output struct {
  21174. } `json:"output"`
  21175. RefmsgTime string `json:"refmsg_time"`
  21176. RespondTime string `json:"respond_time"`
  21177. Signtype interface{} `json:"signtype"`
  21178. WarnInfo interface{} `json:"warn_info"`
  21179. }
  21180. type ResultSixteen struct {
  21181. Cainfo string `json:"cainfo"`
  21182. ErrMsg string `json:"err_msg"`
  21183. InfRefmsgid string `json:"inf_refmsgid"`
  21184. Infcode int64 `json:"infcode"`
  21185. Output struct {
  21186. Setlinfo struct {
  21187. MdtrtID string `json:"mdtrt_id"`
  21188. SetlID string `json:"setl_id"`
  21189. ClrOptins string `json:"clr_optins"`
  21190. SetlTime string `json:"setl_time"`
  21191. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21192. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21193. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21194. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21195. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21196. ActPayDedc float64 `json:"act_pay_dedc"`
  21197. HifpPay float64 `json:"hifp_pay"`
  21198. PoolPropSe float64 `json:"pool_prop_selfpay"`
  21199. Lfpay float64 `json:"selfpay"`
  21200. CvlservPay float64 `json:"cvlserv_pay"`
  21201. HifesPay float64 `json:"hifes_pay"`
  21202. HifmiPay float64 `json:"hifmi_pay"`
  21203. HifobPay float64 `json:"hifob_pay"`
  21204. MafPay float64 `json:"maf_pay"`
  21205. OthPay float64 `json:"oth_pay"`
  21206. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21207. PsnPartAmt float64 `json:"psn_part_amt"`
  21208. AcctPay float64 `json:"acct_pay"`
  21209. Balc float64 `json:"balc"`
  21210. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21211. HospPartAmt float64 `json:"hosp_part_amt"`
  21212. MedinsSetlID string `json:"medins_setl_id"`
  21213. PdnCashPay string `json:"pdn_cash_pay"`
  21214. } `json:"setlinfo"`
  21215. } `json:"output"`
  21216. RefmsgTime string `json:"refmsg_time"`
  21217. RespondTime string `json:"respond_time"`
  21218. Signtype interface{} `json:"signtype"`
  21219. WarnMsg interface{} `json:"warn_msg"`
  21220. }
  21221. type ResultSixteen10265 struct {
  21222. Cainfo string `json:"cainfo"`
  21223. ErrMsg string `json:"err_msg"`
  21224. InfRefmsgid string `json:"inf_refmsgid"`
  21225. Infcode string `json:"infcode"`
  21226. Output struct {
  21227. Setlinfo struct {
  21228. MdtrtID string `json:"mdtrt_id"`
  21229. SetlID string `json:"setl_id"`
  21230. ClrOptins string `json:"clr_optins"`
  21231. SetlTime string `json:"setl_time"`
  21232. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21233. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21234. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21235. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21236. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21237. ActPayDedc float64 `json:"act_pay_dedc"`
  21238. HifpPay float64 `json:"hifp_pay"`
  21239. PoolPropSe float64 `json:"pool_prop_selfpay"`
  21240. Lfpay float64 `json:"selfpay"`
  21241. CvlservPay float64 `json:"cvlserv_pay"`
  21242. HifesPay float64 `json:"hifes_pay"`
  21243. HifmiPay float64 `json:"hifmi_pay"`
  21244. HifobPay float64 `json:"hifob_pay"`
  21245. MafPay float64 `json:"maf_pay"`
  21246. OthPay float64 `json:"oth_pay"`
  21247. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21248. PsnPartAmt float64 `json:"psn_part_amt"`
  21249. AcctPay float64 `json:"acct_pay"`
  21250. Balc float64 `json:"balc"`
  21251. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21252. HospPartAmt float64 `json:"hosp_part_amt"`
  21253. MedinsSetlID string `json:"medins_setl_id"`
  21254. PdnCashPay string `json:"pdn_cash_pay"`
  21255. } `json:"setlinfo"`
  21256. } `json:"output"`
  21257. RefmsgTime string `json:"refmsg_time"`
  21258. RespondTime string `json:"respond_time"`
  21259. Signtype interface{} `json:"signtype"`
  21260. WarnMsg interface{} `json:"warn_msg"`
  21261. }
  21262. type ResultSixteen10265Two struct {
  21263. Cainfo string `json:"cainfo"`
  21264. ErrMsg string `json:"err_msg"`
  21265. InfRefmsgid string `json:"inf_refmsgid"`
  21266. Infcode string `json:"infcode"`
  21267. Output struct {
  21268. Setlinfo interface{} `json:"setlinfo"`
  21269. } `json:"output"`
  21270. RefmsgTime string `json:"refmsg_time"`
  21271. RespondTime string `json:"respond_time"`
  21272. Signtype interface{} `json:"signtype"`
  21273. WarnMsg interface{} `json:"warn_msg"`
  21274. }
  21275. type ResultgzSixteen10265Two struct {
  21276. Cainfo string `json:"cainfo"`
  21277. ErrMsg string `json:"err_msg"`
  21278. InfRefmsgid string `json:"inf_refmsgid"`
  21279. Infcode int64 `json:"infcode"`
  21280. Output struct {
  21281. Setlinfo interface{} `json:"setlinfo"`
  21282. } `json:"output"`
  21283. RefmsgTime string `json:"refmsg_time"`
  21284. RespondTime string `json:"respond_time"`
  21285. Signtype interface{} `json:"signtype"`
  21286. WarnMsg interface{} `json:"warn_msg"`
  21287. }
  21288. type ResultSeventeen struct {
  21289. ErrMsg string `json:"err_msg"`
  21290. InfRefmsgid string `json:"inf_refmsgid"`
  21291. Infcode int64 `json:"infcode"`
  21292. Output struct {
  21293. SetlListId string `json:"setl_list_id"`
  21294. } `json:"output"`
  21295. RefmsgTime string `json:"refmsg_time"`
  21296. RespondTime string `json:"respond_time"`
  21297. Signtype string `json:"signtype"`
  21298. WarnInfo string `json:"warn_info"`
  21299. }
  21300. type ResultSeventeenOther struct {
  21301. ErrMsg string `json:"err_msg"`
  21302. InfRefmsgid string `json:"inf_refmsgid"`
  21303. Infcode string `json:"infcode"`
  21304. Output struct {
  21305. SetlListId string `json:"setl_list_id"`
  21306. } `json:"output"`
  21307. RefmsgTime string `json:"refmsg_time"`
  21308. RespondTime string `json:"respond_time"`
  21309. Signtype string `json:"signtype"`
  21310. WarnInfo string `json:"warn_info"`
  21311. }
  21312. type Result90991 struct {
  21313. ErrMsg string `json:"err_msg"`
  21314. InfRefmsgid string `json:"inf_refmsgid"`
  21315. Infcode int64 `json:"infcode"`
  21316. Output struct {
  21317. Result struct {
  21318. PsnNo string `json:"psn_no"`
  21319. CardStat string `json:"card_stat"`
  21320. Certno string `json:"certno"`
  21321. PsnName string `json:"psn_name"`
  21322. CheckStat string `json:"check_stat"`
  21323. SscnoCheckStat string `json:"sscno_check_stat"`
  21324. } `json:"result"`
  21325. } `json:"output"`
  21326. RefmsgTime string `json:"refmsg_time"`
  21327. RespondTime string `json:"respond_time"`
  21328. Signtype interface{} `json:"signtype"`
  21329. WarnInfo interface{} `json:"warn_info"`
  21330. }
  21331. type Result90100 struct {
  21332. ErrMsg string `json:"err_msg"`
  21333. InfRefmsgid string `json:"inf_refmsgid"`
  21334. Infcode int64 `json:"infcode"`
  21335. Output struct {
  21336. PoolareaNo string `json:"poolarea_no"`
  21337. PoolareaNoName string `json:"poolarea_no_name"`
  21338. Insutype string `json:"insutype"`
  21339. InsutypeName string `json:"insutype_name"`
  21340. ClctType string `json:"clct_type"`
  21341. ClctTypeName string `json:"clct_type_name"`
  21342. ClctFlag string `json:"clct_flag"`
  21343. ClctFlagName string `json:"clct_flag_name"`
  21344. AccrymBegn string `json:"accrym_begn"`
  21345. AccrymEnd string `json:"accrym_end"`
  21346. ClctTime string `json:"clct_time"`
  21347. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  21348. } `json:"output"`
  21349. RefmsgTime string `json:"refmsg_time"`
  21350. RespondTime string `json:"respond_time"`
  21351. Signtype interface{} `json:"signtype"`
  21352. WarnInfo interface{} `json:"warn_info"`
  21353. }
  21354. type Custom struct {
  21355. DetItemFeeSumamt string
  21356. Cut string
  21357. FeedetlSn string
  21358. Price string
  21359. MedListCodg string
  21360. Type int64
  21361. AdviceId int64
  21362. ProjectId int64
  21363. ItemId int64
  21364. }
  21365. type Result5301 struct {
  21366. ErrMsg string `json:"err_msg"`
  21367. InfRefmsgid string `json:"inf_refmsgid"`
  21368. Infcode int64 `json:"infcode"`
  21369. Output struct {
  21370. Result []struct {
  21371. OpspDiseCode string `json:"opsp_dise_code"`
  21372. OpspDiseName string `json:"opsp_dise_name"`
  21373. Begndate string `json:"begndate"`
  21374. Enddate string `json:"enddate"`
  21375. } `json:"feedetail"`
  21376. } `json:"output"`
  21377. RefmsgTime string `json:"refmsg_time"`
  21378. RespondTime string `json:"respond_time"`
  21379. Signtype interface{} `json:"signtype"`
  21380. WarnInfo interface{} `json:"warn_info"`
  21381. }
  21382. type Result5301For10265 struct {
  21383. ErrMsg string `json:"err_msg"`
  21384. InfRefmsgid string `json:"inf_refmsgid"`
  21385. Infcode string `json:"infcode"`
  21386. Output struct {
  21387. Result []struct {
  21388. OpspDiseCode string `json:"opsp_dise_code"`
  21389. OpspDiseName string `json:"opsp_dise_name"`
  21390. Begndate string `json:"begndate"`
  21391. Enddate string `json:"enddate"`
  21392. } `json:"feedetail"`
  21393. } `json:"output"`
  21394. RefmsgTime string `json:"refmsg_time"`
  21395. RespondTime string `json:"respond_time"`
  21396. Signtype interface{} `json:"signtype"`
  21397. WarnInfo interface{} `json:"warn_info"`
  21398. }
  21399. //获取个人信息----挂号-----上传就诊信息
  21400. func (c *HisApiController) GetRegisterInfo() {
  21401. id, _ := c.GetInt64("id")
  21402. record_time := c.GetString("record_time")
  21403. settlementValue, _ := c.GetInt64("settlement_value")
  21404. medical_insurance_card := c.GetString("medical_insurance_card")
  21405. name := c.GetString("name")
  21406. id_card_type, _ := c.GetInt64("id_card_type")
  21407. certificates, _ := c.GetInt64("certificates")
  21408. medical_care, _ := c.GetInt64("medical_care")
  21409. birthday := c.GetString("birthday")
  21410. id_card := c.GetString("id_card")
  21411. register_type, _ := c.GetInt64("register")
  21412. doctor, _ := c.GetInt64("doctor")
  21413. department, _ := c.GetInt64("department")
  21414. gender, _ := c.GetInt64("sex")
  21415. registration_fee, _ := c.GetFloat("registration_fee")
  21416. medical_expenses, _ := c.GetFloat("medical_expenses")
  21417. social_type, _ := c.GetInt64("social_type")
  21418. admin_user_id, _ := c.GetInt64("admin_user_id")
  21419. insuplc_admdvs := c.GetString("insuplc_admdvs")
  21420. mdtrt_type := c.GetString("mdtrt_type")
  21421. if id_card_type == 5 {
  21422. id_card_type = 4
  21423. }
  21424. timeLayout := "2006-01-02"
  21425. loc, _ := time.LoadLocation("Local")
  21426. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  21427. birthUnix := birthdays.Unix()
  21428. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  21429. if err != nil {
  21430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21431. return
  21432. }
  21433. recordDateTime := theTime.Unix()
  21434. adminInfo := c.GetAdminUserInfo()
  21435. var patient service.Patients
  21436. if id == 0 {
  21437. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  21438. } else {
  21439. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  21440. }
  21441. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  21442. if patientPrescription.ID == 0 {
  21443. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  21444. }
  21445. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  21446. if patient.ID == 0 {
  21447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  21448. return
  21449. }
  21450. if len(patient.IdCardNo) == 0 {
  21451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  21452. return
  21453. }
  21454. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  21455. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  21456. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  21457. //就诊结算未完成,不能进行二次挂号
  21458. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  21459. if len(his) >= 1 {
  21460. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  21461. if len(his) >= 1 && order.ID == 0 {
  21462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  21463. return
  21464. }
  21465. }
  21466. //var register_log string
  21467. if config.IsOpen == 1 {
  21468. var res ResultTwo
  21469. var res10265 ResultTwo10265
  21470. var PsnNo string
  21471. var PsnCertType string
  21472. var Certno string
  21473. var PsnName string
  21474. var Gend string
  21475. var Naty string
  21476. var Brdy string
  21477. var Age float64
  21478. var infoStr string
  21479. var idetinfoStr string
  21480. var infocode int64
  21481. var verify_number string
  21482. fmt.Println(verify_number)
  21483. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  21484. psn_info, _ := service.GetPsnByPatientId(id)
  21485. PsnNo = psn_info.PsnNo
  21486. PsnCertType = psn_info.PsnCertType
  21487. Certno = psn_info.Certno
  21488. PsnName = psn_info.PsnName
  21489. Gend = psn_info.Gend
  21490. Naty = psn_info.Naty
  21491. Brdy = psn_info.Brdy
  21492. Age = psn_info.Age
  21493. infoStr = psn_info.Insuinfo
  21494. idetinfoStr = psn_info.Idetinfo
  21495. infocode = 0
  21496. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21497. psn_info, _ := service.GetPsnByPatientId(id)
  21498. PsnNo = psn_info.PsnNo
  21499. PsnCertType = psn_info.PsnCertType
  21500. Certno = psn_info.Certno
  21501. PsnName = psn_info.PsnName
  21502. Gend = psn_info.Gend
  21503. Naty = psn_info.Naty
  21504. Brdy = psn_info.Brdy
  21505. Age = psn_info.Age
  21506. infoStr = psn_info.Insuinfo
  21507. idetinfoStr = psn_info.Idetinfo
  21508. infocode = 0
  21509. verify_number = psn_info.VerifyNumber
  21510. } else if miConfig.MdtrtareaAdmvs == "150499" {
  21511. if id_card_type == 2 {
  21512. //请求内网数据
  21513. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  21514. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21515. "&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
  21516. resp, requestErr := http.Get(api)
  21517. if requestErr != nil {
  21518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21519. return
  21520. }
  21521. body, ioErr := ioutil.ReadAll(resp.Body)
  21522. if ioErr != nil {
  21523. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21525. return
  21526. }
  21527. var respJSON map[string]interface{}
  21528. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21531. return
  21532. }
  21533. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21534. result_byte, _ := json.Marshal(respJSON)
  21535. result := string(result_byte)
  21536. var dat map[string]interface{}
  21537. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21538. fmt.Println(dat)
  21539. } else {
  21540. fmt.Println(err)
  21541. }
  21542. userJSONBytes, _ := json.Marshal(dat)
  21543. var res ResultTwo
  21544. var resTwo10265 ResultTwo10265
  21545. if miConfig.Code == "H15049901371" {
  21546. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  21547. utils.ErrorLog("解析失败:%v", err)
  21548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21549. return
  21550. }
  21551. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  21552. res.Infcode = Infcode
  21553. res.ErrMsg = resTwo10265.ErrMsg
  21554. res.Output = resTwo10265.Output
  21555. res.InfRefmsgid = resTwo10265.InfRefmsgid
  21556. res.RespondTime = resTwo10265.RespondTime
  21557. res.WarnInfo = resTwo10265.WarnInfo
  21558. } else {
  21559. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21560. utils.ErrorLog("解析失败:%v", err)
  21561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21562. return
  21563. }
  21564. }
  21565. //var insutypes []string
  21566. //var insutype string
  21567. //var is390 int = 0
  21568. //var is310 int = 0
  21569. //for _, item := range res.Output.Iinfo {
  21570. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  21571. // insutypes = append(insutypes, item.Insutype)
  21572. // }
  21573. //}
  21574. //if len(insutypes) == 1 {
  21575. // insutype = insutypes[0]
  21576. //} else {
  21577. // for _, i := range insutypes {
  21578. // if i == "390" {
  21579. // is390 = 1
  21580. // }
  21581. //
  21582. // if i == "310" {
  21583. // is310 = 1
  21584. // }
  21585. // }
  21586. //}
  21587. //if is390 == 1 {
  21588. // insutype = "390"
  21589. //}
  21590. //if is310 == 1 {
  21591. // insutype = "310"
  21592. //}
  21593. //if len(insutypes) == 0 {
  21594. // insutype = "310"
  21595. //}
  21596. PsnNo = res.Output.Baseinfo.PsnNo
  21597. PsnCertType = res.Output.Baseinfo.PsnCertType
  21598. Certno = res.Output.Baseinfo.Certno
  21599. PsnName = res.Output.Baseinfo.PsnName
  21600. Gend = res.Output.Baseinfo.Gend
  21601. Naty = res.Output.Baseinfo.Naty
  21602. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21603. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21604. infoStr = string(Iinfos)
  21605. idetinfoStr = string(Idetinfos)
  21606. infocode = res.Infcode
  21607. //infocode = 0
  21608. //verify_number = psn_info.VerifyNumber
  21609. } else {
  21610. psn_info, _ := service.GetPsnByPatientId(id)
  21611. PsnNo = psn_info.PsnNo
  21612. PsnCertType = psn_info.PsnCertType
  21613. Certno = psn_info.Certno
  21614. PsnName = psn_info.PsnName
  21615. Gend = psn_info.Gend
  21616. Naty = psn_info.Naty
  21617. Brdy = psn_info.Brdy
  21618. Age = psn_info.Age
  21619. infoStr = psn_info.Insuinfo
  21620. idetinfoStr = psn_info.Idetinfo
  21621. infocode = 0
  21622. verify_number = psn_info.VerifyNumber
  21623. }
  21624. } else if miConfig.MdtrtareaAdmvs == "350500" {
  21625. if id_card_type == 1 {
  21626. psn_info, _ := service.GetPsnByPatientId(id)
  21627. PsnNo = psn_info.PsnNo
  21628. PsnCertType = psn_info.PsnCertType
  21629. Certno = psn_info.Certno
  21630. PsnName = psn_info.PsnName
  21631. Gend = psn_info.Gend
  21632. Naty = psn_info.Naty
  21633. Brdy = psn_info.Brdy
  21634. Age = psn_info.Age
  21635. infoStr = psn_info.Insuinfo
  21636. idetinfoStr = psn_info.Idetinfo
  21637. infocode = 0
  21638. verify_number = psn_info.VerifyNumber
  21639. } else if id_card_type == 2 {
  21640. 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)
  21641. fmt.Println(errMsgLog)
  21642. saveLog(result, requestLog, "1101", "人员基本信息获取")
  21643. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21644. utils.ErrorLog("解析失败:%v", err)
  21645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21646. return
  21647. }
  21648. PsnNo = res.Output.Baseinfo.PsnNo
  21649. PsnCertType = res.Output.Baseinfo.PsnCertType
  21650. Certno = res.Output.Baseinfo.Certno
  21651. PsnName = res.Output.Baseinfo.PsnName
  21652. Gend = res.Output.Baseinfo.Gend
  21653. Naty = res.Output.Baseinfo.Naty
  21654. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21655. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21656. infoStr = string(Iinfos)
  21657. idetinfoStr = string(Idetinfos)
  21658. infocode = res.Infcode
  21659. }
  21660. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21661. if id_card_type == 1 {
  21662. psn_info, _ := service.GetPsnByPatientId(id)
  21663. PsnNo = psn_info.PsnNo
  21664. PsnCertType = psn_info.PsnCertType
  21665. Certno = psn_info.Certno
  21666. PsnName = psn_info.PsnName
  21667. Gend = psn_info.Gend
  21668. Naty = psn_info.Naty
  21669. Brdy = psn_info.Brdy
  21670. Age = psn_info.Age
  21671. infoStr = psn_info.Insuinfo
  21672. idetinfoStr = psn_info.Idetinfo
  21673. infocode = 0
  21674. verify_number = psn_info.VerifyNumber
  21675. } else if id_card_type == 2 {
  21676. 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, "")
  21677. saveLog(result, requestLog, "1101", "人员基本信息获取")
  21678. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21679. utils.ErrorLog("解析失败:%v", err)
  21680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21681. return
  21682. }
  21683. PsnNo = res.Output.Baseinfo.PsnNo
  21684. PsnCertType = res.Output.Baseinfo.PsnCertType
  21685. Certno = res.Output.Baseinfo.Certno
  21686. PsnName = res.Output.Baseinfo.PsnName
  21687. Gend = res.Output.Baseinfo.Gend
  21688. Naty = res.Output.Baseinfo.Naty
  21689. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21690. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21691. infoStr = string(Iinfos)
  21692. idetinfoStr = string(Idetinfos)
  21693. infocode = res.Infcode
  21694. } else {
  21695. psn_info, _ := service.GetPsnByPatientId(id)
  21696. PsnNo = psn_info.PsnNo
  21697. PsnCertType = psn_info.PsnCertType
  21698. Certno = psn_info.Certno
  21699. PsnName = psn_info.PsnName
  21700. Gend = psn_info.Gend
  21701. Naty = psn_info.Naty
  21702. Brdy = psn_info.Brdy
  21703. Age = psn_info.Age
  21704. infoStr = psn_info.Insuinfo
  21705. idetinfoStr = psn_info.Idetinfo
  21706. infocode = 0
  21707. verify_number = psn_info.VerifyNumber
  21708. }
  21709. } else if miConfig.MdtrtareaAdmvs == "341203" {
  21710. psn_info, _ := service.GetPsnByPatientId(id)
  21711. PsnNo = psn_info.PsnNo
  21712. PsnCertType = psn_info.PsnCertType
  21713. Certno = psn_info.Certno
  21714. PsnName = psn_info.PsnName
  21715. Gend = psn_info.Gend
  21716. Naty = psn_info.Naty
  21717. Brdy = psn_info.Brdy
  21718. Age = psn_info.Age
  21719. infoStr = psn_info.Insuinfo
  21720. idetinfoStr = psn_info.Idetinfo
  21721. infocode = 0
  21722. verify_number = psn_info.VerifyNumber
  21723. } else if miConfig.MdtrtareaAdmvs == "430800" {
  21724. if id_card_type == 1 {
  21725. psn_info, _ := service.GetPsnByPatientId(id)
  21726. PsnNo = psn_info.PsnNo
  21727. PsnCertType = psn_info.PsnCertType
  21728. Certno = psn_info.Certno
  21729. PsnName = psn_info.PsnName
  21730. Gend = psn_info.Gend
  21731. Naty = psn_info.Naty
  21732. Brdy = psn_info.Brdy
  21733. Age = psn_info.Age
  21734. infoStr = psn_info.Insuinfo
  21735. idetinfoStr = psn_info.Idetinfo
  21736. infocode = 0
  21737. verify_number = psn_info.VerifyNumber
  21738. } else if id_card_type == 2 {
  21739. 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)
  21740. saveLog(result, requestLog, "1101", "人员基本信息获取")
  21741. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21742. utils.ErrorLog("解析失败:%v", err)
  21743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21744. return
  21745. }
  21746. PsnNo = res.Output.Baseinfo.PsnNo
  21747. PsnCertType = res.Output.Baseinfo.PsnCertType
  21748. Certno = res.Output.Baseinfo.Certno
  21749. PsnName = res.Output.Baseinfo.PsnName
  21750. Gend = res.Output.Baseinfo.Gend
  21751. Naty = res.Output.Baseinfo.Naty
  21752. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21753. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21754. infoStr = string(Iinfos)
  21755. idetinfoStr = string(Idetinfos)
  21756. infocode = res.Infcode
  21757. } else if id_card_type == 4 {
  21758. psn_info, _ := service.GetPsnByPatientId(id)
  21759. PsnNo = psn_info.PsnNo
  21760. PsnCertType = psn_info.PsnCertType
  21761. Certno = psn_info.Certno
  21762. PsnName = psn_info.PsnName
  21763. Gend = psn_info.Gend
  21764. Naty = psn_info.Naty
  21765. Brdy = psn_info.Brdy
  21766. Age = psn_info.Age
  21767. infoStr = psn_info.Insuinfo
  21768. idetinfoStr = psn_info.Idetinfo
  21769. infocode = 0
  21770. verify_number = psn_info.VerifyNumber
  21771. }
  21772. } else if miConfig.MdtrtareaAdmvs == "131023" {
  21773. var result string
  21774. var requestLog string
  21775. 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), "")
  21776. if id_card_type == 4 {
  21777. psn_info, _ := service.GetPsnByPatientId(id)
  21778. PsnNo = psn_info.PsnNo
  21779. PsnCertType = psn_info.PsnCertType
  21780. Certno = psn_info.Certno
  21781. PsnName = psn_info.PsnName
  21782. Gend = psn_info.Gend
  21783. Naty = psn_info.Naty
  21784. Brdy = psn_info.Brdy
  21785. Age = psn_info.Age
  21786. infoStr = psn_info.Insuinfo
  21787. idetinfoStr = psn_info.Idetinfo
  21788. infocode = 0
  21789. verify_number = psn_info.VerifyNumber
  21790. } else {
  21791. saveLog(result, requestLog, "1101", "人员基本信息获取")
  21792. if miConfig.Code == "H15049901371" {
  21793. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  21794. utils.ErrorLog("解析失败:%v", err)
  21795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21796. return
  21797. }
  21798. res.ErrMsg = res10265.ErrMsg
  21799. res.Output = res10265.Output
  21800. res.InfRefmsgid = res10265.InfRefmsgid
  21801. } else {
  21802. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21803. utils.ErrorLog("解析失败:%v", err)
  21804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21805. return
  21806. }
  21807. }
  21808. PsnNo = res.Output.Baseinfo.PsnNo
  21809. PsnCertType = res.Output.Baseinfo.PsnCertType
  21810. Certno = res.Output.Baseinfo.Certno
  21811. PsnName = res.Output.Baseinfo.PsnName
  21812. Gend = res.Output.Baseinfo.Gend
  21813. Naty = res.Output.Baseinfo.Naty
  21814. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21815. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21816. infoStr = string(Iinfos)
  21817. idetinfoStr = string(Idetinfos)
  21818. if miConfig.Code == "H15049901371" {
  21819. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  21820. } else {
  21821. infocode = res.Infcode
  21822. }
  21823. }
  21824. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21825. psn_info, _ := service.GetPsnByPatientId(id)
  21826. PsnNo = psn_info.PsnNo
  21827. PsnCertType = psn_info.PsnCertType
  21828. Certno = psn_info.Certno
  21829. PsnName = psn_info.PsnName
  21830. Gend = psn_info.Gend
  21831. Naty = psn_info.Naty
  21832. Brdy = psn_info.Brdy
  21833. Age = psn_info.Age
  21834. infoStr = psn_info.Insuinfo
  21835. idetinfoStr = psn_info.Idetinfo
  21836. infocode = 0
  21837. verify_number = psn_info.VerifyNumber
  21838. } else if miConfig.MdtrtareaAdmvs == "450721" {
  21839. psn_info, _ := service.GetPsnByPatientId(id)
  21840. PsnNo = psn_info.PsnNo
  21841. PsnCertType = psn_info.PsnCertType
  21842. Certno = psn_info.Certno
  21843. PsnName = psn_info.PsnName
  21844. Gend = psn_info.Gend
  21845. Naty = psn_info.Naty
  21846. Brdy = psn_info.Brdy
  21847. Age = psn_info.Age
  21848. infoStr = psn_info.Insuinfo
  21849. idetinfoStr = psn_info.Idetinfo
  21850. infocode = 0
  21851. verify_number = psn_info.VerifyNumber
  21852. } else {
  21853. var result string
  21854. var requestLog string
  21855. //if miConfig.UserOrgId == 10138 {
  21856. if id_card_type != 4 || id_card_type != 1 {
  21857. var insa string
  21858. if len(patient.InsuplcAdmdvs) > 0 {
  21859. insa = patient.InsuplcAdmdvs
  21860. } else {
  21861. insa = miConfig.InsuplcAdmdvs
  21862. }
  21863. //psn_info, _ := service.GetPsnByPatientId(id)
  21864. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  21865. 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)
  21866. }
  21867. //}
  21868. //else {
  21869. // var insa string
  21870. // if len(patient.InsuplcAdmdvs) > 0 {
  21871. // insa = patient.InsuplcAdmdvs
  21872. // } else {
  21873. // insa = miConfig.InsuplcAdmdvs
  21874. // }
  21875. // 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)
  21876. //}
  21877. if id_card_type == 4 || id_card_type == 1 {
  21878. psn_info, _ := service.GetPsnByPatientId(id)
  21879. PsnNo = psn_info.PsnNo
  21880. PsnCertType = psn_info.PsnCertType
  21881. Certno = psn_info.Certno
  21882. PsnName = psn_info.PsnName
  21883. Gend = psn_info.Gend
  21884. Naty = psn_info.Naty
  21885. Brdy = psn_info.Brdy
  21886. Age = psn_info.Age
  21887. infoStr = psn_info.Insuinfo
  21888. idetinfoStr = psn_info.Idetinfo
  21889. infocode = 0
  21890. verify_number = psn_info.VerifyNumber
  21891. } else {
  21892. saveLog(result, requestLog, "1101", "人员基本信息获取")
  21893. if miConfig.Code == "H15049901371" {
  21894. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  21895. utils.ErrorLog("解析失败:%v", err)
  21896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21897. return
  21898. }
  21899. res.ErrMsg = res10265.ErrMsg
  21900. res.Output = res10265.Output
  21901. res.InfRefmsgid = res10265.InfRefmsgid
  21902. } else {
  21903. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21904. utils.ErrorLog("解析失败:%v", err)
  21905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21906. return
  21907. }
  21908. }
  21909. PsnNo = res.Output.Baseinfo.PsnNo
  21910. PsnCertType = res.Output.Baseinfo.PsnCertType
  21911. Certno = res.Output.Baseinfo.Certno
  21912. PsnName = res.Output.Baseinfo.PsnName
  21913. Gend = res.Output.Baseinfo.Gend
  21914. Naty = res.Output.Baseinfo.Naty
  21915. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21916. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21917. infoStr = string(Iinfos)
  21918. idetinfoStr = string(Idetinfos)
  21919. if miConfig.Code == "H15049901371" {
  21920. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  21921. } else {
  21922. infocode = res.Infcode
  21923. }
  21924. }
  21925. }
  21926. if infocode == 0 {
  21927. his := models.VMHisPatient{
  21928. Name: name,
  21929. Gender: gender,
  21930. Birthday: birthUnix,
  21931. MedicalTreatmentType: medical_care,
  21932. IdType: certificates,
  21933. IdCardNo: id_card,
  21934. BalanceAccountsType: settlementValue,
  21935. SocialType: social_type,
  21936. MedicalInsuranceNumber: medical_insurance_card,
  21937. RegisterType: register_type,
  21938. RegisterCost: registration_fee,
  21939. TreatmentCost: medical_expenses,
  21940. Status: 1,
  21941. Ctime: time.Now().Unix(),
  21942. Mtime: time.Now().Unix(),
  21943. PsnNo: PsnNo,
  21944. PsnCertType: PsnCertType,
  21945. Certno: Certno,
  21946. PsnName: PsnName,
  21947. Gend: Gend,
  21948. Naty: Naty,
  21949. Brdy: Brdy,
  21950. Age: Age,
  21951. Iinfo: infoStr,
  21952. Idetinfo: idetinfoStr,
  21953. PatientId: patient.ID,
  21954. RecordDate: theTime.Unix(),
  21955. UserOrgId: adminInfo.CurrentOrgId,
  21956. AdminUserId: admin_user_id,
  21957. IsReturn: 1,
  21958. IdCardType: id_card_type,
  21959. Doctor: doctor,
  21960. Departments: department,
  21961. MdtrtGrpType: mdtrt_type,
  21962. }
  21963. timestamp := time.Now().Unix()
  21964. tempTime := time.Unix(timestamp, 0)
  21965. timeFormat := tempTime.Format("20060102150405")
  21966. chrgBchno := rand.Intn(100000) + 10000
  21967. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  21968. his.Number = ipt_otp_no
  21969. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  21970. department, _ := service.GetDepartMentDetail(department)
  21971. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  21972. IdCardNo := ""
  21973. if id_card_type == 1 {
  21974. // IdCardNo = medical_insurance_card
  21975. IdCardNo = patient.IdCardNo
  21976. } else {
  21977. IdCardNo = patient.IdCardNo
  21978. }
  21979. var rf []*ResultFive
  21980. json.Unmarshal([]byte(his.Iinfo), &rf)
  21981. var insutypes []*ResultFive
  21982. var insutype string
  21983. var insuplc_admdvs_temp string
  21984. var is390 int = 0
  21985. var is310 int = 0
  21986. for _, item := range rf {
  21987. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  21988. insutypes = append(insutypes, item)
  21989. }
  21990. }
  21991. if len(insutypes) == 1 {
  21992. insutype = insutypes[0].Insutype
  21993. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  21994. if insutype == "390" {
  21995. is390 = 1
  21996. }
  21997. if insutype == "310" {
  21998. is310 = 1
  21999. }
  22000. } else {
  22001. for _, i := range insutypes {
  22002. if i.Insutype == "390" {
  22003. is390 = 1
  22004. }
  22005. if i.Insutype == "310" {
  22006. is310 = 1
  22007. }
  22008. }
  22009. }
  22010. if is390 == 1 {
  22011. insutype = "390"
  22012. }
  22013. if is310 == 1 {
  22014. insutype = "310"
  22015. }
  22016. fmt.Println(social_type)
  22017. if social_type > 0 {
  22018. insutype = strconv.FormatInt(social_type, 10)
  22019. }
  22020. var infocode int64
  22021. var resThree ResultThree
  22022. var resThree10265 ResultThree10265
  22023. if len(insuplc_admdvs) == 0 {
  22024. psn_info, _ := service.GetPsnByPatientId(id)
  22025. //if len(psn_info.InsuplcAdmdvs) > 0 {
  22026. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  22027. //}
  22028. } else {
  22029. insuplc_admdvs_temp = insuplc_admdvs
  22030. }
  22031. if miConfig.MdtrtareaAdmvs == "421300" {
  22032. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  22033. psn_info, _ := service.GetPsnByPatientId(id)
  22034. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  22035. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22036. "&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
  22037. resp, requestErr := http.Get(api)
  22038. if requestErr != nil {
  22039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22040. return
  22041. }
  22042. body, ioErr := ioutil.ReadAll(resp.Body)
  22043. if ioErr != nil {
  22044. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22046. return
  22047. }
  22048. var respJSON map[string]interface{}
  22049. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22050. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22052. return
  22053. }
  22054. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22055. result, _ := json.Marshal(respJSON)
  22056. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22057. utils.ErrorLog("解析失败:%v", err)
  22058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22059. return
  22060. }
  22061. infocode = resThree.Infcode
  22062. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22063. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  22064. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  22065. // insuplc_admdvs_temp =
  22066. //}
  22067. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  22068. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  22069. //}
  22070. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  22071. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22072. "&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
  22073. resp, requestErr := http.Get(api)
  22074. if requestErr != nil {
  22075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22076. return
  22077. }
  22078. body, ioErr := ioutil.ReadAll(resp.Body)
  22079. if ioErr != nil {
  22080. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22082. return
  22083. }
  22084. var respJSON map[string]interface{}
  22085. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22086. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22088. return
  22089. }
  22090. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22091. result, _ := json.Marshal(respJSON)
  22092. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22093. utils.ErrorLog("解析失败:%v", err)
  22094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22095. return
  22096. }
  22097. infocode = resThree.Infcode
  22098. } else if miConfig.MdtrtareaAdmvs == "420902" {
  22099. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  22100. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  22101. // insuplc_admdvs_temp =
  22102. //}
  22103. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  22104. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  22105. //}
  22106. utils.ErrorLog("解析失败:%v", insutype)
  22107. utils.ErrorLog("解析失败:%v", PsnNo)
  22108. utils.ErrorLog("解析失败:%v", Certno)
  22109. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  22110. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  22111. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  22112. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  22113. utils.ErrorLog("解析失败:%v", PsnNo)
  22114. utils.ErrorLog("解析失败:%v", department.Number)
  22115. utils.ErrorLog("解析失败:%v", department.Name)
  22116. utils.ErrorLog("解析失败:%v", roles.UserName)
  22117. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  22118. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22119. "&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
  22120. resp, requestErr := http.Get(api)
  22121. if requestErr != nil {
  22122. utils.ErrorLog("解析失败:%v", requestErr)
  22123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22124. return
  22125. }
  22126. body, ioErr := ioutil.ReadAll(resp.Body)
  22127. if ioErr != nil {
  22128. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22130. return
  22131. }
  22132. var respJSON map[string]interface{}
  22133. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22134. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22136. return
  22137. }
  22138. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22139. result, _ := json.Marshal(respJSON)
  22140. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22141. utils.ErrorLog("解析失败:%v", err)
  22142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22143. return
  22144. }
  22145. infocode = resThree.Infcode
  22146. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22147. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  22148. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  22149. // insuplc_admdvs_temp =
  22150. //}
  22151. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  22152. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  22153. //}
  22154. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  22155. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22156. "&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
  22157. resp, requestErr := http.Get(api)
  22158. if requestErr != nil {
  22159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22160. return
  22161. }
  22162. body, ioErr := ioutil.ReadAll(resp.Body)
  22163. if ioErr != nil {
  22164. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22166. return
  22167. }
  22168. var respJSON map[string]interface{}
  22169. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22170. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22172. return
  22173. }
  22174. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22175. result, _ := json.Marshal(respJSON)
  22176. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22177. utils.ErrorLog("解析失败:%v", err)
  22178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22179. return
  22180. }
  22181. infocode = resThree.Infcode
  22182. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22183. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  22184. psn_info, _ := service.GetPsnByPatientId(id)
  22185. var verify_number string
  22186. if id_card_type == 4 {
  22187. verify_number = psn_info.VerifyNumber
  22188. } else if id_card_type == 1 {
  22189. bas := strings.Split(psn_info.CardInfo, "|")
  22190. cardNumber := bas[2]
  22191. verify_number = cardNumber
  22192. }
  22193. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  22194. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22195. "&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
  22196. resp, requestErr := http.Get(api)
  22197. if requestErr != nil {
  22198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22199. return
  22200. }
  22201. body, ioErr := ioutil.ReadAll(resp.Body)
  22202. if ioErr != nil {
  22203. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22205. return
  22206. }
  22207. var respJSON map[string]interface{}
  22208. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22209. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22211. return
  22212. }
  22213. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22214. result, _ := json.Marshal(respJSON)
  22215. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22216. // utils.ErrorLog("解析失败:%v", err)
  22217. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22218. // return
  22219. //}
  22220. //infocode = resThree.Infcode
  22221. //result, _ := json.Marshal(respJSON)
  22222. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22223. utils.ErrorLog("解析失败:%v", err)
  22224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22225. return
  22226. }
  22227. resThree.ErrMsg = resThree10265.ErrMsg
  22228. resThree.Output = resThree10265.Output
  22229. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22230. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22231. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22232. psn_info, _ := service.GetPsnByPatientId(id)
  22233. his.PsnNo = psn_info.PsnNo
  22234. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  22235. var cert_no string
  22236. if id_card_type == 3 {
  22237. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  22238. cert_no = IdCardNo
  22239. } else if id_card_type == 4 {
  22240. cert_no = IdCardNo
  22241. psn_info.VerifyNumber = psn_info.VerifyNumber
  22242. } else {
  22243. bas := strings.Split(psn_info.CardInfo, "|")
  22244. cert_no = bas[2]
  22245. }
  22246. var hisPrescription []*models.HisPrescription
  22247. for _, item := range rf {
  22248. if item.Insutype == insutype {
  22249. //insuplc_admdvs = item.InsuplcAdmdvs
  22250. his.InsuplcAdmdvs = insuplc_admdvs
  22251. }
  22252. }
  22253. his.Insutype = insutype
  22254. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  22255. fmt.Println(res3101)
  22256. fmt.Println(res3101.Infcode)
  22257. if res3101.Infcode == "0" {
  22258. fmt.Println("33333333")
  22259. if len(res3101.Output.Result) > 0 {
  22260. fmt.Println("222222")
  22261. for _, item := range res3101.Output.Result {
  22262. if len(res3101.ErrMsg) == 0 {
  22263. res3101.ErrMsg = item.VolaCont
  22264. } else {
  22265. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  22266. }
  22267. }
  22268. c.ServeSuccessJSON(map[string]interface{}{
  22269. "failed_code": -10,
  22270. "msg": res3101.ErrMsg,
  22271. })
  22272. return
  22273. } else {
  22274. fmt.Println("11111")
  22275. var api string
  22276. if miConfig.MdtrtareaAdmvs == "320921" {
  22277. ipt_otp_no = timeFormat
  22278. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  22279. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22280. "&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
  22281. } else {
  22282. ipt_otp_no = timeFormat
  22283. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  22284. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22285. "&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
  22286. }
  22287. resp, requestErr := http.Get(api)
  22288. if requestErr != nil {
  22289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22290. return
  22291. }
  22292. body, ioErr := ioutil.ReadAll(resp.Body)
  22293. if ioErr != nil {
  22294. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22296. return
  22297. }
  22298. var respJSON map[string]interface{}
  22299. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22300. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22302. return
  22303. }
  22304. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22305. result, _ := json.Marshal(respJSON)
  22306. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22307. utils.ErrorLog("解析失败:%v", err)
  22308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22309. return
  22310. }
  22311. resThree.ErrMsg = resThree10265.ErrMsg
  22312. resThree.Output = resThree10265.Output
  22313. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22314. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22315. }
  22316. } else if res3101.Infcode != "0" {
  22317. c.ServeSuccessJSON(map[string]interface{}{
  22318. "failed_code": -10,
  22319. "msg": res3101.ErrMsg,
  22320. })
  22321. return
  22322. }
  22323. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22324. psn_info, _ := service.GetPsnByPatientId(id)
  22325. var cert_no string
  22326. if id_card_type == 1 {
  22327. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  22328. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  22329. } else if id_card_type == 4 {
  22330. cert_no = psn_info.VerifyNumber
  22331. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  22332. } else {
  22333. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  22334. cert_no = psn_info.VerifyNumber
  22335. }
  22336. 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)
  22337. saveLog(result, requestLog, "2201", "挂号")
  22338. if miConfig.Code == "H15049901371" {
  22339. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22340. utils.ErrorLog("解析失败:%v", err)
  22341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22342. return
  22343. }
  22344. resThree.ErrMsg = resThree10265.ErrMsg
  22345. resThree.Output = resThree10265.Output
  22346. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22347. } else {
  22348. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22349. utils.ErrorLog("解析失败:%v", err)
  22350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22351. return
  22352. }
  22353. }
  22354. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22355. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  22356. psn_info, _ := service.GetPsnByPatientId(id)
  22357. var result string
  22358. var requestLog string
  22359. if id_card_type == 1 {
  22360. bas := strings.Split(psn_info.CardInfo, "|")
  22361. basNumber := bas[2]
  22362. card_sn := bas[3]
  22363. 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)
  22364. saveLog(result, requestLog, "2201A", "挂号")
  22365. } else if id_card_type == 2 {
  22366. 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, "", "", "", "", "", "")
  22367. saveLog(result, requestLog, "2201A", "挂号")
  22368. } else {
  22369. 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)
  22370. saveLog(result, requestLog, "2201A", "挂号")
  22371. }
  22372. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22373. utils.ErrorLog("解析失败:%v", err)
  22374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22375. return
  22376. }
  22377. infocode = resThree.Infcode
  22378. } else if miConfig.MdtrtareaAdmvs == "341203" {
  22379. psn_info, _ := service.GetPsnByPatientId(id)
  22380. his.PsnNo = psn_info.PsnNo
  22381. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  22382. var cert_no string
  22383. if id_card_type == 1 {
  22384. bas := strings.Split(psn_info.CardInfo, "|")
  22385. cert_no = bas[2]
  22386. } else if id_card_type == 4 {
  22387. cert_no = IdCardNo
  22388. psn_info.VerifyNumber = psn_info.VerifyNumber
  22389. } else {
  22390. cert_no = IdCardNo
  22391. psn_info.VerifyNumber = cert_no
  22392. }
  22393. for _, item := range rf {
  22394. if item.Insutype == insutype {
  22395. his.InsuplcAdmdvs = insuplc_admdvs
  22396. }
  22397. }
  22398. his.Insutype = insutype
  22399. var api string
  22400. ipt_otp_no = timeFormat
  22401. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  22402. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22403. "&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
  22404. resp, requestErr := http.Get(api)
  22405. if requestErr != nil {
  22406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22407. return
  22408. }
  22409. body, ioErr := ioutil.ReadAll(resp.Body)
  22410. if ioErr != nil {
  22411. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22413. return
  22414. }
  22415. var respJSON map[string]interface{}
  22416. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22417. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22419. return
  22420. }
  22421. status := respJSON["data"].(map[string]interface{})["status"].(string)
  22422. if status == "0" {
  22423. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  22424. c.ServeSuccessJSON(map[string]interface{}{
  22425. "failed_code": -10,
  22426. "msg": err_msg,
  22427. })
  22428. return
  22429. }
  22430. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22431. result, _ := json.Marshal(respJSON)
  22432. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22433. utils.ErrorLog("解析失败:%v", err)
  22434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22435. return
  22436. }
  22437. infocode = resThree.Infcode
  22438. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22439. psn_info, _ := service.GetPsnByPatientId(id)
  22440. var result string
  22441. var requestLog string
  22442. if id_card_type == 1 {
  22443. bas := strings.Split(psn_info.CardInfo, "|")
  22444. basNumber := bas[2]
  22445. card_sn := bas[3]
  22446. 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)
  22447. saveLog(result, requestLog, "2201A", "挂号")
  22448. } else if id_card_type == 2 {
  22449. 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, "", "")
  22450. saveLog(result, requestLog, "2201A", "挂号")
  22451. } else {
  22452. 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, "", "")
  22453. saveLog(result, requestLog, "2201A", "挂号")
  22454. }
  22455. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22456. utils.ErrorLog("解析失败:%v", err)
  22457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22458. return
  22459. }
  22460. infocode = resThree.Infcode
  22461. } else if miConfig.MdtrtareaAdmvs == "131023" {
  22462. psn_info, _ := service.GetPsnByPatientId(id)
  22463. 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)
  22464. saveLog(result, requestLog, "2201A", "挂号")
  22465. if miConfig.Code == "H15049901371" {
  22466. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22467. utils.ErrorLog("解析失败:%v", err)
  22468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22469. return
  22470. }
  22471. resThree.ErrMsg = resThree10265.ErrMsg
  22472. resThree.Output = resThree10265.Output
  22473. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22474. } else {
  22475. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22476. utils.ErrorLog("解析失败:%v", err)
  22477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22478. return
  22479. }
  22480. }
  22481. if miConfig.Code == "H15049901371" {
  22482. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22483. } else {
  22484. infocode = resThree.Infcode
  22485. }
  22486. } else {
  22487. psn_info, _ := service.GetPsnByPatientId(id)
  22488. if id_card_type == 4 || id_card_type == 1 {
  22489. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  22490. }
  22491. var rf []*ResultFive
  22492. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  22493. var insutypes []*ResultFive
  22494. var insutype string
  22495. var is390 int = 0
  22496. var is310 int = 0
  22497. for _, item := range rf {
  22498. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  22499. insutypes = append(insutypes, item)
  22500. }
  22501. }
  22502. if len(insutypes) == 1 {
  22503. insutype = insutypes[0].Insutype
  22504. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  22505. } else {
  22506. for _, i := range insutypes {
  22507. if i.Insutype == "390" {
  22508. is390 = 1
  22509. }
  22510. if i.Insutype == "310" {
  22511. is310 = 1
  22512. }
  22513. }
  22514. }
  22515. if is390 == 1 {
  22516. insutype = "390"
  22517. }
  22518. if is310 == 1 {
  22519. insutype = "310"
  22520. }
  22521. fmt.Println(len(insutypes))
  22522. if len(insutypes) == 0 {
  22523. for index, item := range rf {
  22524. if index == 0 {
  22525. insutype = item.Insutype
  22526. insuplc_admdvs = item.InsuplcAdmdvs
  22527. }
  22528. }
  22529. fmt.Println(insutype)
  22530. fmt.Println(insuplc_admdvs)
  22531. }
  22532. if social_type > 0 {
  22533. insutype = strconv.FormatInt(social_type, 10)
  22534. }
  22535. fmt.Println("--------")
  22536. fmt.Println(psn_info)
  22537. fmt.Println(psn_info.PsnNo)
  22538. if miConfig.MdtrtareaAdmvs == "441202" {
  22539. var hisPrescription []*models.HisPrescription
  22540. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  22541. if res3101.Infcode == 0 {
  22542. fmt.Println("33333333")
  22543. if len(res3101.Output.Result) > 0 {
  22544. fmt.Println("222222")
  22545. for _, item := range res3101.Output.Result {
  22546. if len(res3101.ErrMsg) == 0 {
  22547. res3101.ErrMsg = item.VolaCont
  22548. } else {
  22549. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  22550. }
  22551. }
  22552. c.ServeSuccessJSON(map[string]interface{}{
  22553. "failed_code": -10,
  22554. "msg": res3101.ErrMsg,
  22555. })
  22556. return
  22557. } else {
  22558. hour := time.Now().Format("15")
  22559. min := time.Now().Format("04")
  22560. sec := time.Now().Format("05")
  22561. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  22562. fmt.Println(record_time_two)
  22563. 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)
  22564. saveLog(result, requestLog, "2201A", "挂号")
  22565. if miConfig.Code == "H15049901371" {
  22566. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22567. utils.ErrorLog("解析失败:%v", err)
  22568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22569. return
  22570. }
  22571. resThree.ErrMsg = resThree10265.ErrMsg
  22572. resThree.Output = resThree10265.Output
  22573. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22574. } else {
  22575. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22576. utils.ErrorLog("解析失败:%v", err)
  22577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22578. return
  22579. }
  22580. }
  22581. if miConfig.Code == "H15049901371" {
  22582. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22583. } else {
  22584. infocode = resThree.Infcode
  22585. }
  22586. }
  22587. } else if res3101.Infcode != 0 {
  22588. c.ServeSuccessJSON(map[string]interface{}{
  22589. "failed_code": -10,
  22590. "msg": res3101.ErrMsg,
  22591. })
  22592. return
  22593. }
  22594. } else if miConfig.MdtrtareaAdmvs == "440205" {
  22595. var hisPrescription []*models.HisPrescription
  22596. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  22597. if res3101.Infcode == 0 {
  22598. fmt.Println("33333333")
  22599. if len(res3101.Output.Result) > 0 {
  22600. fmt.Println("222222")
  22601. for _, item := range res3101.Output.Result {
  22602. if len(res3101.ErrMsg) == 0 {
  22603. res3101.ErrMsg = item.VolaCont
  22604. } else {
  22605. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  22606. }
  22607. }
  22608. c.ServeSuccessJSON(map[string]interface{}{
  22609. "failed_code": -10,
  22610. "msg": res3101.ErrMsg,
  22611. })
  22612. return
  22613. } else {
  22614. hour := time.Now().Format("15")
  22615. min := time.Now().Format("04")
  22616. sec := time.Now().Format("05")
  22617. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  22618. fmt.Println(record_time_two)
  22619. 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)
  22620. saveLog(result, requestLog, "2201A", "挂号")
  22621. if miConfig.Code == "H15049901371" {
  22622. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22623. utils.ErrorLog("解析失败:%v", err)
  22624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22625. return
  22626. }
  22627. resThree.ErrMsg = resThree10265.ErrMsg
  22628. resThree.Output = resThree10265.Output
  22629. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22630. } else {
  22631. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22632. utils.ErrorLog("解析失败:%v", err)
  22633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22634. return
  22635. }
  22636. }
  22637. if miConfig.Code == "H15049901371" {
  22638. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22639. } else {
  22640. infocode = resThree.Infcode
  22641. }
  22642. }
  22643. } else if res3101.Infcode != 0 {
  22644. c.ServeSuccessJSON(map[string]interface{}{
  22645. "failed_code": -10,
  22646. "msg": res3101.ErrMsg,
  22647. })
  22648. return
  22649. }
  22650. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22651. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  22652. psn_info, _ := service.GetPsnByPatientId(id)
  22653. var verify_number string
  22654. if id_card_type == 4 {
  22655. verify_number = psn_info.VerifyNumber
  22656. } else if id_card_type == 1 {
  22657. bas := strings.Split(psn_info.CardInfo, "|")
  22658. cardNumber := bas[2]
  22659. verify_number = cardNumber
  22660. } else {
  22661. verify_number = psn_info.Certno
  22662. }
  22663. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  22664. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22665. "&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
  22666. resp, requestErr := http.Get(api)
  22667. if requestErr != nil {
  22668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22669. return
  22670. }
  22671. body, ioErr := ioutil.ReadAll(resp.Body)
  22672. if ioErr != nil {
  22673. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22675. return
  22676. }
  22677. var respJSON map[string]interface{}
  22678. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22679. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22681. return
  22682. }
  22683. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22684. result, _ := json.Marshal(respJSON)
  22685. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22686. utils.ErrorLog("解析失败:%v", err)
  22687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22688. return
  22689. }
  22690. infocode = resThree.Infcode
  22691. } else {
  22692. hour := time.Now().Format("15")
  22693. min := time.Now().Format("04")
  22694. sec := time.Now().Format("05")
  22695. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  22696. if id_card_type == 1 {
  22697. for _, item := range rf {
  22698. if item.Insutype == strconv.FormatInt(social_type, 10) {
  22699. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  22700. insuplc_admdvs_temp = item.InsuplcAdmdvs
  22701. } else if strconv.FormatInt(social_type, 10) == "390" {
  22702. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  22703. } else {
  22704. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  22705. }
  22706. }
  22707. }
  22708. }
  22709. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  22710. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  22711. }
  22712. if id_card_type == 1 {
  22713. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  22714. bas := strings.Split(psn_info.CardInfo, "|")
  22715. basNumber := bas[1]
  22716. IdCardNo = basNumber
  22717. }
  22718. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  22719. IdCardNo = psn_info.VerifyNumber
  22720. }
  22721. if len(insuplc_admdvs_temp) == 0 {
  22722. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  22723. }
  22724. 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)
  22725. saveLog(result, requestLog, "2201A", "挂号")
  22726. if miConfig.Code == "H15049901371" {
  22727. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22728. utils.ErrorLog("解析失败:%v", err)
  22729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22730. return
  22731. }
  22732. resThree.ErrMsg = resThree10265.ErrMsg
  22733. resThree.Output = resThree10265.Output
  22734. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22735. } else {
  22736. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22737. utils.ErrorLog("解析失败:%v", err)
  22738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22739. return
  22740. }
  22741. }
  22742. if miConfig.Code == "H15049901371" {
  22743. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22744. } else {
  22745. infocode = resThree.Infcode
  22746. }
  22747. }
  22748. }
  22749. if infocode == -1 {
  22750. adminUser := c.GetAdminUserInfo()
  22751. errlog := &models.HisOrderError{
  22752. UserOrgId: adminUser.CurrentOrgId,
  22753. Ctime: time.Now().Unix(),
  22754. Mtime: time.Now().Unix(),
  22755. ErrMsg: resThree.ErrMsg,
  22756. Status: 1,
  22757. PatientId: id,
  22758. RecordTime: recordDateTime,
  22759. Stage: 2,
  22760. }
  22761. service.CreateErrMsgLog(errlog)
  22762. c.ServeSuccessJSON(map[string]interface{}{
  22763. "failed_code": -10,
  22764. "msg": resThree.ErrMsg,
  22765. })
  22766. return
  22767. }
  22768. his.Number = resThree.Output.Data.MdtrtID
  22769. his.PsnNo = resThree.Output.Data.PsnNo
  22770. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  22771. his.IdCardNo = patient.IdCardNo
  22772. his.PhoneNumber = patient.Phone
  22773. his.UserOrgId = adminInfo.CurrentOrgId
  22774. his.Insutype = insutype
  22775. his.Ctime = time.Now().Unix()
  22776. his.Mtime = time.Now().Unix()
  22777. his.InsuplcAdmdvs = insuplc_admdvs_temp
  22778. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  22779. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  22780. }
  22781. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  22782. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  22783. }
  22784. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  22785. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  22786. }
  22787. his.Status = 1
  22788. his.MdtrtGrpType = mdtrt_type
  22789. service.UpdateHisPatientStatus(&his)
  22790. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  22791. c.ServeSuccessJSON(map[string]interface{}{
  22792. "his_info": his,
  22793. })
  22794. } else {
  22795. adminUser := c.GetAdminUserInfo()
  22796. errlog := &models.HisOrderError{
  22797. UserOrgId: adminUser.CurrentOrgId,
  22798. Ctime: time.Now().Unix(),
  22799. Mtime: time.Now().Unix(),
  22800. ErrMsg: res.ErrMsg,
  22801. Status: 1,
  22802. PatientId: id,
  22803. RecordTime: recordDateTime,
  22804. Stage: 1,
  22805. }
  22806. service.CreateErrMsgLog(errlog)
  22807. c.ServeSuccessJSON(map[string]interface{}{
  22808. "failed_code": -10,
  22809. "msg": res.ErrMsg,
  22810. })
  22811. return
  22812. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  22813. }
  22814. }
  22815. }
  22816. func (c *HisApiController) GetUploadInfo() {
  22817. id, _ := c.GetInt64("id")
  22818. record_time := c.GetString("record_time")
  22819. his_patient_id, _ := c.GetInt64("his_patient_id")
  22820. order_id, _ := c.GetInt64("order_id")
  22821. pay_way, _ := c.GetInt64("pay_way")
  22822. pay_ways := c.GetString("pay_ways")
  22823. oth_desc := c.GetString("oth_desc")
  22824. pay_price, _ := c.GetFloat("pay_price")
  22825. pay_card_no := c.GetString("pay_card_no")
  22826. discount_price, _ := c.GetFloat("discount_price")
  22827. preferential_price, _ := c.GetFloat("preferential_price")
  22828. reality_price, _ := c.GetFloat("reality_price")
  22829. found_price, _ := c.GetFloat("found_price")
  22830. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  22831. private_price, _ := c.GetFloat("private_price")
  22832. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  22833. admin_user_id, _ := c.GetInt64("admin_user_id")
  22834. fapiao_code := c.GetString("fapiao_code")
  22835. fapiao_number := c.GetString("fapiao_number")
  22836. diagnosis_id := c.GetString("diagnosis")
  22837. sick_type, _ := c.GetInt64("sick_type")
  22838. reg_type, _ := c.GetInt64("p_type")
  22839. begin_time := c.GetString("begin_time")
  22840. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  22841. cash_pay := c.GetString("cash_pay")
  22842. band_card_pay := c.GetString("band_card_pay")
  22843. wechat_pay := c.GetString("wechat_pay")
  22844. ali_pay := c.GetString("ali_pay")
  22845. jifen_pay := c.GetString("jifen_pay")
  22846. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  22847. fmt.Println(acct_used_flag)
  22848. id_str := c.GetString("ids")
  22849. ids_arr := strings.Split(id_str, ",")
  22850. timeLayout := "2006-01-02"
  22851. loc, _ := time.LoadLocation("Local")
  22852. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  22853. if err != nil {
  22854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22855. return
  22856. }
  22857. recordDateTime := theTime.Unix()
  22858. adminUser := c.GetAdminUserInfo()
  22859. var tempOrder models.HisOrder
  22860. tempOrder, _ = service.GetHisOrderByID(order_id)
  22861. var prescriptions []*models.HisPrescription
  22862. var start_time int64
  22863. var end_time int64
  22864. //押金模块
  22865. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  22866. tmp_decimal := c.GetString("tmp_decimal")
  22867. var decimal float64 //本次使用的押金
  22868. var errmsg error
  22869. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  22870. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  22871. return
  22872. }
  22873. if len(tmp_decimal) > 0 {
  22874. if tmp_decimal[0] == 45 {
  22875. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  22876. return
  22877. }
  22878. }
  22879. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  22880. fmt.Println(errs)
  22881. decimal = tt
  22882. //if adminUser.CurrentOrgId == 10106{
  22883. // if len(fapiao_code) == 0{
  22884. // fapiao_code = "144072080589"
  22885. // }
  22886. // if len(fapiao_number) == 0{
  22887. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  22888. // if order.ID == 0{
  22889. // fapiao_number = "00001520"
  22890. // }else{
  22891. // //fapiao_code = "00001520"
  22892. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  22893. // var zero string
  22894. // if fpNumber >= 1000{
  22895. // zero = "0000" + strconv.Itoa(fpNumber)
  22896. // }else if fpNumber >= 10000{
  22897. // zero = "000" + strconv.Itoa(fpNumber)
  22898. // } else if fpNumber >= 100000{
  22899. // zero = "00" + strconv.Itoa(fpNumber)
  22900. // } else if fpNumber >= 1000000{
  22901. // zero = "0" + strconv.Itoa(fpNumber)
  22902. // }else {
  22903. // zero = strconv.Itoa(fpNumber)
  22904. // }
  22905. // fapiao_number = zero
  22906. // }
  22907. // }
  22908. //}
  22909. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  22910. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  22911. var patientPrescription models.HisPrescriptionInfo
  22912. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  22913. if patientPrescription.ID == 0 {
  22914. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  22915. }
  22916. //if patientPrescription.Do
  22917. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  22918. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  22919. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  22920. diagnosis_ids := strings.Split(diagnosis_id, ",")
  22921. var config []*models.HisXtDiagnoseConfig
  22922. for _, item := range diagnosis_ids {
  22923. id, _ := strconv.ParseInt(item, 10, 64)
  22924. diagnosisConfig, _ := service.FindDiagnoseById(id)
  22925. config = append(config, &diagnosisConfig)
  22926. }
  22927. sickConfig, _ := service.FindSickById(sick_type)
  22928. //if tempOrder.ID == 0 {
  22929. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  22930. //}
  22931. if tempOrder.ID == 0 {
  22932. var result string
  22933. var requestLog string
  22934. var res2 ResultSix
  22935. var res3 GZResultSix
  22936. var ressix10265 ResultSix10265
  22937. if miConfig.MdtrtareaAdmvs == "421300" {
  22938. data := make(map[string]interface{})
  22939. client := &http.Client{}
  22940. data["psn_no"] = his.PsnNo
  22941. data["mdtrt_id"] = his.Number
  22942. data["opter"] = roles.UserName
  22943. data["org_name"] = miConfig.OrgName
  22944. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22945. data["doctor_id"] = doctor_info.DoctorNumber
  22946. data["doctor_name"] = doctor_info.UserName
  22947. data["department"] = department.Name
  22948. data["fixmedins_code"] = miConfig.Code
  22949. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22950. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22951. data["secret_key"] = miConfig.SecretKey
  22952. data["sick_code"] = sickConfig.CountryCode
  22953. data["sick_name"] = sickConfig.ClassName
  22954. data["dept"] = strconv.FormatInt(department.ID, 10)
  22955. data["config"] = config
  22956. data["begin_time"] = begin_time
  22957. bytesData, _ := json.Marshal(data)
  22958. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  22959. resp, _ := client.Do(req)
  22960. defer resp.Body.Close()
  22961. body, ioErr := ioutil.ReadAll(resp.Body)
  22962. if ioErr != nil {
  22963. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22965. return
  22966. }
  22967. var respJSON map[string]interface{}
  22968. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22969. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22971. return
  22972. }
  22973. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22974. userJSONBytes, _ := json.Marshal(respJSON)
  22975. fmt.Println("log")
  22976. fmt.Println(string(userJSONBytes))
  22977. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22978. utils.ErrorLog("解析失败:%v", err)
  22979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22980. return
  22981. }
  22982. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22983. data := make(map[string]interface{})
  22984. client := &http.Client{}
  22985. data["psn_no"] = his.PsnNo
  22986. data["mdtrt_id"] = his.Number
  22987. data["opter"] = roles.UserName
  22988. data["org_name"] = miConfig.OrgName
  22989. if reg_type == 11 && his.Insutype == "390" {
  22990. data["med_type"] = "110104"
  22991. } else {
  22992. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22993. }
  22994. data["doctor_id"] = doctor_info.DoctorNumber
  22995. data["doctor_name"] = doctor_info.UserName
  22996. data["department"] = department.Name
  22997. data["fixmedins_code"] = miConfig.Code
  22998. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22999. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  23000. data["secret_key"] = miConfig.SecretKey
  23001. data["sick_code"] = sickConfig.CountryCode
  23002. data["sick_name"] = sickConfig.ClassName
  23003. data["dept"] = strconv.FormatInt(department.ID, 10)
  23004. data["config"] = config
  23005. data["begin_time"] = begin_time
  23006. bytesData, _ := json.Marshal(data)
  23007. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  23008. resp, _ := client.Do(req)
  23009. defer resp.Body.Close()
  23010. body, ioErr := ioutil.ReadAll(resp.Body)
  23011. if ioErr != nil {
  23012. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23014. return
  23015. }
  23016. var respJSON map[string]interface{}
  23017. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23018. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23020. return
  23021. }
  23022. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23023. userJSONBytes, _ := json.Marshal(respJSON)
  23024. fmt.Println("log")
  23025. fmt.Println(string(userJSONBytes))
  23026. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23027. utils.ErrorLog("解析失败:%v", err)
  23028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23029. return
  23030. }
  23031. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23032. data := make(map[string]interface{})
  23033. client := &http.Client{}
  23034. data["psn_no"] = his.PsnNo
  23035. data["mdtrt_id"] = his.Number
  23036. data["opter"] = roles.UserName
  23037. data["org_name"] = miConfig.OrgName
  23038. if reg_type == 11 && his.Insutype == "390" {
  23039. data["med_type"] = "110104"
  23040. } else {
  23041. data["med_type"] = strconv.FormatInt(reg_type, 10)
  23042. }
  23043. data["doctor_id"] = doctor_info.DoctorNumber
  23044. data["doctor_name"] = doctor_info.UserName
  23045. data["department"] = department.Name
  23046. data["fixmedins_code"] = miConfig.Code
  23047. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  23048. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  23049. data["secret_key"] = miConfig.SecretKey
  23050. data["sick_code"] = sickConfig.CountryCode
  23051. data["sick_name"] = sickConfig.ClassName
  23052. data["dept"] = strconv.FormatInt(department.ID, 10)
  23053. data["config"] = config
  23054. data["begin_time"] = begin_time
  23055. bytesData, _ := json.Marshal(data)
  23056. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  23057. resp, _ := client.Do(req)
  23058. defer resp.Body.Close()
  23059. body, ioErr := ioutil.ReadAll(resp.Body)
  23060. if ioErr != nil {
  23061. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23063. return
  23064. }
  23065. var respJSON map[string]interface{}
  23066. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23067. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23069. return
  23070. }
  23071. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23072. userJSONBytes, _ := json.Marshal(respJSON)
  23073. fmt.Println("log")
  23074. fmt.Println(string(userJSONBytes))
  23075. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23076. utils.ErrorLog("解析失败:%v", err)
  23077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23078. return
  23079. }
  23080. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23081. data := make(map[string]interface{})
  23082. client := &http.Client{}
  23083. data["psn_no"] = his.PsnNo
  23084. data["mdtrt_id"] = his.Number
  23085. data["opter"] = roles.UserName
  23086. data["org_name"] = miConfig.OrgName
  23087. if reg_type == 11 && his.Insutype == "390" {
  23088. data["med_type"] = "110104"
  23089. } else {
  23090. data["med_type"] = strconv.FormatInt(reg_type, 10)
  23091. }
  23092. data["doctor_id"] = doctor_info.DoctorNumber
  23093. data["doctor_name"] = doctor_info.UserName
  23094. data["department"] = department.Name
  23095. data["fixmedins_code"] = miConfig.Code
  23096. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  23097. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  23098. data["secret_key"] = miConfig.SecretKey
  23099. data["sick_code"] = sickConfig.CountryCode
  23100. data["sick_name"] = sickConfig.ClassName
  23101. data["dept"] = strconv.FormatInt(department.ID, 10)
  23102. data["config"] = config
  23103. data["begin_time"] = begin_time
  23104. bytesData, _ := json.Marshal(data)
  23105. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  23106. resp, _ := client.Do(req)
  23107. defer resp.Body.Close()
  23108. body, ioErr := ioutil.ReadAll(resp.Body)
  23109. if ioErr != nil {
  23110. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23112. return
  23113. }
  23114. var respJSON map[string]interface{}
  23115. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23116. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23118. return
  23119. }
  23120. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23121. userJSONBytes, _ := json.Marshal(respJSON)
  23122. fmt.Println("log")
  23123. fmt.Println(string(userJSONBytes))
  23124. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23125. utils.ErrorLog("解析失败:%v", err)
  23126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23127. return
  23128. }
  23129. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23130. data := make(map[string]interface{})
  23131. client := &http.Client{}
  23132. data["psn_no"] = his.PsnNo
  23133. data["mdtrt_id"] = his.Number
  23134. data["doctor"] = roles.UserName
  23135. data["department"] = department.Name
  23136. data["org_name"] = miConfig.OrgName
  23137. data["med_type"] = strconv.FormatInt(reg_type, 10)
  23138. data["doctor_id"] = doctor_info.DoctorNumber
  23139. data["new_doctor_name"] = doctor_info.UserName
  23140. data["fixmedins_code"] = miConfig.Code
  23141. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  23142. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  23143. data["secret_key"] = miConfig.SecretKey
  23144. data["sick_code"] = sickConfig.CountryCode
  23145. data["sick_name"] = sickConfig.ClassName
  23146. data["url"] = miConfig.Url
  23147. data["ak"] = miConfig.AccessKey
  23148. data["begin_time"] = begin_time
  23149. data["cainfo"] = miConfig.Cainfo
  23150. data["dept"] = strconv.FormatInt(department.ID, 10)
  23151. data["config"] = config
  23152. bytesData, _ := json.Marshal(data)
  23153. var req *http.Request
  23154. if miConfig.MdtrtareaAdmvs == "320921" {
  23155. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  23156. //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 +
  23157. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  23158. } else {
  23159. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  23160. }
  23161. resp, _ := client.Do(req)
  23162. defer resp.Body.Close()
  23163. body, ioErr := ioutil.ReadAll(resp.Body)
  23164. if ioErr != nil {
  23165. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23167. return
  23168. }
  23169. var respJSON map[string]interface{}
  23170. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23171. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23173. return
  23174. }
  23175. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23176. userJSONBytes, _ := json.Marshal(respJSON)
  23177. fmt.Println("log")
  23178. fmt.Println(string(userJSONBytes))
  23179. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  23180. utils.ErrorLog("解析失败:%v", err)
  23181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23182. return
  23183. }
  23184. res2.InfRefmsgid = ressix10265.InfRefmsgid
  23185. res2.Output = ressix10265.Output
  23186. res2.ErrMsg = ressix10265.ErrMsg
  23187. res2.Cainfo = ressix10265.Cainfo
  23188. res2.WarnMsg = ressix10265.WarnMsg
  23189. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  23190. res2.Infcode = infocode
  23191. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23192. data := make(map[string]interface{})
  23193. client := &http.Client{}
  23194. data["psn_no"] = his.PsnNo
  23195. data["mdtrt_id"] = his.Number
  23196. data["doctor"] = roles.UserName
  23197. data["department"] = department.Name
  23198. data["org_name"] = miConfig.OrgName
  23199. data["med_type"] = strconv.FormatInt(reg_type, 10)
  23200. data["doctor_id"] = doctor_info.DoctorNumber
  23201. data["new_doctor_name"] = doctor_info.UserName
  23202. data["fixmedins_code"] = miConfig.Code
  23203. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  23204. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  23205. data["secret_key"] = miConfig.SecretKey
  23206. data["sick_code"] = sickConfig.CountryCode
  23207. data["sick_name"] = sickConfig.ClassName
  23208. data["url"] = miConfig.Url
  23209. data["ak"] = miConfig.AccessKey
  23210. data["begin_time"] = begin_time
  23211. data["cainfo"] = miConfig.Cainfo
  23212. data["dept"] = strconv.FormatInt(department.ID, 10)
  23213. data["config"] = config
  23214. bytesData, _ := json.Marshal(data)
  23215. var req *http.Request
  23216. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  23217. resp, _ := client.Do(req)
  23218. defer resp.Body.Close()
  23219. body, ioErr := ioutil.ReadAll(resp.Body)
  23220. if ioErr != nil {
  23221. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23223. return
  23224. }
  23225. var respJSON map[string]interface{}
  23226. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23227. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23229. return
  23230. }
  23231. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23232. userJSONBytes, _ := json.Marshal(respJSON)
  23233. fmt.Println("log")
  23234. fmt.Println(string(userJSONBytes))
  23235. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  23236. utils.ErrorLog("解析失败:%v", err)
  23237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23238. return
  23239. }
  23240. res2.InfRefmsgid = ressix10265.InfRefmsgid
  23241. res2.Output = ressix10265.Output
  23242. res2.ErrMsg = ressix10265.ErrMsg
  23243. res2.Cainfo = ressix10265.Cainfo
  23244. res2.WarnMsg = ressix10265.WarnMsg
  23245. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  23246. res2.Infcode = infocode
  23247. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23248. 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)
  23249. saveLog(result, requestLog, "2203", "上传就诊信息")
  23250. var respJSON2 map[string]interface{}
  23251. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  23252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23254. return
  23255. }
  23256. userJSONBytes2, _ := json.Marshal(respJSON2)
  23257. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  23258. utils.ErrorLog("解析失败:%v", err)
  23259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23260. return
  23261. }
  23262. 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)
  23263. fmt.Println(result2)
  23264. fmt.Println(src_request)
  23265. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23266. data := make(map[string]interface{})
  23267. client := &http.Client{}
  23268. data["psn_no"] = his.PsnNo
  23269. data["mdtrt_id"] = his.Number
  23270. data["doctor"] = roles.UserName
  23271. data["department"] = department.Name
  23272. data["org_name"] = miConfig.OrgName
  23273. data["med_type"] = strconv.FormatInt(reg_type, 10)
  23274. data["doctor_id"] = doctor_info.DoctorNumber
  23275. data["new_doctor_name"] = doctor_info.UserName
  23276. data["fixmedins_code"] = miConfig.Code
  23277. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  23278. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  23279. data["secret_key"] = miConfig.SecretKey
  23280. data["sick_code"] = sickConfig.CountryCode
  23281. data["sick_name"] = sickConfig.ClassName
  23282. data["url"] = miConfig.Url
  23283. data["ak"] = miConfig.AccessKey
  23284. data["begin_time"] = begin_time
  23285. data["cainfo"] = miConfig.Cainfo
  23286. data["dept"] = strconv.FormatInt(department.ID, 10)
  23287. data["config"] = config
  23288. bytesData, _ := json.Marshal(data)
  23289. var req *http.Request
  23290. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  23291. resp, _ := client.Do(req)
  23292. defer resp.Body.Close()
  23293. body, ioErr := ioutil.ReadAll(resp.Body)
  23294. if ioErr != nil {
  23295. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23297. return
  23298. }
  23299. var respJSON map[string]interface{}
  23300. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23301. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23303. return
  23304. }
  23305. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23306. userJSONBytes, _ := json.Marshal(respJSON)
  23307. fmt.Println("log")
  23308. fmt.Println(string(userJSONBytes))
  23309. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23310. utils.ErrorLog("解析失败:%v", err)
  23311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23312. return
  23313. }
  23314. } else {
  23315. if miConfig.MdtrtareaAdmvs == "440781" { //
  23316. 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)
  23317. } else {
  23318. if miConfig.Code == "H15049901371" {
  23319. //赤峰地区国家医保医疗类别
  23320. //职工透析:医疗类别选特殊情况门诊990502
  23321. //居民定额血透门慢: 医疗类别选门诊慢病140104
  23322. var med_type string
  23323. if his.Insutype == "390" {
  23324. if reg_type == 14 {
  23325. med_type = "9933"
  23326. } else if reg_type == 11 {
  23327. med_type = "11"
  23328. }
  23329. } else if his.Insutype == "310" {
  23330. if reg_type == 14 {
  23331. med_type = "990502"
  23332. } else if reg_type == 11 {
  23333. med_type = "11"
  23334. }
  23335. }
  23336. 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)
  23337. } else {
  23338. 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)
  23339. }
  23340. }
  23341. saveLog(result, requestLog, "2203", "上传就诊信息")
  23342. var respJSON2 map[string]interface{}
  23343. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  23344. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23346. return
  23347. }
  23348. userJSONBytes2, _ := json.Marshal(respJSON2)
  23349. if miConfig.Code == "H15049901371" {
  23350. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  23351. utils.ErrorLog("解析失败:%v", err)
  23352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23353. return
  23354. }
  23355. res2.InfRefmsgid = ressix10265.InfRefmsgid
  23356. res2.Output = ressix10265.Output
  23357. res2.ErrMsg = ressix10265.ErrMsg
  23358. res2.Cainfo = ressix10265.Cainfo
  23359. res2.WarnMsg = ressix10265.WarnMsg
  23360. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  23361. res2.Infcode = infocode
  23362. } else {
  23363. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23364. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  23365. utils.ErrorLog("解析失败:%v", err)
  23366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23367. return
  23368. }
  23369. res2.Infcode = res3.Infcode
  23370. } else {
  23371. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  23372. utils.ErrorLog("解析失败:%v", err)
  23373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23374. return
  23375. }
  23376. }
  23377. }
  23378. }
  23379. if res2.Infcode == -1 {
  23380. adminUser := c.GetAdminUserInfo()
  23381. errlog := &models.HisOrderError{
  23382. UserOrgId: adminUser.CurrentOrgId,
  23383. Ctime: time.Now().Unix(),
  23384. Mtime: time.Now().Unix(),
  23385. ErrMsg: res2.ErrMsg,
  23386. Status: 1,
  23387. PatientId: id,
  23388. RecordTime: recordDateTime,
  23389. Stage: 3,
  23390. }
  23391. service.CreateErrMsgLog(errlog)
  23392. c.ServeSuccessJSON(map[string]interface{}{
  23393. "failed_code": -10,
  23394. "msg": res2.ErrMsg,
  23395. })
  23396. return
  23397. } else {
  23398. his.Diagnosis = diagnosis_id
  23399. his.SickType = sickConfig.ID
  23400. //var p_type int64
  23401. //if reg_type == 1111 || reg_type == 1112 {
  23402. // p_type = 11
  23403. //
  23404. //}
  23405. his.PType = fmt.Sprintf("%d", reg_type)
  23406. service.UpdateHisPatientThree(&his)
  23407. data := make(map[string]interface{})
  23408. if settle_accounts_type == 1 { //日结
  23409. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  23410. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  23411. } else {
  23412. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  23413. }
  23414. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  23415. data["pre"] = prescriptions
  23416. } else { //月结
  23417. start_time_str := c.GetString("start_time")
  23418. end_time_str := c.GetString("end_time")
  23419. timeLayout := "2006-01-02"
  23420. loc, _ := time.LoadLocation("Local")
  23421. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  23422. if err != nil {
  23423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23424. return
  23425. }
  23426. recordStartTime := theStartTime.Unix()
  23427. start_time = recordStartTime
  23428. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  23429. if err != nil {
  23430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23431. return
  23432. }
  23433. recordEndTime := theEndTime.Unix()
  23434. end_time = recordEndTime
  23435. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  23436. data["pre"] = prescriptions
  23437. }
  23438. timestamp := time.Now().Unix()
  23439. tempTime := time.Unix(timestamp, 0)
  23440. timeFormat := tempTime.Format("20060102150405")
  23441. chrgBchno := rand.Intn(100000) + 10000
  23442. new_chrg_bchno := ""
  23443. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  23444. new_chrg_bchno = chrg_bchno
  23445. strconv.FormatInt(his.PatientId, 10)
  23446. client := &http.Client{}
  23447. if adminUser.CurrentOrgId == 10265 {
  23448. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  23449. new_chrg_bchno = "0000"
  23450. }
  23451. }
  23452. data["psn_no"] = his.PsnNo
  23453. data["mdtrt_id"] = his.Number
  23454. data["chrg_bchno"] = new_chrg_bchno
  23455. data["org_name"] = miConfig.OrgName
  23456. data["doctor"] = doctor_info.UserName
  23457. data["doctor_id"] = doctor_info.DoctorNumber
  23458. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  23459. data["fixmedins_code"] = miConfig.Code
  23460. data["dept_code"] = department.Number
  23461. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  23462. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  23463. data["secret_key"] = miConfig.SecretKey
  23464. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  23465. data["url"] = miConfig.Url
  23466. data["ak"] = miConfig.AccessKey
  23467. data["new_doctor_name"] = patientPrescription.Doctor
  23468. data["diag_code"] = sickConfig.CountryCode
  23469. data["cainfo"] = miConfig.Cainfo
  23470. data["opter"] = roles.UserName
  23471. var ids []int64
  23472. for _, item := range prescriptions {
  23473. ids = append(ids, item.ID)
  23474. }
  23475. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  23476. if config.IsOpen == 1 { //对接了医保,走医保流程
  23477. var res ResultFour
  23478. var resFour10265 ResultFour10265
  23479. if miConfig.MdtrtareaAdmvs == "421300" {
  23480. bytesData, _ := json.Marshal(data)
  23481. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  23482. resp, _ := client.Do(req)
  23483. defer resp.Body.Close()
  23484. body, ioErr := ioutil.ReadAll(resp.Body)
  23485. if ioErr != nil {
  23486. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23488. return
  23489. }
  23490. var respJSON map[string]interface{}
  23491. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23492. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23494. return
  23495. }
  23496. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23497. userJSONBytes, _ := json.Marshal(respJSON)
  23498. fmt.Println("log")
  23499. fmt.Println(string(userJSONBytes))
  23500. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23501. utils.ErrorLog("解析失败:%v", err)
  23502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23503. return
  23504. }
  23505. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23506. bytesData, _ := json.Marshal(data)
  23507. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  23508. resp, _ := client.Do(req)
  23509. defer resp.Body.Close()
  23510. body, ioErr := ioutil.ReadAll(resp.Body)
  23511. if ioErr != nil {
  23512. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23514. return
  23515. }
  23516. var respJSON map[string]interface{}
  23517. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23518. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23520. return
  23521. }
  23522. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23523. userJSONBytes, _ := json.Marshal(respJSON)
  23524. fmt.Println("log")
  23525. fmt.Println(string(userJSONBytes))
  23526. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23527. utils.ErrorLog("解析失败:%v", err)
  23528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23529. return
  23530. }
  23531. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23532. bytesData, _ := json.Marshal(data)
  23533. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  23534. resp, _ := client.Do(req)
  23535. defer resp.Body.Close()
  23536. body, ioErr := ioutil.ReadAll(resp.Body)
  23537. if ioErr != nil {
  23538. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23540. return
  23541. }
  23542. var respJSON map[string]interface{}
  23543. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23544. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23546. return
  23547. }
  23548. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23549. userJSONBytes, _ := json.Marshal(respJSON)
  23550. fmt.Println("log")
  23551. fmt.Println(string(userJSONBytes))
  23552. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23553. utils.ErrorLog("解析失败:%v", err)
  23554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23555. return
  23556. }
  23557. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23558. bytesData, _ := json.Marshal(data)
  23559. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  23560. resp, _ := client.Do(req)
  23561. defer resp.Body.Close()
  23562. body, ioErr := ioutil.ReadAll(resp.Body)
  23563. if ioErr != nil {
  23564. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23566. return
  23567. }
  23568. var respJSON map[string]interface{}
  23569. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23570. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23572. return
  23573. }
  23574. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23575. userJSONBytes, _ := json.Marshal(respJSON)
  23576. fmt.Println("log")
  23577. fmt.Println(string(userJSONBytes))
  23578. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23579. utils.ErrorLog("解析失败:%v", err)
  23580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23581. return
  23582. }
  23583. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23584. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  23585. if result3101.Infcode == "0" {
  23586. if len(result3101.Output.Result) > 0 {
  23587. var errMsgs []string
  23588. for _, item := range result3101.Output.Result {
  23589. errMsgs = append(errMsgs, item.VolaCont)
  23590. }
  23591. c.ServeSuccessJSON(map[string]interface{}{
  23592. "failed_code": -10,
  23593. "msg": errMsgs,
  23594. })
  23595. return
  23596. }
  23597. }
  23598. bytesData, _ := json.Marshal(data)
  23599. var req *http.Request
  23600. if miConfig.MdtrtareaAdmvs == "320921" {
  23601. data["diag_code"] = sickConfig.CountryCode
  23602. fmt.Println(data)
  23603. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23604. } else {
  23605. data["diag_code"] = sickConfig.CountryCode
  23606. fmt.Println(data)
  23607. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23608. }
  23609. resp, _ := client.Do(req)
  23610. defer resp.Body.Close()
  23611. body, ioErr := ioutil.ReadAll(resp.Body)
  23612. if ioErr != nil {
  23613. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23615. return
  23616. }
  23617. var respJSON map[string]interface{}
  23618. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23619. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23621. return
  23622. }
  23623. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23624. userJSONBytes, _ := json.Marshal(respJSON)
  23625. fmt.Println("log")
  23626. fmt.Println(string(userJSONBytes))
  23627. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  23628. utils.ErrorLog("解析失败:%v", err)
  23629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23630. return
  23631. }
  23632. res.InfRefmsgid = resFour10265.InfRefmsgid
  23633. res.Output = resFour10265.Output
  23634. res.ErrMsg = resFour10265.ErrMsg
  23635. res.Cainfo = resFour10265.Cainfo
  23636. res.WarnMsg = resFour10265.WarnMsg
  23637. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  23638. res.Infcode = infocode
  23639. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23640. var pagesize int = 2
  23641. var start int = 1
  23642. var stop int
  23643. var pagecount int
  23644. var curpage int
  23645. var isSuccess bool = true
  23646. data["doctor_id"] = doctor_info.DoctorNumber
  23647. //总页数,向上取整,注意除之前要先转换类型为float64
  23648. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  23649. for curpage = 1; curpage <= pagecount; curpage++ {
  23650. if curpage == 1 {
  23651. start = 1
  23652. } else {
  23653. start = (curpage-1)*pagesize + 1
  23654. }
  23655. stop = curpage * pagesize
  23656. if stop > len(prescriptions) {
  23657. stop = len(prescriptions)
  23658. }
  23659. //var requestLog string
  23660. data["pre"] = prescriptions[start-1 : stop]
  23661. fmt.Println(data["pre"])
  23662. bytesData, _ := json.Marshal(data)
  23663. var req *http.Request
  23664. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  23665. resp, _ := client.Do(req)
  23666. defer resp.Body.Close()
  23667. body, ioErr := ioutil.ReadAll(resp.Body)
  23668. if ioErr != nil {
  23669. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23671. return
  23672. }
  23673. var respJSON map[string]interface{}
  23674. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23675. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23677. return
  23678. }
  23679. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23680. userJSONBytes, _ := json.Marshal(respJSON)
  23681. fmt.Println("log")
  23682. fmt.Println(string(userJSONBytes))
  23683. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  23684. utils.ErrorLog("解析失败:%v", err)
  23685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23686. return
  23687. }
  23688. res.InfRefmsgid = resFour10265.InfRefmsgid
  23689. res.Output = resFour10265.Output
  23690. res.ErrMsg = resFour10265.ErrMsg
  23691. res.Cainfo = resFour10265.Cainfo
  23692. res.WarnMsg = resFour10265.WarnMsg
  23693. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  23694. res.Infcode = infocode
  23695. if infocode == 0 {
  23696. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  23697. } else {
  23698. isSuccess = false
  23699. errlog := &models.HisOrderError{
  23700. UserOrgId: adminUser.CurrentOrgId,
  23701. Ctime: time.Now().Unix(),
  23702. Mtime: time.Now().Unix(),
  23703. Number: chrg_bchno,
  23704. ErrMsg: "",
  23705. Status: 1,
  23706. PatientId: id,
  23707. RecordTime: recordDateTime,
  23708. Stage: 4,
  23709. }
  23710. service.CreateErrMsgLog(errlog)
  23711. c.ServeSuccessJSON(map[string]interface{}{
  23712. "failed_code": -10,
  23713. "msg": res.ErrMsg,
  23714. })
  23715. return
  23716. }
  23717. }
  23718. if isSuccess {
  23719. res.Infcode = 0
  23720. }
  23721. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23722. 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)
  23723. var dat map[string]interface{}
  23724. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23725. fmt.Println(dat)
  23726. } else {
  23727. fmt.Println(err)
  23728. }
  23729. saveLog(result, request_log, "2204", "上传费用明细")
  23730. userJSONBytes, _ := json.Marshal(dat)
  23731. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  23732. utils.ErrorLog("解析失败:%v", err)
  23733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23734. return
  23735. }
  23736. res.InfRefmsgid = resFour10265.InfRefmsgid
  23737. res.Output = resFour10265.Output
  23738. res.ErrMsg = resFour10265.ErrMsg
  23739. res.Cainfo = resFour10265.Cainfo
  23740. res.WarnMsg = resFour10265.WarnMsg
  23741. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  23742. res.Infcode = infocode
  23743. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23744. bytesData, _ := json.Marshal(data)
  23745. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  23746. resp, _ := client.Do(req)
  23747. defer resp.Body.Close()
  23748. body, ioErr := ioutil.ReadAll(resp.Body)
  23749. if ioErr != nil {
  23750. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23752. return
  23753. }
  23754. var respJSON map[string]interface{}
  23755. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23756. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23758. return
  23759. }
  23760. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23761. userJSONBytes, _ := json.Marshal(respJSON)
  23762. fmt.Println("log")
  23763. fmt.Println(string(userJSONBytes))
  23764. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23765. utils.ErrorLog("解析失败:%v", err)
  23766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23767. return
  23768. }
  23769. } else {
  23770. if miConfig.Code == "H15049901371" {
  23771. 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)
  23772. var dat map[string]interface{}
  23773. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23774. fmt.Println(dat)
  23775. } else {
  23776. fmt.Println(err)
  23777. }
  23778. saveLog(result, request_log, "2204", "上传费用明细")
  23779. userJSONBytes, _ := json.Marshal(dat)
  23780. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  23781. utils.ErrorLog("解析失败:%v", err)
  23782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23783. return
  23784. }
  23785. res.InfRefmsgid = resFour10265.InfRefmsgid
  23786. res.Output = resFour10265.Output
  23787. res.ErrMsg = resFour10265.ErrMsg
  23788. res.Cainfo = resFour10265.Cainfo
  23789. res.WarnMsg = resFour10265.WarnMsg
  23790. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  23791. res.Infcode = infocode
  23792. } else {
  23793. 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)
  23794. var dat map[string]interface{}
  23795. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23796. fmt.Println(dat)
  23797. } else {
  23798. fmt.Println(err)
  23799. }
  23800. saveLog(result, request_log, "2204", "上传费用明细")
  23801. userJSONBytes, _ := json.Marshal(dat)
  23802. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23803. utils.ErrorLog("解析失败:%v", err)
  23804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23805. return
  23806. }
  23807. }
  23808. }
  23809. if res.Infcode == 0 {
  23810. order := &models.HisOrder{
  23811. UserOrgId: adminUser.CurrentOrgId,
  23812. HisPatientId: his.ID,
  23813. PatientId: his.PatientId,
  23814. SettleAccountsDate: recordDateTime,
  23815. MdtrtId: his.Number,
  23816. PsnNo: his.PsnNo,
  23817. MedType: strconv.FormatInt(reg_type, 10),
  23818. Ctime: time.Now().Unix(),
  23819. Mtime: time.Now().Unix(),
  23820. Status: 1,
  23821. Number: chrg_bchno,
  23822. Infcode: res.Infcode,
  23823. WarnMsg: res.WarnMsg,
  23824. Cainfo: res.Cainfo,
  23825. ErrMsg: res.ErrMsg,
  23826. RespondTime: res.RefmsgTime,
  23827. InfRefmsgid: res.InfRefmsgid,
  23828. OrderStatus: 1,
  23829. PayWay: pay_way,
  23830. PayWays: pay_ways,
  23831. OthDesc: oth_desc,
  23832. PayPrice: pay_price,
  23833. PayCardNo: pay_card_no,
  23834. DiscountPrice: discount_price,
  23835. PreferentialPrice: preferential_price,
  23836. RealityPrice: reality_price,
  23837. FoundPrice: found_price,
  23838. MedicalInsurancePrice: medical_insurance_price,
  23839. PrivatePrice: private_price,
  23840. IsMedicineInsurance: 1,
  23841. SettleType: settle_accounts_type,
  23842. SettleStartTime: start_time,
  23843. SettleEndTime: end_time,
  23844. Creator: roles.AdminUserId,
  23845. Modify: roles.AdminUserId,
  23846. FaPiaoNumber: fapiao_number,
  23847. FaPiaoCode: fapiao_code,
  23848. PType: 2,
  23849. Diagnosis: diagnosis_id,
  23850. CashPay: cash_pay,
  23851. WechatPay: wechat_pay,
  23852. AliPay: ali_pay,
  23853. JifenPay: jifen_pay,
  23854. BandCardPay: band_card_pay,
  23855. }
  23856. err = service.CreateOrder(order)
  23857. if err != nil {
  23858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  23859. return
  23860. }
  23861. for _, item := range res.Output.Result {
  23862. temp := strings.Split(item.FeedetlSn, "-")
  23863. var advice_id int64 = 0
  23864. var project_id int64 = 0
  23865. var types int64 = 0
  23866. id, _ := strconv.ParseInt(temp[2], 10, 64)
  23867. types, _ = strconv.ParseInt(temp[1], 10, 64)
  23868. if temp[1] == "1" {
  23869. advice_id = id
  23870. project_id = 0
  23871. } else if temp[1] == "2" {
  23872. advice_id = 0
  23873. project_id = id
  23874. }
  23875. if item.MedChrgitmType == "9" {
  23876. item.MedChrgitmType = "09"
  23877. }
  23878. info := &models.HisOrderInfo{
  23879. OrderNumber: order.Number,
  23880. FeedetlSn: item.FeedetlSn,
  23881. UploadDate: time.Now().Unix(),
  23882. AdviceId: advice_id,
  23883. DetItemFeeSumamt: item.DetItemFeeSumamt,
  23884. Cnt: item.Cnt,
  23885. Pric: float64(item.Pric),
  23886. PatientId: his.PatientId,
  23887. PricUplmtAmt: item.PricUplmtAmt,
  23888. SelfpayProp: item.SelfpayProp,
  23889. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  23890. OverlmtAmt: item.OverlmtAmt,
  23891. PreselfpayAmt: item.PreselfpayAmt,
  23892. BasMednFlag: item.BasMednFlag,
  23893. MedChrgitmType: item.MedChrgitmType,
  23894. HiNegoDrugFlag: item.HiNegoDrugFlag,
  23895. Status: 1,
  23896. Memo: item.Memo,
  23897. Mtime: time.Now().Unix(),
  23898. InscpScpAmt: item.InscpScpAmt,
  23899. DrtReimFlag: item.DrtReimFlag,
  23900. Ctime: time.Now().Unix(),
  23901. ListSpItemFlag: item.ListSpItemFlag,
  23902. ChldMedcFlag: item.ChldMedcFlag,
  23903. LmtUsedFlag: item.LmtUsedFlag,
  23904. ChrgitmLv: item.ChrgitmLv,
  23905. UserOrgId: adminUser.CurrentOrgId,
  23906. HisPatientId: his.ID,
  23907. OrderId: order.ID,
  23908. ProjectId: project_id,
  23909. Type: types,
  23910. }
  23911. service.CreateOrderInfo(info)
  23912. }
  23913. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  23914. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  23915. var total float64
  23916. for _, item := range prescriptions {
  23917. if item.Type == 1 { //药品
  23918. for _, subItem := range item.HisDoctorAdviceInfo {
  23919. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  23920. total_one := price * subItem.PrescribingNumber
  23921. total = total + total_one
  23922. }
  23923. }
  23924. if item.Type == 2 { //项目
  23925. for _, subItem := range item.HisPrescriptionProject {
  23926. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  23927. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  23928. total_one := price * cnt
  23929. total = total + total_one
  23930. }
  23931. }
  23932. }
  23933. allTotal := fmt.Sprintf("%.2f", total)
  23934. //if adminUser.CurrentOrgId == 9919 {
  23935. //
  23936. // allTotal = fmt.Sprintf("%.2f", total)
  23937. //
  23938. //} else {
  23939. //
  23940. // allTotal = fmt.Sprintf("%.2f", total)
  23941. //
  23942. //}
  23943. if res.Infcode == 0 {
  23944. var rf []*ResultFive
  23945. json.Unmarshal([]byte(his.Iinfo), &rf)
  23946. chrg_bchno := chrg_bchno
  23947. cert_no := his.Certno
  23948. var insutypes []string
  23949. var insutype string
  23950. var is390 int = 0
  23951. var is310 int = 0
  23952. for _, item := range rf {
  23953. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23954. insutypes = append(insutypes, item.Insutype)
  23955. }
  23956. }
  23957. if len(insutypes) == 1 {
  23958. insutype = insutypes[0]
  23959. } else {
  23960. for _, i := range insutypes {
  23961. if i == "390" {
  23962. is390 = 1
  23963. }
  23964. if i == "310" {
  23965. is310 = 1
  23966. }
  23967. }
  23968. }
  23969. if is390 == 1 {
  23970. insutype = "390"
  23971. }
  23972. if is310 == 1 {
  23973. insutype = "310"
  23974. }
  23975. if len(insutypes) == 0 {
  23976. insutype = "310"
  23977. }
  23978. if len(insutypes) == 2 {
  23979. insutype = strconv.FormatInt(his.SocialType, 10)
  23980. }
  23981. insutype = strconv.FormatInt(his.SocialType, 10)
  23982. //insutype = "390"
  23983. if his.IdCardType == 1 {
  23984. // cert_no = his.MedicalInsuranceNumber
  23985. cert_no = his.Certno
  23986. } else {
  23987. cert_no = his.Certno
  23988. }
  23989. var res ResultSeven
  23990. var resSeven10265 ResultSeven10265
  23991. var gzresSeven10265Two GZResultSeven10265Two
  23992. var src_resquest string
  23993. var result2 string
  23994. if miConfig.MdtrtareaAdmvs == "421300" {
  23995. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23996. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23997. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23998. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23999. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24000. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24001. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  24002. resp, requestErr := http.Get(api)
  24003. if requestErr != nil {
  24004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24005. return
  24006. }
  24007. body, ioErr := ioutil.ReadAll(resp.Body)
  24008. if ioErr != nil {
  24009. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24011. return
  24012. }
  24013. var respJSON map[string]interface{}
  24014. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24017. return
  24018. }
  24019. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24020. result, _ := json.Marshal(respJSON)
  24021. if miConfig.Code == "H15049901371" {
  24022. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  24023. utils.ErrorLog("解析失败:%v", err)
  24024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24025. return
  24026. }
  24027. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24028. res.Output = resSeven10265.Output
  24029. res.ErrMsg = resSeven10265.ErrMsg
  24030. res.Cainfo = resSeven10265.Cainfo
  24031. res.WarnMsg = resSeven10265.WarnMsg
  24032. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24033. res.Infcode = infocode
  24034. } else {
  24035. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24036. utils.ErrorLog("解析失败:%v", err)
  24037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24038. return
  24039. }
  24040. }
  24041. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24042. if reg_type == 11 && his.Insutype == "390" {
  24043. reg_type = 110104
  24044. }
  24045. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24046. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24047. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24048. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24049. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24050. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24051. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  24052. resp, requestErr := http.Get(api)
  24053. if requestErr != nil {
  24054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24055. return
  24056. }
  24057. body, ioErr := ioutil.ReadAll(resp.Body)
  24058. if ioErr != nil {
  24059. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24061. return
  24062. }
  24063. var respJSON map[string]interface{}
  24064. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24065. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24067. return
  24068. }
  24069. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24070. result, _ := json.Marshal(respJSON)
  24071. if miConfig.Code == "H15049901371" {
  24072. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  24073. utils.ErrorLog("解析失败:%v", err)
  24074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24075. return
  24076. }
  24077. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24078. res.Output = resSeven10265.Output
  24079. res.ErrMsg = resSeven10265.ErrMsg
  24080. res.Cainfo = resSeven10265.Cainfo
  24081. res.WarnMsg = resSeven10265.WarnMsg
  24082. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24083. res.Infcode = infocode
  24084. } else {
  24085. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24086. utils.ErrorLog("解析失败:%v", err)
  24087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24088. return
  24089. }
  24090. }
  24091. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24092. if reg_type == 11 && his.Insutype == "390" {
  24093. reg_type = 110104
  24094. }
  24095. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24096. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24097. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24098. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24099. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24100. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24101. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  24102. resp, requestErr := http.Get(api)
  24103. if requestErr != nil {
  24104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24105. return
  24106. }
  24107. body, ioErr := ioutil.ReadAll(resp.Body)
  24108. if ioErr != nil {
  24109. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24111. return
  24112. }
  24113. var respJSON map[string]interface{}
  24114. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24115. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24117. return
  24118. }
  24119. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24120. result, _ := json.Marshal(respJSON)
  24121. if miConfig.Code == "H15049901371" {
  24122. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  24123. utils.ErrorLog("解析失败:%v", err)
  24124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24125. return
  24126. }
  24127. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24128. res.Output = resSeven10265.Output
  24129. res.ErrMsg = resSeven10265.ErrMsg
  24130. res.Cainfo = resSeven10265.Cainfo
  24131. res.WarnMsg = resSeven10265.WarnMsg
  24132. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24133. res.Infcode = infocode
  24134. } else {
  24135. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24136. utils.ErrorLog("解析失败:%v", err)
  24137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24138. return
  24139. }
  24140. }
  24141. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24142. if reg_type == 11 && his.Insutype == "390" {
  24143. reg_type = 110104
  24144. }
  24145. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24146. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24147. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24148. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24149. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24150. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24151. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  24152. resp, requestErr := http.Get(api)
  24153. if requestErr != nil {
  24154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24155. return
  24156. }
  24157. body, ioErr := ioutil.ReadAll(resp.Body)
  24158. if ioErr != nil {
  24159. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24161. return
  24162. }
  24163. var respJSON map[string]interface{}
  24164. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24165. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24167. return
  24168. }
  24169. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24170. result, _ := json.Marshal(respJSON)
  24171. if miConfig.Code == "H15049901371" {
  24172. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  24173. utils.ErrorLog("解析失败:%v", err)
  24174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24175. return
  24176. }
  24177. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24178. res.Output = resSeven10265.Output
  24179. res.ErrMsg = resSeven10265.ErrMsg
  24180. res.Cainfo = resSeven10265.Cainfo
  24181. res.WarnMsg = resSeven10265.WarnMsg
  24182. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24183. res.Infcode = infocode
  24184. } else {
  24185. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24186. utils.ErrorLog("解析失败:%v", err)
  24187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24188. return
  24189. }
  24190. }
  24191. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24192. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  24193. if result3101.Infcode == "0" {
  24194. if len(result3101.Output.Result) > 0 {
  24195. var errMsgs []string
  24196. for _, item := range result3101.Output.Result {
  24197. errMsgs = append(errMsgs, item.VolaCont)
  24198. }
  24199. c.ServeSuccessJSON(map[string]interface{}{
  24200. "failed_code": -10,
  24201. "msg": errMsgs,
  24202. })
  24203. return
  24204. } else {
  24205. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24206. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24207. bas := strings.Split(psn_info.CardInfo, "|")
  24208. if his.IdCardType == 1 {
  24209. cert_no = bas[2]
  24210. } else if his.IdCardType == 3 {
  24211. cert_no = his.Certno
  24212. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  24213. } else if his.IdCardType == 4 {
  24214. cert_no = his.Certno
  24215. psn_info.VerifyNumber = psn_info.VerifyNumber
  24216. }
  24217. var api string
  24218. if miConfig.MdtrtareaAdmvs == "320921" {
  24219. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24220. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24221. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24222. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24223. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24224. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24225. "&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
  24226. } else {
  24227. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24228. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24229. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24230. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24231. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24232. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24233. "&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
  24234. }
  24235. resp, requestErr := http.Get(api)
  24236. if requestErr != nil {
  24237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24238. return
  24239. }
  24240. body, ioErr := ioutil.ReadAll(resp.Body)
  24241. if ioErr != nil {
  24242. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24244. return
  24245. }
  24246. var respJSON map[string]interface{}
  24247. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24248. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24250. return
  24251. }
  24252. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24253. result, _ := json.Marshal(respJSON)
  24254. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  24255. utils.ErrorLog("解析失败:%v", err)
  24256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24257. return
  24258. }
  24259. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24260. res.Output = resSeven10265.Output
  24261. res.ErrMsg = resSeven10265.ErrMsg
  24262. res.Cainfo = resSeven10265.Cainfo
  24263. res.WarnMsg = resSeven10265.WarnMsg
  24264. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24265. res.Infcode = infocode
  24266. }
  24267. }
  24268. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24269. psn_info, _ := service.GetPsnByPatientId(id)
  24270. var verify_number string
  24271. if psn_info.IdCardType == 4 {
  24272. verify_number = psn_info.VerifyNumber
  24273. } else if psn_info.IdCardType == 1 {
  24274. bas := strings.Split(psn_info.CardInfo, "|")
  24275. cardNumber := bas[2]
  24276. verify_number = cardNumber
  24277. } else {
  24278. psn_info.IdCardType = 2
  24279. verify_number = psn_info.Certno
  24280. }
  24281. var api string
  24282. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24283. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24284. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24285. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24286. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24287. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24288. "&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
  24289. resp, requestErr := http.Get(api)
  24290. if requestErr != nil {
  24291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24292. return
  24293. }
  24294. body, ioErr := ioutil.ReadAll(resp.Body)
  24295. if ioErr != nil {
  24296. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24298. return
  24299. }
  24300. var respJSON map[string]interface{}
  24301. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24302. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  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), &resSeven10265); err != nil {
  24309. utils.ErrorLog("解析失败:%v", err)
  24310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24311. return
  24312. }
  24313. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24314. res.Output = resSeven10265.Output
  24315. res.ErrMsg = resSeven10265.ErrMsg
  24316. res.Cainfo = resSeven10265.Cainfo
  24317. res.WarnMsg = resSeven10265.WarnMsg
  24318. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24319. res.Infcode = infocode
  24320. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24321. var cert_no string
  24322. if his.IdCardType == 4 {
  24323. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24324. cert_no = psn_info.VerifyNumber
  24325. 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)
  24326. } else if his.IdCardType == 1 {
  24327. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24328. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  24329. 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)
  24330. }
  24331. //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)
  24332. var dat map[string]interface{}
  24333. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24334. fmt.Println(dat)
  24335. } else {
  24336. fmt.Println(err)
  24337. }
  24338. saveLog(result2, src_resquest, "2207", "结算")
  24339. userJSONBytes, _ := json.Marshal(dat)
  24340. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  24341. utils.ErrorLog("解析失败:%v", err)
  24342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24343. return
  24344. }
  24345. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24346. res.Output = resSeven10265.Output
  24347. res.ErrMsg = resSeven10265.ErrMsg
  24348. res.Cainfo = resSeven10265.Cainfo
  24349. res.WarnMsg = resSeven10265.WarnMsg
  24350. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24351. res.Infcode = infocode
  24352. } else if miConfig.MdtrtareaAdmvs == "450721" {
  24353. res2 := c.GetoleInfo()
  24354. if res2.Infcode == 0 {
  24355. var result string
  24356. var request_log string
  24357. var result_log string
  24358. if res2.Output.MdtrtCertType == "02" {
  24359. 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)
  24360. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  24361. } else if res2.Output.MdtrtCertType == "01" {
  24362. 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)
  24363. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  24364. } else {
  24365. 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)
  24366. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  24367. }
  24368. var dat map[string]interface{}
  24369. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24370. fmt.Println(dat)
  24371. } else {
  24372. fmt.Println(err)
  24373. }
  24374. userJSONBytes, _ := json.Marshal(dat)
  24375. var res5 ResultTwo
  24376. //var resTwo10265 ResultTwo10265
  24377. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  24378. utils.ErrorLog("解析失败:%v", err)
  24379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24380. return
  24381. }
  24382. if res5.Infcode == -1 {
  24383. c.ServeSuccessJSON(map[string]interface{}{
  24384. "failed_code": -10,
  24385. "msg": res5.ErrMsg,
  24386. })
  24387. return
  24388. }
  24389. var insutypes []string
  24390. var insutype string
  24391. var is390 int = 0
  24392. var is310 int = 0
  24393. for _, item := range res5.Output.Iinfo {
  24394. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24395. insutypes = append(insutypes, item.Insutype)
  24396. }
  24397. }
  24398. if len(insutypes) == 1 {
  24399. insutype = insutypes[0]
  24400. } else {
  24401. for _, i := range insutypes {
  24402. if i == "390" {
  24403. is390 = 1
  24404. }
  24405. if i == "310" {
  24406. is310 = 1
  24407. }
  24408. }
  24409. }
  24410. if is390 == 1 {
  24411. insutype = "390"
  24412. }
  24413. if is310 == 1 {
  24414. insutype = "310"
  24415. }
  24416. if len(insutypes) == 0 {
  24417. insutype = "310"
  24418. }
  24419. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  24420. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  24421. infoStr := string(Iinfos)
  24422. idetinfoStr := string(Idetinfos)
  24423. psn := &models.HisPsn{
  24424. PsnNo: res5.Output.Baseinfo.PsnNo,
  24425. PatientId: id,
  24426. Certno: res5.Output.Baseinfo.Certno,
  24427. Gend: res5.Output.Baseinfo.Gend,
  24428. Naty: res5.Output.Baseinfo.Naty,
  24429. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  24430. PsnName: res5.Output.Baseinfo.PsnName,
  24431. Idetinfo: idetinfoStr,
  24432. Insuinfo: infoStr,
  24433. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  24434. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  24435. VerifyNumber: res2.Output.EcToken,
  24436. }
  24437. if res2.Output.MdtrtCertType == "01" {
  24438. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24439. psn.VerifyNumber = res2.Output.EcToken
  24440. } else if res2.Output.MdtrtCertType == "02" {
  24441. psn.VerifyNumber = res2.Output.CardNo
  24442. } else {
  24443. psn.VerifyNumber = res2.Output.MdtrtCertNo
  24444. }
  24445. service.CreateHisPsn(psn)
  24446. if res2.Output.MdtrtCertType == "01" {
  24447. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24448. token := res2.Output.EcToken
  24449. 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)
  24450. } else if res2.Output.MdtrtCertType == "02" {
  24451. 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)
  24452. } else {
  24453. 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)
  24454. }
  24455. var dat2 map[string]interface{}
  24456. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  24457. fmt.Println(dat2)
  24458. } else {
  24459. fmt.Println(err)
  24460. }
  24461. userJSONBytes3, _ := json.Marshal(dat2)
  24462. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24463. utils.ErrorLog("解析失败:%v", err)
  24464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24465. return
  24466. }
  24467. saveLog(result2, src_resquest, "2207", "结算")
  24468. } else {
  24469. c.ServeSuccessJSON(map[string]interface{}{
  24470. "failed_code": -10,
  24471. "msg": res2.ErrMsg,
  24472. })
  24473. return
  24474. }
  24475. } else {
  24476. if miConfig.Code == "H15049901371" {
  24477. //赤峰地区国家医保医疗类别
  24478. //职工透析:医疗类别选特殊情况门诊990502
  24479. //居民定额血透门慢: 医疗类别选门诊慢病140104
  24480. var med_type string
  24481. if his.Insutype == "390" {
  24482. if reg_type == 14 {
  24483. med_type = "9933"
  24484. } else if reg_type == 11 {
  24485. med_type = "11"
  24486. }
  24487. } else if his.Insutype == "310" {
  24488. if reg_type == 14 {
  24489. med_type = "990502"
  24490. } else if reg_type == 11 {
  24491. med_type = "11"
  24492. }
  24493. }
  24494. 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)
  24495. } else {
  24496. if his.IdCardType == 4 {
  24497. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24498. var token string
  24499. token = psn_info.VerifyNumber
  24500. 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)
  24501. } else {
  24502. if his.IdCardType == 1 {
  24503. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24504. bas := strings.Split(psn_info.CardInfo, "|")
  24505. basNumber := bas[2]
  24506. cert_no = basNumber
  24507. }
  24508. 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)
  24509. }
  24510. }
  24511. //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)
  24512. var dat map[string]interface{}
  24513. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24514. fmt.Println(dat)
  24515. } else {
  24516. fmt.Println(err)
  24517. }
  24518. saveLog(result2, src_resquest, "2207", "结算")
  24519. userJSONBytes, _ := json.Marshal(dat)
  24520. if miConfig.Code == "H15049901371" {
  24521. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  24522. utils.ErrorLog("解析失败:%v", err)
  24523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24524. return
  24525. }
  24526. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24527. res.Output = resSeven10265.Output
  24528. res.ErrMsg = resSeven10265.ErrMsg
  24529. res.Cainfo = resSeven10265.Cainfo
  24530. res.WarnMsg = resSeven10265.WarnMsg
  24531. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24532. res.Infcode = infocode
  24533. } else {
  24534. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24535. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  24536. utils.ErrorLog("解析失败:%v", err)
  24537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24538. return
  24539. }
  24540. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  24541. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  24542. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  24543. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  24544. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  24545. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  24546. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  24547. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  24548. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  24549. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24550. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24551. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24552. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24553. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  24554. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  24555. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  24556. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  24557. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  24558. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  24559. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  24560. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  24561. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  24562. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  24563. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  24564. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  24565. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  24566. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  24567. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  24568. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  24569. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  24570. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  24571. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  24572. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  24573. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  24574. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  24575. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  24576. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  24577. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  24578. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24579. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  24580. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  24581. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  24582. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  24583. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  24584. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  24585. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  24586. res.ErrMsg = gzresSeven10265Two.ErrMsg
  24587. res.Cainfo = gzresSeven10265Two.Cainfo
  24588. res.WarnMsg = gzresSeven10265Two.WarnMsg
  24589. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  24590. //res.Infcode = infocode
  24591. } else {
  24592. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24593. utils.ErrorLog("解析失败:%v", err)
  24594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24595. return
  24596. }
  24597. }
  24598. }
  24599. }
  24600. if res.Infcode == -1 {
  24601. errlog := &models.HisOrderError{
  24602. UserOrgId: adminUser.CurrentOrgId,
  24603. Ctime: time.Now().Unix(),
  24604. Mtime: time.Now().Unix(),
  24605. Number: chrg_bchno,
  24606. ErrMsg: res.ErrMsg,
  24607. Status: 1,
  24608. PatientId: id,
  24609. RecordTime: recordDateTime,
  24610. Stage: 6,
  24611. }
  24612. service.CreateErrMsgLog(errlog)
  24613. c.ServeSuccessJSON(map[string]interface{}{
  24614. "failed_code": -10,
  24615. "msg": res.ErrMsg,
  24616. })
  24617. return
  24618. } else {
  24619. sickConfig, _ := service.FindSickById(his.SickType)
  24620. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  24621. order.OrderStatus = 2
  24622. order.Status = 1
  24623. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  24624. order.SetlId = res.Output.Setlinfo.SetlID
  24625. order.PsnNo = res.Output.Setlinfo.PsnNo
  24626. order.PsnName = res.Output.Setlinfo.PsnName
  24627. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  24628. order.Certno = res.Output.Setlinfo.Certno
  24629. order.Gend = res.Output.Setlinfo.Gend
  24630. order.Naty = res.Output.Setlinfo.Naty
  24631. order.Age = res.Output.Setlinfo.Age
  24632. order.Insutype = res.Output.Setlinfo.Insutype
  24633. order.PsnType = res.Output.Setlinfo.PsnType
  24634. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  24635. order.SetlTime = res.Output.Setlinfo.SetlTime
  24636. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  24637. if res.Output.Setlinfo.MedType == "140101" {
  24638. order.MedType = "14"
  24639. } else {
  24640. if res.Output.Setlinfo.MedType == "110104" {
  24641. order.MedType = "11"
  24642. } else {
  24643. order.MedType = res.Output.Setlinfo.MedType
  24644. }
  24645. }
  24646. if reg_type == 1112 {
  24647. order.MedType = "1112"
  24648. }
  24649. if reg_type == 1111 {
  24650. order.MedType = "1111"
  24651. }
  24652. order.ClrType = res.Output.Setlinfo.ClrType
  24653. if adminUser.CurrentOrgId == 10480 {
  24654. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  24655. order.ClrType = "11"
  24656. } else {
  24657. order.ClrType = "9903"
  24658. }
  24659. }
  24660. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  24661. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  24662. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  24663. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  24664. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  24665. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  24666. order.HifpPay = res.Output.Setlinfo.HifpPay
  24667. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  24668. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  24669. order.HifesPay = res.Output.Setlinfo.HifesPay
  24670. order.HifobPay = res.Output.Setlinfo.HifobPay
  24671. order.MafPay = res.Output.Setlinfo.MafPay
  24672. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  24673. order.OthPay = res.Output.Setlinfo.OthPay
  24674. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  24675. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  24676. order.AcctPay = res.Output.Setlinfo.AcctPay
  24677. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  24678. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  24679. order.Balc = res.Output.Setlinfo.Balc
  24680. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  24681. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  24682. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  24683. //order.ClrType = res.Output.Setlinfo.ClrType
  24684. order.ClrWay = res.Output.Setlinfo.ClrWay
  24685. order.Creator = order.Creator
  24686. order.Modify = roles.AdminUserId
  24687. order.RequestLog = src_resquest
  24688. order.FaPiaoNumber = fapiao_number
  24689. order.FaPiaoCode = fapiao_code
  24690. order.SickName = sickConfig.ClassName
  24691. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  24692. //detailStr := string(setlDetail)
  24693. //order.SetlDetail = detailStr
  24694. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  24695. err = service.UpDateOrder(order)
  24696. if err == nil {
  24697. //判断是否使用了押金
  24698. if dec_way == "true" {
  24699. tmpstring := strconv.FormatInt(order.ID, 10)
  24700. order.Decimal = decimal
  24701. service.UpDateOrder(order)
  24702. //扣押金
  24703. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  24704. if errmsg != nil {
  24705. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  24706. return
  24707. }
  24708. }
  24709. c.ServeSuccessJSON(map[string]interface{}{
  24710. "msg": "结算成功",
  24711. })
  24712. } else {
  24713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  24714. return
  24715. }
  24716. }
  24717. } else {
  24718. adminUser := c.GetAdminUserInfo()
  24719. errlog := &models.HisOrderError{
  24720. UserOrgId: adminUser.CurrentOrgId,
  24721. Ctime: time.Now().Unix(),
  24722. Mtime: time.Now().Unix(),
  24723. ErrMsg: res.ErrMsg,
  24724. Status: 1,
  24725. PatientId: id,
  24726. RecordTime: recordDateTime,
  24727. Stage: 4,
  24728. }
  24729. service.CreateErrMsgLog(errlog)
  24730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  24731. return
  24732. }
  24733. } else {
  24734. adminUser := c.GetAdminUserInfo()
  24735. errlog := &models.HisOrderError{
  24736. UserOrgId: adminUser.CurrentOrgId,
  24737. Ctime: time.Now().Unix(),
  24738. Mtime: time.Now().Unix(),
  24739. ErrMsg: res.ErrMsg,
  24740. Status: 1,
  24741. PatientId: id,
  24742. RecordTime: recordDateTime,
  24743. Stage: 4,
  24744. }
  24745. service.CreateErrMsgLog(errlog)
  24746. c.ServeSuccessJSON(map[string]interface{}{
  24747. "failed_code": -10,
  24748. "msg": res.ErrMsg,
  24749. })
  24750. return
  24751. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  24752. //return
  24753. }
  24754. }
  24755. }
  24756. } else if tempOrder.ID > 0 {
  24757. if tempOrder.IsPre == 1 {
  24758. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  24759. var rf []*ResultFive
  24760. json.Unmarshal([]byte(his.Iinfo), &rf)
  24761. chrg_bchno := tempOrder.Number
  24762. cert_no := his.Certno
  24763. var insutypes []string
  24764. var insutype string
  24765. var is390 int = 0
  24766. var is310 int = 0
  24767. for _, item := range rf {
  24768. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24769. insutypes = append(insutypes, item.Insutype)
  24770. }
  24771. }
  24772. if len(insutypes) == 1 {
  24773. insutype = insutypes[0]
  24774. } else {
  24775. for _, i := range insutypes {
  24776. if i == "390" {
  24777. is390 = 1
  24778. }
  24779. if i == "310" {
  24780. is310 = 1
  24781. }
  24782. }
  24783. }
  24784. if is390 == 1 {
  24785. insutype = "390"
  24786. }
  24787. if is310 == 1 {
  24788. insutype = "310"
  24789. }
  24790. if len(insutypes) == 0 {
  24791. insutype = "310"
  24792. }
  24793. if len(insutypes) == 2 {
  24794. insutype = strconv.FormatInt(his.SocialType, 10)
  24795. }
  24796. //insutype = "390"
  24797. if his.IdCardType == 1 {
  24798. // cert_no = his.MedicalInsuranceNumber
  24799. cert_no = his.Certno
  24800. } else {
  24801. cert_no = his.Certno
  24802. }
  24803. var res ResultSeven
  24804. var ahres ResultSevenAH
  24805. var resSeven10265 ResultSeven10265
  24806. var gzresSeven10265Two GZResultSeven10265Two
  24807. var src_resquest string
  24808. var result2 string
  24809. if miConfig.MdtrtareaAdmvs == "450721" {
  24810. res2 := c.GetoleInfo()
  24811. if res2.Infcode == 0 {
  24812. var result string
  24813. var request_log string
  24814. var result_log string
  24815. if res2.Output.MdtrtCertType == "02" {
  24816. 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)
  24817. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  24818. } else if res2.Output.MdtrtCertType == "01" {
  24819. 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)
  24820. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  24821. } else {
  24822. 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)
  24823. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  24824. }
  24825. var dat map[string]interface{}
  24826. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24827. fmt.Println(dat)
  24828. } else {
  24829. fmt.Println(err)
  24830. }
  24831. userJSONBytes, _ := json.Marshal(dat)
  24832. var res5 ResultTwo
  24833. //var resTwo10265 ResultTwo10265
  24834. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  24835. utils.ErrorLog("解析失败:%v", err)
  24836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24837. return
  24838. }
  24839. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  24840. if res5.Infcode == -1 {
  24841. c.ServeSuccessJSON(map[string]interface{}{
  24842. "failed_code": -10,
  24843. "msg": res5.ErrMsg,
  24844. })
  24845. return
  24846. }
  24847. var insutypes []string
  24848. var insutype string
  24849. var is390 int = 0
  24850. var is310 int = 0
  24851. for _, item := range res5.Output.Iinfo {
  24852. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24853. insutypes = append(insutypes, item.Insutype)
  24854. }
  24855. }
  24856. if len(insutypes) == 1 {
  24857. insutype = insutypes[0]
  24858. } else {
  24859. for _, i := range insutypes {
  24860. if i == "390" {
  24861. is390 = 1
  24862. }
  24863. if i == "310" {
  24864. is310 = 1
  24865. }
  24866. }
  24867. }
  24868. if is390 == 1 {
  24869. insutype = "390"
  24870. }
  24871. if is310 == 1 {
  24872. insutype = "310"
  24873. }
  24874. if len(insutypes) == 0 {
  24875. insutype = "310"
  24876. }
  24877. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  24878. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  24879. infoStr := string(Iinfos)
  24880. idetinfoStr := string(Idetinfos)
  24881. psn := &models.HisPsn{
  24882. PsnNo: res5.Output.Baseinfo.PsnNo,
  24883. PatientId: id,
  24884. Certno: res5.Output.Baseinfo.Certno,
  24885. Gend: res5.Output.Baseinfo.Gend,
  24886. Naty: res5.Output.Baseinfo.Naty,
  24887. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  24888. PsnName: res5.Output.Baseinfo.PsnName,
  24889. Idetinfo: idetinfoStr,
  24890. Insuinfo: infoStr,
  24891. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  24892. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  24893. VerifyNumber: res2.Output.EcToken,
  24894. }
  24895. service.CreateHisPsn(psn)
  24896. if res2.Output.MdtrtCertType == "01" {
  24897. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24898. token := res2.Output.EcToken
  24899. 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)
  24900. } else if res2.Output.MdtrtCertType == "02" {
  24901. 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)
  24902. } else {
  24903. 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)
  24904. }
  24905. var dat2 map[string]interface{}
  24906. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  24907. fmt.Println(dat2)
  24908. } else {
  24909. fmt.Println(err)
  24910. }
  24911. userJSONBytes3, _ := json.Marshal(dat2)
  24912. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24913. utils.ErrorLog("解析失败:%v", err)
  24914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24915. return
  24916. }
  24917. saveLog(result2, src_resquest, "2207", "结算")
  24918. } else {
  24919. c.ServeSuccessJSON(map[string]interface{}{
  24920. "failed_code": -10,
  24921. "msg": res2.ErrMsg,
  24922. })
  24923. return
  24924. }
  24925. } else if miConfig.MdtrtareaAdmvs == "421300" {
  24926. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24927. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24928. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24929. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24930. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24931. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24932. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  24933. resp, requestErr := http.Get(api)
  24934. if requestErr != nil {
  24935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24936. return
  24937. }
  24938. body, ioErr := ioutil.ReadAll(resp.Body)
  24939. if ioErr != nil {
  24940. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24942. return
  24943. }
  24944. var respJSON map[string]interface{}
  24945. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24946. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24948. return
  24949. }
  24950. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24951. result, _ := json.Marshal(respJSON)
  24952. fmt.Println("log")
  24953. fmt.Println(string(result))
  24954. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24955. utils.ErrorLog("解析失败:%v", err)
  24956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24957. return
  24958. }
  24959. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24960. if reg_type == 11 && his.Insutype == "390" {
  24961. reg_type = 110104
  24962. }
  24963. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24964. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24965. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24966. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24967. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24968. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24969. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  24970. resp, requestErr := http.Get(api)
  24971. if requestErr != nil {
  24972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24973. return
  24974. }
  24975. body, ioErr := ioutil.ReadAll(resp.Body)
  24976. if ioErr != nil {
  24977. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24979. return
  24980. }
  24981. var respJSON map[string]interface{}
  24982. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24983. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24985. return
  24986. }
  24987. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24988. result, _ := json.Marshal(respJSON)
  24989. fmt.Println("log")
  24990. fmt.Println(string(result))
  24991. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24992. utils.ErrorLog("解析失败:%v", err)
  24993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24994. return
  24995. }
  24996. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24997. if reg_type == 11 && his.Insutype == "390" {
  24998. reg_type = 110104
  24999. }
  25000. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25001. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25002. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25003. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25004. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25005. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25006. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25007. resp, requestErr := http.Get(api)
  25008. if requestErr != nil {
  25009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25010. return
  25011. }
  25012. body, ioErr := ioutil.ReadAll(resp.Body)
  25013. if ioErr != nil {
  25014. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25016. return
  25017. }
  25018. var respJSON map[string]interface{}
  25019. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25020. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25022. return
  25023. }
  25024. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25025. result, _ := json.Marshal(respJSON)
  25026. fmt.Println("log")
  25027. fmt.Println(string(result))
  25028. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25029. utils.ErrorLog("解析失败:%v", err)
  25030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25031. return
  25032. }
  25033. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25034. if reg_type == 11 && his.Insutype == "390" {
  25035. reg_type = 110104
  25036. }
  25037. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25038. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25039. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25040. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25041. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25042. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25043. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  25044. resp, requestErr := http.Get(api)
  25045. if requestErr != nil {
  25046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25047. return
  25048. }
  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(string(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. result, _ := json.Marshal(respJSON)
  25063. fmt.Println("log")
  25064. fmt.Println(string(result))
  25065. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25066. utils.ErrorLog("解析失败:%v", err)
  25067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25068. return
  25069. }
  25070. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25071. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  25072. if result3101.Infcode == "0" {
  25073. if len(result3101.Output.Result) > 0 {
  25074. var errMsgs []string
  25075. for _, item := range result3101.Output.Result {
  25076. errMsgs = append(errMsgs, item.VolaCont)
  25077. }
  25078. c.ServeSuccessJSON(map[string]interface{}{
  25079. "failed_code": -10,
  25080. "msg": errMsgs,
  25081. })
  25082. return
  25083. } else {
  25084. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25085. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25086. bas := strings.Split(psn_info.CardInfo, "|")
  25087. if his.IdCardType == 1 {
  25088. cert_no = bas[2]
  25089. } else if his.IdCardType == 3 {
  25090. cert_no = his.Certno
  25091. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  25092. } else if his.IdCardType == 4 {
  25093. cert_no = his.Certno
  25094. psn_info.VerifyNumber = psn_info.VerifyNumber
  25095. }
  25096. //江苏地区国家医保医疗类别
  25097. //职工透析:医疗类别选特殊情况门诊9933
  25098. //居民血透门慢: 医疗类别选门诊慢病1402
  25099. //var med_type string
  25100. //if his.Insutype == "310" {
  25101. // if reg_type == 14 {
  25102. // med_type = "9933"
  25103. // } else if reg_type == 11 {
  25104. // med_type = "11"
  25105. //
  25106. // }
  25107. //} else if his.Insutype == "390" {
  25108. // if reg_type == 14 {
  25109. // med_type = "1402"
  25110. // } else if reg_type == 11 {
  25111. // med_type = "11"
  25112. // }
  25113. //}
  25114. var api string
  25115. if miConfig.MdtrtareaAdmvs == "320921" {
  25116. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25117. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25118. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25119. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25120. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25121. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25122. "&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
  25123. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25124. } else {
  25125. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25126. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25127. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25128. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25129. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25130. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25131. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25132. "&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
  25133. }
  25134. resp, requestErr := http.Get(api)
  25135. if requestErr != nil {
  25136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25137. return
  25138. }
  25139. body, ioErr := ioutil.ReadAll(resp.Body)
  25140. if ioErr != nil {
  25141. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25143. return
  25144. }
  25145. var respJSON map[string]interface{}
  25146. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25147. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25149. return
  25150. }
  25151. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25152. result, _ := json.Marshal(respJSON)
  25153. fmt.Println("log")
  25154. fmt.Println(string(result))
  25155. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25156. utils.ErrorLog("解析失败:%v", err)
  25157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25158. return
  25159. }
  25160. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25161. res.Output = resSeven10265.Output
  25162. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25163. res.ErrMsg = resSeven10265.ErrMsg
  25164. res.Cainfo = resSeven10265.Cainfo
  25165. res.WarnMsg = resSeven10265.WarnMsg
  25166. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25167. res.Infcode = infocode
  25168. }
  25169. }
  25170. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25171. psn_info, _ := service.GetPsnByPatientId(id)
  25172. var verify_number string
  25173. if psn_info.IdCardType == 4 {
  25174. verify_number = psn_info.VerifyNumber
  25175. } else if psn_info.IdCardType == 1 {
  25176. bas := strings.Split(psn_info.CardInfo, "|")
  25177. cardNumber := bas[2]
  25178. verify_number = cardNumber
  25179. } else {
  25180. verify_number = psn_info.Certno
  25181. psn_info.IdCardType = 2
  25182. }
  25183. var api string
  25184. new_chrg_bchno := chrg_bchno
  25185. if adminUser.CurrentOrgId == 10265 {
  25186. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  25187. new_chrg_bchno = "0000"
  25188. }
  25189. }
  25190. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25191. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  25192. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25193. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25194. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  25195. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25196. "&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
  25197. resp, requestErr := http.Get(api)
  25198. if requestErr != nil {
  25199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25200. return
  25201. }
  25202. body, ioErr := ioutil.ReadAll(resp.Body)
  25203. if ioErr != nil {
  25204. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25206. return
  25207. }
  25208. var respJSON map[string]interface{}
  25209. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25210. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25212. return
  25213. }
  25214. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25215. result, _ := json.Marshal(respJSON)
  25216. fmt.Println("log")
  25217. fmt.Println(string(result))
  25218. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25219. utils.ErrorLog("解析失败:%v", err)
  25220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25221. return
  25222. }
  25223. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25224. res.Output = resSeven10265.Output
  25225. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25226. res.ErrMsg = resSeven10265.ErrMsg
  25227. res.Cainfo = resSeven10265.Cainfo
  25228. res.WarnMsg = resSeven10265.WarnMsg
  25229. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25230. res.Infcode = infocode
  25231. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25232. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25233. var cert_no string
  25234. if his.IdCardType == 1 {
  25235. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25236. } else {
  25237. cert_no = psn_info.VerifyNumber
  25238. }
  25239. 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)
  25240. var dat map[string]interface{}
  25241. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25242. fmt.Println(dat)
  25243. } else {
  25244. fmt.Println(err)
  25245. }
  25246. saveLog(result2, src_resquest, "2207", "结算")
  25247. userJSONBytes, _ := json.Marshal(dat)
  25248. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25249. utils.ErrorLog("解析失败:%v", err)
  25250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25251. return
  25252. }
  25253. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25254. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25255. var cert_no string
  25256. var card_sn string
  25257. if his.IdCardType == 1 {
  25258. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25259. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25260. bas := strings.Split(psn_info.CardInfo, "|")
  25261. card_sn = bas[3]
  25262. } else if his.IdCardType == 2 {
  25263. cert_no = his.IdCardNo
  25264. } else {
  25265. cert_no = psn_info.VerifyNumber
  25266. }
  25267. var rf []*ResultFive
  25268. json.Unmarshal([]byte(his.Iinfo), &rf)
  25269. var psn_type string
  25270. for _, item := range rf {
  25271. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  25272. psn_type = item.PsnType
  25273. }
  25274. }
  25275. 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)
  25276. var dat map[string]interface{}
  25277. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25278. fmt.Println(dat)
  25279. } else {
  25280. fmt.Println(err)
  25281. }
  25282. saveLog(result2, src_resquest, "2207", "结算")
  25283. userJSONBytes, _ := json.Marshal(dat)
  25284. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25285. utils.ErrorLog("解析失败:%v", err)
  25286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25287. return
  25288. }
  25289. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25290. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25291. if his.IdCardType == 1 {
  25292. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25293. bas := strings.Split(psn_info.CardInfo, "|")
  25294. cert_no = bas[2]
  25295. } else if his.IdCardType == 3 {
  25296. cert_no = his.Certno
  25297. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  25298. } else if his.IdCardType == 4 {
  25299. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25300. cert_no = his.Certno
  25301. psn_info.VerifyNumber = psn_info.VerifyNumber
  25302. } else {
  25303. cert_no = his.Certno
  25304. psn_info.VerifyNumber = his.Certno
  25305. }
  25306. var api string
  25307. var med_type string
  25308. if his.Insutype == "390" {
  25309. if reg_type == 992102 {
  25310. med_type = "992102"
  25311. }
  25312. if reg_type == 140104 {
  25313. med_type = "140104"
  25314. }
  25315. if reg_type == 14 {
  25316. med_type = "14"
  25317. }
  25318. } else if his.Insutype == "310" {
  25319. if reg_type == 992102 {
  25320. med_type = "992102"
  25321. }
  25322. if reg_type == 14 {
  25323. med_type = "14"
  25324. }
  25325. }
  25326. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25327. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25328. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25329. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25330. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25331. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25332. "&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
  25333. resp, requestErr := http.Get(api)
  25334. if requestErr != nil {
  25335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25336. return
  25337. }
  25338. body, ioErr := ioutil.ReadAll(resp.Body)
  25339. if ioErr != nil {
  25340. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25342. return
  25343. }
  25344. var respJSON map[string]interface{}
  25345. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25346. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25348. return
  25349. }
  25350. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25351. if status == "0" {
  25352. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25353. c.ServeSuccessJSON(map[string]interface{}{
  25354. "failed_code": -10,
  25355. "msg": err_msg,
  25356. })
  25357. return
  25358. }
  25359. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25360. result, _ := json.Marshal(respJSON)
  25361. fmt.Println("log")
  25362. fmt.Println(string(result))
  25363. if err := json.Unmarshal(result, &ahres); err != nil {
  25364. utils.ErrorLog("解析失败:%v", err)
  25365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25366. return
  25367. }
  25368. res.InfRefmsgid = ahres.InfRefmsgid
  25369. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  25370. // 创建对应的Time类型
  25371. t := time.UnixMilli(timestamp)
  25372. // 格式化成指定的日期字符串
  25373. str := t.Format("2006-01-02 15:04:05")
  25374. res.Output.Setlinfo.SetlTime = str
  25375. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  25376. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  25377. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  25378. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  25379. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  25380. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  25381. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  25382. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  25383. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  25384. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  25385. res.Output.Setlinfo.ClrType = "11"
  25386. } else {
  25387. res.Output.Setlinfo.ClrType = "9903"
  25388. }
  25389. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  25390. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  25391. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  25392. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  25393. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  25394. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  25395. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  25396. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  25397. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  25398. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  25399. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  25400. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  25401. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  25402. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  25403. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  25404. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  25405. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  25406. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  25407. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  25408. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  25409. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  25410. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  25411. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  25412. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  25413. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  25414. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  25415. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  25416. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  25417. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  25418. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  25419. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  25420. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  25421. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  25422. res.Output.Setldetail = ahres.Output.Setldetail
  25423. res.ErrMsg = ahres.ErrMsg
  25424. res.Cainfo = ahres.Cainfo
  25425. res.WarnMsg = ahres.WarnMsg
  25426. res.Infcode = ahres.Infcode
  25427. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25428. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25429. var cert_no string
  25430. if his.IdCardType == 1 {
  25431. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25432. } else if his.IdCardType == 2 {
  25433. cert_no = his.IdCardNo
  25434. } else {
  25435. cert_no = psn_info.VerifyNumber
  25436. }
  25437. 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, "")
  25438. var dat map[string]interface{}
  25439. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25440. fmt.Println(dat)
  25441. } else {
  25442. fmt.Println(err)
  25443. }
  25444. saveLog(result2, src_resquest, "2207", "结算")
  25445. userJSONBytes, _ := json.Marshal(dat)
  25446. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25447. utils.ErrorLog("解析失败:%v", err)
  25448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25449. return
  25450. }
  25451. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25452. psn_info, _ := service.GetPsnByPatientId(id)
  25453. var verify_number string
  25454. if psn_info.IdCardType == 4 {
  25455. verify_number = psn_info.VerifyNumber
  25456. } else if psn_info.IdCardType == 1 {
  25457. bas := strings.Split(psn_info.CardInfo, "|")
  25458. cardNumber := bas[2]
  25459. verify_number = cardNumber
  25460. } else {
  25461. verify_number = psn_info.Certno
  25462. psn_info.IdCardType = 2
  25463. }
  25464. var api string
  25465. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25466. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25467. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25468. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25469. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  25470. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25471. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  25472. resp, requestErr := http.Get(api)
  25473. if requestErr != nil {
  25474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25475. return
  25476. }
  25477. body, ioErr := ioutil.ReadAll(resp.Body)
  25478. if ioErr != nil {
  25479. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25481. return
  25482. }
  25483. var respJSON map[string]interface{}
  25484. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25485. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25487. return
  25488. }
  25489. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25490. result, _ := json.Marshal(respJSON)
  25491. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25492. utils.ErrorLog("解析失败:%v", err)
  25493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25494. return
  25495. }
  25496. } else {
  25497. var src_resquest string
  25498. if miConfig.Code == "H15049901371" {
  25499. //赤峰地区国家医保医疗类别
  25500. //职工透析:医疗类别选特殊情况门诊990502
  25501. //居民定额血透门慢: 医疗类别选门诊慢病140104
  25502. var med_type string
  25503. if his.Insutype == "390" {
  25504. if reg_type == 14 {
  25505. med_type = "9933"
  25506. } else if reg_type == 11 {
  25507. med_type = "11"
  25508. }
  25509. } else if his.Insutype == "310" {
  25510. if reg_type == 14 {
  25511. med_type = "990502"
  25512. } else if reg_type == 11 {
  25513. med_type = "11"
  25514. }
  25515. }
  25516. 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)
  25517. } else {
  25518. if his.IdCardType == 4 {
  25519. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25520. token := psn_info.VerifyNumber
  25521. 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)
  25522. } else {
  25523. 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)
  25524. }
  25525. }
  25526. var dat map[string]interface{}
  25527. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25528. fmt.Println(dat)
  25529. } else {
  25530. fmt.Println(err)
  25531. }
  25532. saveLog(result2, src_resquest, "2207", "结算")
  25533. userJSONBytes, _ := json.Marshal(dat)
  25534. if miConfig.Code == "H15049901371" {
  25535. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  25536. utils.ErrorLog("解析失败:%v", err)
  25537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25538. return
  25539. }
  25540. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25541. res.Output = resSeven10265.Output
  25542. res.ErrMsg = resSeven10265.ErrMsg
  25543. res.Cainfo = resSeven10265.Cainfo
  25544. res.WarnMsg = resSeven10265.WarnMsg
  25545. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25546. res.Infcode = infocode
  25547. } else {
  25548. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25549. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  25550. utils.ErrorLog("解析失败:%v", err)
  25551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25552. return
  25553. }
  25554. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  25555. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  25556. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  25557. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  25558. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  25559. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  25560. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  25561. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  25562. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  25563. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25564. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25565. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25566. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25567. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  25568. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  25569. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  25570. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  25571. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  25572. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  25573. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  25574. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  25575. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  25576. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  25577. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  25578. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  25579. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  25580. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  25581. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  25582. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  25583. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  25584. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  25585. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  25586. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  25587. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  25588. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  25589. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  25590. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  25591. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  25592. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25593. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  25594. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  25595. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  25596. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  25597. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  25598. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  25599. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  25600. res.ErrMsg = gzresSeven10265Two.ErrMsg
  25601. res.Cainfo = gzresSeven10265Two.Cainfo
  25602. res.WarnMsg = gzresSeven10265Two.WarnMsg
  25603. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  25604. //res.Infcode = infocode
  25605. } else {
  25606. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25607. utils.ErrorLog("解析失败:%v", err)
  25608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25609. return
  25610. }
  25611. }
  25612. }
  25613. }
  25614. if res.Infcode == -1 {
  25615. errlog := &models.HisOrderError{
  25616. UserOrgId: adminUser.CurrentOrgId,
  25617. Ctime: time.Now().Unix(),
  25618. Mtime: time.Now().Unix(),
  25619. Number: chrg_bchno,
  25620. ErrMsg: res.ErrMsg,
  25621. Status: 1,
  25622. PatientId: id,
  25623. RecordTime: recordDateTime,
  25624. Stage: 6,
  25625. }
  25626. service.CreateErrMsgLog(errlog)
  25627. c.ServeSuccessJSON(map[string]interface{}{
  25628. "failed_code": -10,
  25629. "msg": res.ErrMsg,
  25630. })
  25631. return
  25632. } else {
  25633. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  25634. order.OrderStatus = 2
  25635. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  25636. order.SetlId = res.Output.Setlinfo.SetlID
  25637. order.PsnNo = res.Output.Setlinfo.PsnNo
  25638. order.PsnName = res.Output.Setlinfo.PsnName
  25639. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  25640. order.Certno = res.Output.Setlinfo.Certno
  25641. order.Gend = res.Output.Setlinfo.Gend
  25642. order.Naty = res.Output.Setlinfo.Naty
  25643. order.Age = res.Output.Setlinfo.Age
  25644. order.Insutype = res.Output.Setlinfo.Insutype
  25645. order.PsnType = res.Output.Setlinfo.PsnType
  25646. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  25647. order.SetlTime = res.Output.Setlinfo.SetlTime
  25648. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  25649. order.PayWays = pay_ways
  25650. order.AcctUsedFlag = acct_used_flag
  25651. order.WechatPay = wechat_pay
  25652. order.AliPay = ali_pay
  25653. order.JifenPay = jifen_pay
  25654. order.BandCardPay = band_card_pay
  25655. order.CashPay = cash_pay
  25656. order.OthDesc = oth_desc
  25657. //order.MedType = res.Output.Setlinfo.MedType
  25658. if reg_type == 1112 {
  25659. order.MedType = "1112"
  25660. }
  25661. if reg_type == 1111 {
  25662. order.MedType = "1111"
  25663. }
  25664. order.ClrType = res.Output.Setlinfo.ClrType
  25665. if adminUser.CurrentOrgId == 10480 {
  25666. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  25667. order.ClrType = "11"
  25668. } else {
  25669. order.ClrType = "9903"
  25670. }
  25671. }
  25672. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  25673. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  25674. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  25675. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  25676. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  25677. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  25678. order.HifpPay = res.Output.Setlinfo.HifpPay
  25679. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  25680. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  25681. order.HifesPay = res.Output.Setlinfo.HifesPay
  25682. order.HifobPay = res.Output.Setlinfo.HifobPay
  25683. order.MafPay = res.Output.Setlinfo.MafPay
  25684. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  25685. order.OthPay = res.Output.Setlinfo.OthPay
  25686. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  25687. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  25688. order.AcctPay = res.Output.Setlinfo.AcctPay
  25689. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  25690. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  25691. order.Balc = res.Output.Setlinfo.Balc
  25692. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  25693. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  25694. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  25695. order.ClrWay = res.Output.Setlinfo.ClrWay
  25696. order.Creator = order.Creator
  25697. order.Modify = roles.AdminUserId
  25698. order.RequestLog = src_resquest
  25699. order.Diagnosis = diagnosis_id
  25700. order.FaPiaoNumber = fapiao_number
  25701. order.FaPiaoCode = fapiao_code
  25702. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  25703. detailStr := string(setlDetail)
  25704. order.SetlDetail = detailStr
  25705. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  25706. err = service.UpDateOrder(order)
  25707. if err == nil {
  25708. //判断是否使用了押金
  25709. if dec_way == "true" {
  25710. tmpstring := strconv.FormatInt(order.ID, 10)
  25711. //扣押金
  25712. order.Decimal = decimal
  25713. service.UpDateOrder(order)
  25714. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  25715. if errmsg != nil {
  25716. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  25717. return
  25718. }
  25719. }
  25720. c.ServeSuccessJSON(map[string]interface{}{
  25721. "msg": "结算成功",
  25722. })
  25723. } else {
  25724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  25725. return
  25726. }
  25727. }
  25728. }
  25729. }
  25730. }
  25731. // 上传明细-预结算-
  25732. func (c *HisApiController) GetPreUploadInfo() {
  25733. id, _ := c.GetInt64("id")
  25734. record_time := c.GetString("record_time")
  25735. his_patient_id, _ := c.GetInt64("his_patient_id")
  25736. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  25737. admin_user_id, _ := c.GetInt64("admin_user_id")
  25738. diagnosis_id := c.GetString("diagnosis")
  25739. sick_type, _ := c.GetInt64("sick_type")
  25740. reg_type, _ := c.GetInt64("p_type")
  25741. begin_time := c.GetString("begin_time")
  25742. acct_used_flag := c.GetString("acct_used_flag")
  25743. id_str := c.GetString("ids")
  25744. ids_arr := strings.Split(id_str, ",")
  25745. timeLayout := "2006-01-02"
  25746. loc, _ := time.LoadLocation("Local")
  25747. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  25748. if err != nil {
  25749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25750. return
  25751. }
  25752. recordDateTime := theTime.Unix()
  25753. adminUser := c.GetAdminUserInfo()
  25754. diagnosis_ids := strings.Split(diagnosis_id, ",")
  25755. var config []*models.HisXtDiagnoseConfig
  25756. for _, item := range diagnosis_ids {
  25757. id, _ := strconv.ParseInt(item, 10, 64)
  25758. diagnosisConfig, _ := service.FindDiagnoseById(id)
  25759. config = append(config, &diagnosisConfig)
  25760. }
  25761. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  25762. sickConfig, _ := service.FindSickById(sick_type)
  25763. var prescriptions []*models.HisPrescription
  25764. var start_time int64
  25765. var end_time int64
  25766. var isSuccess bool = true
  25767. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25768. fmt.Println(his_patient_id)
  25769. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  25770. timestamp := time.Now().Unix()
  25771. tempTime := time.Unix(timestamp, 0)
  25772. timeFormat := tempTime.Format("20060102150405")
  25773. chrgBchno := rand.Intn(100000) + 10000
  25774. new_chrg_bchno := ""
  25775. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  25776. new_chrg_bchno = chrg_bchno
  25777. if adminUser.CurrentOrgId == 10265 {
  25778. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  25779. new_chrg_bchno = "0000"
  25780. }
  25781. }
  25782. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25783. var patientPrescription models.HisPrescriptionInfo
  25784. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  25785. if patientPrescription.ID == 0 {
  25786. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  25787. }
  25788. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25789. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  25790. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  25791. strconv.FormatInt(his.PatientId, 10)
  25792. var res2406 Result2406
  25793. //安徽单病种处理
  25794. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  25795. data := make(map[string]interface{})
  25796. client := &http.Client{}
  25797. data["psn_no"] = his.PsnNo
  25798. data["mdtrt_id"] = his.Number
  25799. data["operator"] = roles.UserName
  25800. data["cert_no"] = his.IdCardNo
  25801. data["org_name"] = miConfig.OrgName
  25802. data["psn_name"] = his.Name
  25803. data["ipt_otp_no"] = his.IptOtpNo
  25804. data["ipt_psn_sp_flag_type"] = "0901"
  25805. data["ipt_psn_sp_flag"] = "1"
  25806. data["fixmedins_code"] = miConfig.Code
  25807. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25808. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25809. data["url"] = miConfig.Url
  25810. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  25811. bytesData, _ := json.Marshal(data)
  25812. var req *http.Request
  25813. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  25814. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  25815. resp, _ := client.Do(req)
  25816. defer resp.Body.Close()
  25817. body, ioErr := ioutil.ReadAll(resp.Body)
  25818. if ioErr != nil {
  25819. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25821. return
  25822. }
  25823. var respJSON map[string]interface{}
  25824. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25825. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25827. return
  25828. }
  25829. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25830. if status == "0" {
  25831. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25832. c.ServeSuccessJSON(map[string]interface{}{
  25833. "failed_code": -10,
  25834. "msg": err_msg,
  25835. })
  25836. return
  25837. }
  25838. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25839. userJSONBytes, _ := json.Marshal(respJSON)
  25840. fmt.Println("log")
  25841. fmt.Println(string(userJSONBytes))
  25842. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  25843. utils.ErrorLog("解析失败:%v", err)
  25844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25845. return
  25846. }
  25847. }
  25848. if res2406.Infcode != 0 {
  25849. adminUser := c.GetAdminUserInfo()
  25850. errlog := &models.HisOrderError{
  25851. UserOrgId: adminUser.CurrentOrgId,
  25852. Ctime: time.Now().Unix(),
  25853. Mtime: time.Now().Unix(),
  25854. ErrMsg: res2406.ErrMsg,
  25855. Status: 1,
  25856. PatientId: id,
  25857. RecordTime: recordDateTime,
  25858. Stage: 3,
  25859. }
  25860. service.CreateErrMsgLog(errlog)
  25861. c.ServeSuccessJSON(map[string]interface{}{
  25862. "failed_code": -10,
  25863. "msg": res2406.ErrMsg,
  25864. })
  25865. return
  25866. }
  25867. var res2 ResultSix
  25868. var res3 GZResultSix
  25869. var resSix10265 ResultSix10265
  25870. //var time_stamp string
  25871. if miConfig.MdtrtareaAdmvs == "421300" {
  25872. data := make(map[string]interface{})
  25873. client := &http.Client{}
  25874. data["psn_no"] = his.PsnNo
  25875. data["mdtrt_id"] = his.Number
  25876. data["department"] = department.Name
  25877. data["org_name"] = miConfig.OrgName
  25878. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25879. data["doctor_id"] = doctor_info.DoctorNumber
  25880. data["doctor_name"] = roles.UserName
  25881. data["fixmedins_code"] = miConfig.Code
  25882. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25883. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25884. data["secret_key"] = miConfig.SecretKey
  25885. data["sick_code"] = sickConfig.CountryCode
  25886. data["sick_name"] = sickConfig.ClassName
  25887. data["begin_time"] = begin_time
  25888. data["dept"] = strconv.FormatInt(department.ID, 10)
  25889. data["config"] = config
  25890. data["opter"] = roles.UserName
  25891. fmt.Println(data)
  25892. bytesData, _ := json.Marshal(data)
  25893. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  25894. resp, _ := client.Do(req)
  25895. defer resp.Body.Close()
  25896. body, ioErr := ioutil.ReadAll(resp.Body)
  25897. if ioErr != nil {
  25898. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25900. return
  25901. }
  25902. var respJSON map[string]interface{}
  25903. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25904. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25906. return
  25907. }
  25908. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25909. userJSONBytes, _ := json.Marshal(respJSON)
  25910. fmt.Println("log")
  25911. fmt.Println(string(userJSONBytes))
  25912. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25913. utils.ErrorLog("解析失败:%v", err)
  25914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25915. return
  25916. }
  25917. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25918. data := make(map[string]interface{})
  25919. client := &http.Client{}
  25920. data["psn_no"] = his.PsnNo
  25921. data["mdtrt_id"] = his.Number
  25922. data["department"] = department.Name
  25923. data["org_name"] = miConfig.OrgName
  25924. if reg_type == 11 && his.Insutype == "390" {
  25925. data["med_type"] = "110104"
  25926. } else {
  25927. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25928. }
  25929. data["doctor_id"] = doctor_info.DoctorNumber
  25930. data["doctor_name"] = roles.UserName
  25931. data["fixmedins_code"] = miConfig.Code
  25932. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25933. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25934. data["secret_key"] = miConfig.SecretKey
  25935. data["sick_code"] = sickConfig.CountryCode
  25936. data["sick_name"] = sickConfig.ClassName
  25937. data["begin_time"] = begin_time
  25938. data["dept"] = strconv.FormatInt(department.ID, 10)
  25939. data["config"] = config
  25940. data["opter"] = roles.UserName
  25941. fmt.Println(data)
  25942. bytesData, _ := json.Marshal(data)
  25943. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  25944. resp, _ := client.Do(req)
  25945. defer resp.Body.Close()
  25946. body, ioErr := ioutil.ReadAll(resp.Body)
  25947. if ioErr != nil {
  25948. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25950. return
  25951. }
  25952. var respJSON map[string]interface{}
  25953. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25954. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25956. return
  25957. }
  25958. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25959. userJSONBytes, _ := json.Marshal(respJSON)
  25960. fmt.Println("log")
  25961. fmt.Println(string(userJSONBytes))
  25962. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25963. utils.ErrorLog("解析失败:%v", err)
  25964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25965. return
  25966. }
  25967. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25968. data := make(map[string]interface{})
  25969. client := &http.Client{}
  25970. data["psn_no"] = his.PsnNo
  25971. data["mdtrt_id"] = his.Number
  25972. data["department"] = department.Name
  25973. data["org_name"] = miConfig.OrgName
  25974. if reg_type == 11 && his.Insutype == "390" {
  25975. data["med_type"] = "110104"
  25976. } else {
  25977. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25978. }
  25979. data["doctor_id"] = doctor_info.DoctorNumber
  25980. data["doctor_name"] = roles.UserName
  25981. data["fixmedins_code"] = miConfig.Code
  25982. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25983. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25984. data["secret_key"] = miConfig.SecretKey
  25985. data["sick_code"] = sickConfig.CountryCode
  25986. data["sick_name"] = sickConfig.ClassName
  25987. data["begin_time"] = begin_time
  25988. data["dept"] = strconv.FormatInt(department.ID, 10)
  25989. data["config"] = config
  25990. data["opter"] = roles.UserName
  25991. fmt.Println(data)
  25992. bytesData, _ := json.Marshal(data)
  25993. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25994. resp, _ := client.Do(req)
  25995. defer resp.Body.Close()
  25996. body, ioErr := ioutil.ReadAll(resp.Body)
  25997. if ioErr != nil {
  25998. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26000. return
  26001. }
  26002. var respJSON map[string]interface{}
  26003. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26006. return
  26007. }
  26008. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26009. userJSONBytes, _ := json.Marshal(respJSON)
  26010. fmt.Println("log")
  26011. fmt.Println(string(userJSONBytes))
  26012. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26013. utils.ErrorLog("解析失败:%v", err)
  26014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26015. return
  26016. }
  26017. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26018. data := make(map[string]interface{})
  26019. client := &http.Client{}
  26020. data["psn_no"] = his.PsnNo
  26021. data["mdtrt_id"] = his.Number
  26022. data["department"] = department.Name
  26023. data["org_name"] = miConfig.OrgName
  26024. if reg_type == 11 && his.Insutype == "390" {
  26025. data["med_type"] = "110104"
  26026. } else {
  26027. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26028. }
  26029. data["doctor_id"] = doctor_info.DoctorNumber
  26030. data["doctor_name"] = roles.UserName
  26031. data["fixmedins_code"] = miConfig.Code
  26032. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26033. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26034. data["secret_key"] = miConfig.SecretKey
  26035. data["sick_code"] = sickConfig.CountryCode
  26036. data["sick_name"] = sickConfig.ClassName
  26037. data["begin_time"] = begin_time
  26038. data["dept"] = strconv.FormatInt(department.ID, 10)
  26039. data["config"] = config
  26040. data["opter"] = roles.UserName
  26041. fmt.Println(data)
  26042. bytesData, _ := json.Marshal(data)
  26043. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26044. resp, _ := client.Do(req)
  26045. defer resp.Body.Close()
  26046. body, ioErr := ioutil.ReadAll(resp.Body)
  26047. if ioErr != nil {
  26048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26050. return
  26051. }
  26052. var respJSON map[string]interface{}
  26053. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26056. return
  26057. }
  26058. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26059. userJSONBytes, _ := json.Marshal(respJSON)
  26060. fmt.Println("log")
  26061. fmt.Println(string(userJSONBytes))
  26062. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26063. utils.ErrorLog("解析失败:%v", err)
  26064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26065. return
  26066. }
  26067. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26068. data := make(map[string]interface{})
  26069. client := &http.Client{}
  26070. data["psn_no"] = his.PsnNo
  26071. data["mdtrt_id"] = his.Number
  26072. data["doctor"] = roles.UserName
  26073. data["department"] = department.Name
  26074. data["org_name"] = miConfig.OrgName
  26075. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26076. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  26077. data["fixmedins_code"] = miConfig.Code
  26078. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26079. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26080. data["secret_key"] = miConfig.SecretKey
  26081. data["sick_code"] = sickConfig.CountryCode
  26082. data["sick_name"] = sickConfig.ClassName
  26083. data["begin_time"] = begin_time
  26084. data["dept"] = strconv.FormatInt(department.ID, 10)
  26085. data["config"] = config
  26086. data["url"] = miConfig.Url
  26087. data["ak"] = miConfig.AccessKey
  26088. data["cainfo"] = miConfig.Cainfo
  26089. bytesData, _ := json.Marshal(data)
  26090. var req *http.Request
  26091. if miConfig.MdtrtareaAdmvs == "320921" {
  26092. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26093. } else {
  26094. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26095. }
  26096. resp, _ := client.Do(req)
  26097. defer resp.Body.Close()
  26098. body, ioErr := ioutil.ReadAll(resp.Body)
  26099. if ioErr != nil {
  26100. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26102. return
  26103. }
  26104. var respJSON map[string]interface{}
  26105. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26106. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26108. return
  26109. }
  26110. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  26111. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  26112. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  26113. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26114. userJSONBytes, _ := json.Marshal(respJSON)
  26115. fmt.Println("log")
  26116. fmt.Println(string(userJSONBytes))
  26117. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  26118. utils.ErrorLog("解析失败:%v", err)
  26119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26120. return
  26121. }
  26122. res2.InfRefmsgid = resSix10265.InfRefmsgid
  26123. res2.Output = resSix10265.Output
  26124. res2.ErrMsg = resSix10265.ErrMsg
  26125. res2.Cainfo = resSix10265.Cainfo
  26126. res2.WarnMsg = resSix10265.WarnMsg
  26127. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  26128. res2.Infcode = infocode
  26129. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26130. data := make(map[string]interface{})
  26131. client := &http.Client{}
  26132. data["psn_no"] = his.PsnNo
  26133. data["mdtrt_id"] = his.Number
  26134. data["doctor"] = roles.UserName
  26135. data["department"] = department.Name
  26136. data["org_name"] = miConfig.OrgName
  26137. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26138. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  26139. data["fixmedins_code"] = miConfig.Code
  26140. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26141. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26142. data["secret_key"] = miConfig.SecretKey
  26143. data["sick_code"] = sickConfig.CountryCode
  26144. data["sick_name"] = sickConfig.ClassName
  26145. data["begin_time"] = begin_time
  26146. data["dept"] = strconv.FormatInt(department.ID, 10)
  26147. data["config"] = config
  26148. //data["url"] = miConfig.Url
  26149. //data["ak"] = miConfig.AccessKey
  26150. data["cainfo"] = miConfig.Cainfo
  26151. fmt.Println(data)
  26152. bytesData, _ := json.Marshal(data)
  26153. var req *http.Request
  26154. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  26155. resp, _ := client.Do(req)
  26156. defer resp.Body.Close()
  26157. body, ioErr := ioutil.ReadAll(resp.Body)
  26158. if ioErr != nil {
  26159. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26161. return
  26162. }
  26163. var respJSON map[string]interface{}
  26164. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26165. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26167. return
  26168. }
  26169. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  26170. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  26171. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  26172. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26173. userJSONBytes, _ := json.Marshal(respJSON)
  26174. fmt.Println("log")
  26175. fmt.Println(string(userJSONBytes))
  26176. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  26177. utils.ErrorLog("解析失败:%v", err)
  26178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26179. return
  26180. }
  26181. res2.InfRefmsgid = resSix10265.InfRefmsgid
  26182. res2.Output = resSix10265.Output
  26183. res2.ErrMsg = resSix10265.ErrMsg
  26184. res2.Cainfo = resSix10265.Cainfo
  26185. res2.WarnMsg = resSix10265.WarnMsg
  26186. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  26187. res2.Infcode = infocode
  26188. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26189. 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)
  26190. saveLog(result, requestLog, "2203", "上传就诊信息")
  26191. var respJSON2 map[string]interface{}
  26192. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26193. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26195. return
  26196. }
  26197. userJSONBytes2, _ := json.Marshal(respJSON2)
  26198. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26199. utils.ErrorLog("解析失败:%v", err)
  26200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26201. return
  26202. }
  26203. } else if miConfig.MdtrtareaAdmvs == "360302" {
  26204. var result string
  26205. var requestLog string
  26206. 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, "")
  26207. saveLog(result, requestLog, "2203", "上传就诊信息")
  26208. var respJSON2 map[string]interface{}
  26209. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26210. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26212. return
  26213. }
  26214. userJSONBytes2, _ := json.Marshal(respJSON2)
  26215. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26216. utils.ErrorLog("解析失败:%v", err)
  26217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26218. return
  26219. }
  26220. } else if miConfig.MdtrtareaAdmvs == "341203" {
  26221. data := make(map[string]interface{})
  26222. client := &http.Client{}
  26223. data["psn_no"] = his.PsnNo
  26224. data["mdtrt_id"] = his.Number
  26225. data["operator"] = roles.UserName
  26226. data["department"] = department.Name
  26227. data["org_name"] = miConfig.OrgName
  26228. var med_type string
  26229. if his.Insutype == "390" {
  26230. if reg_type == 992102 {
  26231. med_type = "992102"
  26232. data["sick_code"] = "ZDZ940"
  26233. data["sick_name"] = "慢性肾衰竭"
  26234. }
  26235. if reg_type == 140104 {
  26236. med_type = "140104"
  26237. data["sick_code"] = sickConfig.CountryCode
  26238. data["sick_name"] = sickConfig.ClassName
  26239. }
  26240. if reg_type == 14 {
  26241. med_type = "140104"
  26242. data["sick_code"] = sickConfig.CountryCode
  26243. data["sick_name"] = sickConfig.ClassName
  26244. }
  26245. } else if his.Insutype == "310" {
  26246. if reg_type == 992102 {
  26247. med_type = "992102"
  26248. data["sick_code"] = "ZDZ940"
  26249. data["sick_name"] = "慢性肾衰竭"
  26250. }
  26251. if reg_type == 140104 {
  26252. med_type = "140104"
  26253. data["sick_code"] = sickConfig.CountryCode
  26254. data["sick_name"] = sickConfig.ClassName
  26255. }
  26256. if reg_type == 14 {
  26257. med_type = "14"
  26258. data["sick_code"] = sickConfig.CountryCode
  26259. data["sick_name"] = sickConfig.ClassName
  26260. }
  26261. }
  26262. data["med_type"] = med_type
  26263. data["doctor_number"] = doctor_info.DoctorNumber
  26264. data["doctor_name"] = doctor_info.UserName
  26265. data["fixmedins_code"] = miConfig.Code
  26266. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26267. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26268. data["secret_key"] = miConfig.SecretKey
  26269. data["begin_time"] = begin_time
  26270. data["dept"] = strconv.FormatInt(department.ID, 10)
  26271. data["config"] = config
  26272. data["url"] = miConfig.Url
  26273. data["ak"] = miConfig.AccessKey
  26274. data["cainfo"] = miConfig.Cainfo
  26275. bytesData, _ := json.Marshal(data)
  26276. var req *http.Request
  26277. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  26278. resp, _ := client.Do(req)
  26279. defer resp.Body.Close()
  26280. body, ioErr := ioutil.ReadAll(resp.Body)
  26281. if ioErr != nil {
  26282. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26284. return
  26285. }
  26286. var respJSON map[string]interface{}
  26287. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26290. return
  26291. }
  26292. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26293. if status == "0" {
  26294. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26295. c.ServeSuccessJSON(map[string]interface{}{
  26296. "failed_code": -10,
  26297. "msg": err_msg,
  26298. })
  26299. return
  26300. }
  26301. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26302. userJSONBytes, _ := json.Marshal(respJSON)
  26303. fmt.Println("log")
  26304. fmt.Println(string(userJSONBytes))
  26305. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26306. utils.ErrorLog("解析失败:%v", err)
  26307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26308. return
  26309. }
  26310. } else if miConfig.MdtrtareaAdmvs == "430800" {
  26311. var result string
  26312. var requestLog string
  26313. 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, "")
  26314. saveLog(result, requestLog, "2203", "上传就诊信息")
  26315. var respJSON2 map[string]interface{}
  26316. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26317. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26319. return
  26320. }
  26321. userJSONBytes2, _ := json.Marshal(respJSON2)
  26322. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26323. utils.ErrorLog("解析失败:%v", err)
  26324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26325. return
  26326. }
  26327. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26328. data := make(map[string]interface{})
  26329. client := &http.Client{}
  26330. data["psn_no"] = his.PsnNo
  26331. data["mdtrt_id"] = his.Number
  26332. data["doctor"] = roles.UserName
  26333. data["department"] = department.Name
  26334. data["org_name"] = miConfig.OrgName
  26335. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26336. data["doctor_id"] = doctor_info.DoctorNumber
  26337. data["fixmedins_code"] = miConfig.Code
  26338. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26339. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26340. data["secret_key"] = miConfig.SecretKey
  26341. data["sick_code"] = sickConfig.CountryCode
  26342. data["sick_name"] = sickConfig.ClassName
  26343. data["begin_time"] = begin_time
  26344. data["new_doctor_name"] = doctor_info.UserName
  26345. data["dept"] = strconv.FormatInt(department.ID, 10)
  26346. data["config"] = config
  26347. bytesData, _ := json.Marshal(data)
  26348. var req *http.Request
  26349. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  26350. resp, _ := client.Do(req)
  26351. defer resp.Body.Close()
  26352. body, ioErr := ioutil.ReadAll(resp.Body)
  26353. if ioErr != nil {
  26354. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26356. return
  26357. }
  26358. var respJSON map[string]interface{}
  26359. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26362. return
  26363. }
  26364. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26365. userJSONBytes, _ := json.Marshal(respJSON)
  26366. fmt.Println("log")
  26367. fmt.Println(string(userJSONBytes))
  26368. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26369. utils.ErrorLog("解析失败:%v", err)
  26370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26371. return
  26372. }
  26373. } else {
  26374. var result string
  26375. var requestLog string
  26376. if miConfig.MdtrtareaAdmvs == "440781" { //
  26377. 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)
  26378. } else {
  26379. if miConfig.Code == "H15049901371" {
  26380. //赤峰地区国家医保医疗类别
  26381. //职工透析:医疗类别选特殊情况门诊990502
  26382. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26383. var med_type string
  26384. if his.Insutype == "390" {
  26385. if reg_type == 14 {
  26386. med_type = "9933"
  26387. } else if reg_type == 11 {
  26388. med_type = "11"
  26389. }
  26390. } else if his.Insutype == "310" {
  26391. if reg_type == 14 {
  26392. med_type = "990502"
  26393. } else if reg_type == 11 {
  26394. med_type = "11"
  26395. }
  26396. }
  26397. 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)
  26398. } else {
  26399. 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)
  26400. }
  26401. saveLog(result, requestLog, "2203", "上传就诊信息")
  26402. var respJSON2 map[string]interface{}
  26403. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26404. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26406. return
  26407. }
  26408. userJSONBytes2, _ := json.Marshal(respJSON2)
  26409. if miConfig.Code == "H15049901371" {
  26410. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  26411. utils.ErrorLog("解析失败:%v", err)
  26412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26413. return
  26414. }
  26415. res2.InfRefmsgid = resSix10265.InfRefmsgid
  26416. res2.Output = resSix10265.Output
  26417. res2.ErrMsg = resSix10265.ErrMsg
  26418. res2.Cainfo = resSix10265.Cainfo
  26419. res2.WarnMsg = resSix10265.WarnMsg
  26420. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  26421. res2.Infcode = infocode
  26422. } else {
  26423. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26424. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  26425. utils.ErrorLog("解析失败:%v", err)
  26426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26427. return
  26428. }
  26429. res2.Infcode = res3.Infcode
  26430. } else {
  26431. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26432. utils.ErrorLog("解析失败:%v", err)
  26433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26434. return
  26435. }
  26436. }
  26437. }
  26438. }
  26439. }
  26440. if res2.Infcode == -1 {
  26441. adminUser := c.GetAdminUserInfo()
  26442. errlog := &models.HisOrderError{
  26443. UserOrgId: adminUser.CurrentOrgId,
  26444. Ctime: time.Now().Unix(),
  26445. Mtime: time.Now().Unix(),
  26446. ErrMsg: res2.ErrMsg,
  26447. Status: 1,
  26448. PatientId: id,
  26449. RecordTime: recordDateTime,
  26450. Stage: 3,
  26451. }
  26452. service.CreateErrMsgLog(errlog)
  26453. c.ServeSuccessJSON(map[string]interface{}{
  26454. "failed_code": -10,
  26455. "msg": res2.ErrMsg,
  26456. })
  26457. return
  26458. }
  26459. if res2.Infcode != 0 {
  26460. adminUser := c.GetAdminUserInfo()
  26461. errlog := &models.HisOrderError{
  26462. UserOrgId: adminUser.CurrentOrgId,
  26463. Ctime: time.Now().Unix(),
  26464. Mtime: time.Now().Unix(),
  26465. ErrMsg: res2.ErrMsg,
  26466. Status: 1,
  26467. PatientId: id,
  26468. RecordTime: recordDateTime,
  26469. Stage: 3,
  26470. }
  26471. service.CreateErrMsgLog(errlog)
  26472. c.ServeSuccessJSON(map[string]interface{}{
  26473. "failed_code": -10,
  26474. "msg": res2.ErrMsg,
  26475. })
  26476. return
  26477. } else {
  26478. his.Diagnosis = diagnosis_id
  26479. his.SickType = sickConfig.ID
  26480. his.PType = fmt.Sprintf("%d", reg_type)
  26481. service.UpdateHisPatientThree(&his)
  26482. data := make(map[string]interface{})
  26483. if settle_accounts_type == 1 { //日结
  26484. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  26485. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  26486. } else {
  26487. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  26488. }
  26489. data["pre"] = prescriptions
  26490. } else { //月结
  26491. start_time_str := c.GetString("start_time")
  26492. end_time_str := c.GetString("end_time")
  26493. timeLayout := "2006-01-02"
  26494. loc, _ := time.LoadLocation("Local")
  26495. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  26496. if err != nil {
  26497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26498. return
  26499. }
  26500. recordStartTime := theStartTime.Unix()
  26501. start_time = recordStartTime
  26502. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  26503. if err != nil {
  26504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26505. return
  26506. }
  26507. recordEndTime := theEndTime.Unix()
  26508. end_time = recordEndTime
  26509. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  26510. data["pre"] = prescriptions
  26511. }
  26512. client := &http.Client{}
  26513. data["psn_no"] = his.PsnNo
  26514. data["mdtrt_id"] = his.Number
  26515. data["chrg_bchno"] = new_chrg_bchno
  26516. data["org_name"] = miConfig.OrgName
  26517. data["doctor"] = doctor_info.UserName
  26518. data["doctor_id"] = doctor_info.DoctorNumber
  26519. data["dept"] = department.Name
  26520. data["fixmedins_code"] = miConfig.Code
  26521. data["opter"] = roles.UserName
  26522. data["dept_code"] = department.Number
  26523. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26524. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26525. data["secret_key"] = miConfig.SecretKey
  26526. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  26527. data["url"] = miConfig.Url
  26528. data["ak"] = miConfig.AccessKey
  26529. data["new_doctor_name"] = patientPrescription.Doctor
  26530. if his.Insutype == "390" {
  26531. if reg_type == 992102 {
  26532. data["diag_code"] = "ZDZ940"
  26533. }
  26534. if reg_type == 140104 {
  26535. data["diag_code"] = sickConfig.CountryCode
  26536. }
  26537. if reg_type == 14 {
  26538. data["diag_code"] = sickConfig.CountryCode
  26539. }
  26540. } else if his.Insutype == "310" {
  26541. if reg_type == 992102 {
  26542. data["diag_code"] = "ZDZ940"
  26543. }
  26544. if reg_type == 14 {
  26545. data["diag_code"] = sickConfig.CountryCode
  26546. }
  26547. }
  26548. data["cainfo"] = miConfig.Cainfo
  26549. data["opter"] = roles.UserName
  26550. var ids []int64
  26551. for _, item := range prescriptions {
  26552. ids = append(ids, item.ID)
  26553. }
  26554. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26555. if config.IsOpen == 1 { //对接了医保,走医保流程
  26556. var res ResultFour
  26557. var resFour10265 ResultFour10265
  26558. if miConfig.MdtrtareaAdmvs == "421300" {
  26559. bytesData, _ := json.Marshal(data)
  26560. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  26561. resp, _ := client.Do(req)
  26562. defer resp.Body.Close()
  26563. body, ioErr := ioutil.ReadAll(resp.Body)
  26564. if ioErr != nil {
  26565. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26567. return
  26568. }
  26569. var respJSON map[string]interface{}
  26570. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26573. return
  26574. }
  26575. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26576. userJSONBytes, _ := json.Marshal(respJSON)
  26577. fmt.Println("log")
  26578. fmt.Println(string(userJSONBytes))
  26579. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26580. utils.ErrorLog("解析失败:%v", err)
  26581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26582. return
  26583. }
  26584. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26585. bytesData, _ := json.Marshal(data)
  26586. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  26587. resp, _ := client.Do(req)
  26588. defer resp.Body.Close()
  26589. body, ioErr := ioutil.ReadAll(resp.Body)
  26590. if ioErr != nil {
  26591. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26593. return
  26594. }
  26595. var respJSON map[string]interface{}
  26596. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26597. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26599. return
  26600. }
  26601. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26602. userJSONBytes, _ := json.Marshal(respJSON)
  26603. fmt.Println("log")
  26604. fmt.Println(string(userJSONBytes))
  26605. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26606. utils.ErrorLog("解析失败:%v", err)
  26607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26608. return
  26609. }
  26610. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26611. bytesData, _ := json.Marshal(data)
  26612. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  26613. resp, _ := client.Do(req)
  26614. defer resp.Body.Close()
  26615. body, ioErr := ioutil.ReadAll(resp.Body)
  26616. if ioErr != nil {
  26617. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26619. return
  26620. }
  26621. var respJSON map[string]interface{}
  26622. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26623. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26625. return
  26626. }
  26627. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26628. userJSONBytes, _ := json.Marshal(respJSON)
  26629. fmt.Println("log")
  26630. fmt.Println(string(userJSONBytes))
  26631. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26632. utils.ErrorLog("解析失败:%v", err)
  26633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26634. return
  26635. }
  26636. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26637. bytesData, _ := json.Marshal(data)
  26638. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  26639. resp, _ := client.Do(req)
  26640. defer resp.Body.Close()
  26641. body, ioErr := ioutil.ReadAll(resp.Body)
  26642. if ioErr != nil {
  26643. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26645. return
  26646. }
  26647. var respJSON map[string]interface{}
  26648. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26649. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26651. return
  26652. }
  26653. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26654. userJSONBytes, _ := json.Marshal(respJSON)
  26655. fmt.Println("log")
  26656. fmt.Println(string(userJSONBytes))
  26657. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26658. utils.ErrorLog("解析失败:%v", err)
  26659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26660. return
  26661. }
  26662. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26663. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26664. if result3101.Infcode == "0" {
  26665. if len(result3101.Output.Result) > 0 {
  26666. var errMsgs []string
  26667. for _, item := range result3101.Output.Result {
  26668. errMsgs = append(errMsgs, item.VolaCont)
  26669. }
  26670. c.ServeSuccessJSON(map[string]interface{}{
  26671. "failed_code": -10,
  26672. "msg": errMsgs,
  26673. })
  26674. return
  26675. } else {
  26676. if miConfig.MdtrtareaAdmvs == "320921" {
  26677. data["doctor_id"] = "D320923012139"
  26678. } else {
  26679. data["doctor_id"] = "D371621008686"
  26680. }
  26681. bytesData, _ := json.Marshal(data)
  26682. var req *http.Request
  26683. if miConfig.MdtrtareaAdmvs == "320921" {
  26684. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26685. } else {
  26686. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26687. }
  26688. resp, _ := client.Do(req)
  26689. defer resp.Body.Close()
  26690. body, ioErr := ioutil.ReadAll(resp.Body)
  26691. if ioErr != nil {
  26692. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26694. return
  26695. }
  26696. var respJSON map[string]interface{}
  26697. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26700. return
  26701. }
  26702. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26703. userJSONBytes, _ := json.Marshal(respJSON)
  26704. fmt.Println("log")
  26705. fmt.Println(string(userJSONBytes))
  26706. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26707. utils.ErrorLog("解析失败:%v", err)
  26708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26709. return
  26710. }
  26711. res.InfRefmsgid = resFour10265.InfRefmsgid
  26712. res.Output = resFour10265.Output
  26713. res.ErrMsg = resFour10265.ErrMsg
  26714. res.Cainfo = resFour10265.Cainfo
  26715. res.WarnMsg = resFour10265.WarnMsg
  26716. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26717. res.Infcode = infocode
  26718. }
  26719. }
  26720. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26721. var pagesize int = 5
  26722. var start int = 1
  26723. var stop int
  26724. var pagecount int
  26725. var curpage int
  26726. data["doctor_id"] = doctor_info.DoctorNumber
  26727. var res2 ResultFour
  26728. //var result res.
  26729. //总页数,向上取整,注意除之前要先转换类型为float64
  26730. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  26731. for curpage = 1; curpage <= pagecount; curpage++ {
  26732. if curpage == 1 {
  26733. start = 1
  26734. } else {
  26735. start = (curpage-1)*pagesize + 1
  26736. }
  26737. stop = curpage * pagesize
  26738. if stop > len(prescriptions) {
  26739. stop = len(prescriptions)
  26740. }
  26741. //var requestLog string
  26742. data["pre"] = prescriptions[start-1 : stop]
  26743. fmt.Println(data["pre"])
  26744. bytesData, _ := json.Marshal(data)
  26745. var req *http.Request
  26746. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  26747. resp, _ := client.Do(req)
  26748. defer resp.Body.Close()
  26749. body, ioErr := ioutil.ReadAll(resp.Body)
  26750. if ioErr != nil {
  26751. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26753. return
  26754. }
  26755. var respJSON map[string]interface{}
  26756. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26757. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26759. return
  26760. }
  26761. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26762. userJSONBytes, _ := json.Marshal(respJSON)
  26763. fmt.Println("log")
  26764. fmt.Println(string(userJSONBytes))
  26765. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26766. utils.ErrorLog("解析失败:%v", err)
  26767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26768. return
  26769. }
  26770. res.InfRefmsgid = resFour10265.InfRefmsgid
  26771. res.Output = resFour10265.Output
  26772. res.ErrMsg = resFour10265.ErrMsg
  26773. res.Cainfo = resFour10265.Cainfo
  26774. res.WarnMsg = resFour10265.WarnMsg
  26775. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26776. res.Infcode = infocode
  26777. if infocode == 0 {
  26778. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  26779. } else {
  26780. isSuccess = false
  26781. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  26782. res.Infcode = -1
  26783. res.ErrMsg = resFour10265.ErrMsg
  26784. errlog := &models.HisOrderError{
  26785. UserOrgId: adminUser.CurrentOrgId,
  26786. Ctime: time.Now().Unix(),
  26787. Mtime: time.Now().Unix(),
  26788. Number: chrg_bchno,
  26789. ErrMsg: "",
  26790. Status: 1,
  26791. PatientId: id,
  26792. RecordTime: recordDateTime,
  26793. Stage: 4,
  26794. }
  26795. service.CreateErrMsgLog(errlog)
  26796. }
  26797. }
  26798. if isSuccess {
  26799. res.Infcode = 0
  26800. res.Output.Result = res2.Output.Result
  26801. } else {
  26802. order := &models.HisOrder{
  26803. UserOrgId: adminUser.CurrentOrgId,
  26804. HisPatientId: his.ID,
  26805. PatientId: his.PatientId,
  26806. SettleAccountsDate: recordDateTime,
  26807. Ctime: time.Now().Unix(),
  26808. Mtime: time.Now().Unix(),
  26809. MdtrtId: his.Number,
  26810. PsnNo: his.PsnNo,
  26811. MedType: strconv.FormatInt(reg_type, 10),
  26812. Status: 1,
  26813. Number: chrg_bchno,
  26814. Infcode: res.Infcode,
  26815. WarnMsg: res.WarnMsg,
  26816. Cainfo: res.Cainfo,
  26817. ErrMsg: res.ErrMsg,
  26818. RespondTime: res.RefmsgTime,
  26819. InfRefmsgid: res.InfRefmsgid,
  26820. OrderStatus: 1,
  26821. IsMedicineInsurance: 1,
  26822. SettleType: settle_accounts_type,
  26823. SettleStartTime: start_time,
  26824. SettleEndTime: end_time,
  26825. Creator: roles.AdminUserId,
  26826. Modify: roles.AdminUserId,
  26827. PType: 2,
  26828. Diagnosis: diagnosis_id,
  26829. }
  26830. err = service.CreateOrder(order)
  26831. if err != nil {
  26832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  26833. return
  26834. }
  26835. c.ServeSuccessJSON(map[string]interface{}{
  26836. "failed_code": -10,
  26837. "msg": res2.ErrMsg,
  26838. })
  26839. return
  26840. }
  26841. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26842. 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)
  26843. var dat map[string]interface{}
  26844. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26845. fmt.Println(dat)
  26846. } else {
  26847. fmt.Println(err)
  26848. }
  26849. saveLog(result, request_log, "2204", "上传费用明细")
  26850. userJSONBytes, _ := json.Marshal(dat)
  26851. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26852. utils.ErrorLog("解析失败:%v", err)
  26853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26854. return
  26855. }
  26856. } else if miConfig.MdtrtareaAdmvs == "360302" {
  26857. 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, "", "")
  26858. var dat map[string]interface{}
  26859. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26860. fmt.Println(dat)
  26861. } else {
  26862. fmt.Println(err)
  26863. }
  26864. saveLog(result, request_log, "2204", "上传费用明细")
  26865. userJSONBytes, _ := json.Marshal(dat)
  26866. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26867. utils.ErrorLog("解析失败:%v", err)
  26868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26869. return
  26870. }
  26871. } else if miConfig.MdtrtareaAdmvs == "341203" {
  26872. bytesData, _ := json.Marshal(data)
  26873. var req *http.Request
  26874. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  26875. resp, _ := client.Do(req)
  26876. defer resp.Body.Close()
  26877. body, ioErr := ioutil.ReadAll(resp.Body)
  26878. if ioErr != nil {
  26879. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26881. return
  26882. }
  26883. var respJSON map[string]interface{}
  26884. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26885. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26887. return
  26888. }
  26889. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26890. if status == "0" {
  26891. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26892. c.ServeSuccessJSON(map[string]interface{}{
  26893. "failed_code": -10,
  26894. "msg": err_msg,
  26895. })
  26896. return
  26897. }
  26898. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26899. userJSONBytes, _ := json.Marshal(respJSON)
  26900. fmt.Println("log")
  26901. fmt.Println(string(userJSONBytes))
  26902. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26903. utils.ErrorLog("解析失败:%v", err)
  26904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26905. return
  26906. }
  26907. } else if miConfig.MdtrtareaAdmvs == "430800" {
  26908. 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, "", "")
  26909. var dat map[string]interface{}
  26910. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26911. fmt.Println(dat)
  26912. } else {
  26913. fmt.Println(err)
  26914. }
  26915. saveLog(result, request_log, "2204", "上传费用明细")
  26916. userJSONBytes, _ := json.Marshal(dat)
  26917. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26918. utils.ErrorLog("解析失败:%v", err)
  26919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26920. return
  26921. }
  26922. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26923. bytesData, _ := json.Marshal(data)
  26924. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  26925. resp, _ := client.Do(req)
  26926. defer resp.Body.Close()
  26927. body, ioErr := ioutil.ReadAll(resp.Body)
  26928. if ioErr != nil {
  26929. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26931. return
  26932. }
  26933. var respJSON map[string]interface{}
  26934. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26935. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26937. return
  26938. }
  26939. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26940. userJSONBytes, _ := json.Marshal(respJSON)
  26941. fmt.Println("log")
  26942. fmt.Println(string(userJSONBytes))
  26943. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26944. utils.ErrorLog("解析失败:%v", err)
  26945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26946. return
  26947. }
  26948. } else {
  26949. if miConfig.MdtrtareaAdmvs == "441202" {
  26950. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26951. if result3101.Infcode == 0 {
  26952. if len(result3101.Output.Result) > 0 {
  26953. var errMsgs []string
  26954. for _, item := range result3101.Output.Result {
  26955. errMsgs = append(errMsgs, item.VolaCont)
  26956. }
  26957. c.ServeSuccessJSON(map[string]interface{}{
  26958. "failed_code": -10,
  26959. "msg": errMsgs,
  26960. })
  26961. return
  26962. } else {
  26963. 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)
  26964. var dat map[string]interface{}
  26965. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26966. fmt.Println(dat)
  26967. } else {
  26968. fmt.Println(err)
  26969. }
  26970. saveLog(result, request_log, "2204", "上传费用明细")
  26971. userJSONBytes, _ := json.Marshal(dat)
  26972. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26973. utils.ErrorLog("解析失败:%v", err)
  26974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26975. return
  26976. }
  26977. }
  26978. } else {
  26979. c.ServeSuccessJSON(map[string]interface{}{
  26980. "failed_code": -10,
  26981. "msg": result3101.ErrMsg,
  26982. })
  26983. return
  26984. }
  26985. } else if miConfig.MdtrtareaAdmvs == "440205" {
  26986. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26987. if result3101.Infcode == 0 {
  26988. if len(result3101.Output.Result) > 0 {
  26989. var errMsgs []string
  26990. for _, item := range result3101.Output.Result {
  26991. errMsgs = append(errMsgs, item.VolaCont)
  26992. }
  26993. c.ServeSuccessJSON(map[string]interface{}{
  26994. "failed_code": -10,
  26995. "msg": errMsgs,
  26996. })
  26997. return
  26998. } else {
  26999. 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)
  27000. var dat map[string]interface{}
  27001. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27002. fmt.Println(dat)
  27003. } else {
  27004. fmt.Println(err)
  27005. }
  27006. saveLog(result, request_log, "2204", "上传费用明细")
  27007. userJSONBytes, _ := json.Marshal(dat)
  27008. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27009. utils.ErrorLog("解析失败:%v", err)
  27010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27011. return
  27012. }
  27013. }
  27014. } else {
  27015. c.ServeSuccessJSON(map[string]interface{}{
  27016. "failed_code": -10,
  27017. "msg": result3101.ErrMsg,
  27018. })
  27019. return
  27020. }
  27021. } else {
  27022. if miConfig.Code == "H15049901371" {
  27023. 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)
  27024. var dat map[string]interface{}
  27025. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27026. fmt.Println(dat)
  27027. } else {
  27028. fmt.Println(err)
  27029. }
  27030. saveLog(result, request_log, "2204", "上传费用明细")
  27031. userJSONBytes, _ := json.Marshal(dat)
  27032. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27033. utils.ErrorLog("解析失败:%v", err)
  27034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27035. return
  27036. }
  27037. res.InfRefmsgid = resFour10265.InfRefmsgid
  27038. res.Output = resFour10265.Output
  27039. res.ErrMsg = resFour10265.ErrMsg
  27040. res.Cainfo = resFour10265.Cainfo
  27041. res.WarnMsg = resFour10265.WarnMsg
  27042. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27043. res.Infcode = infocode
  27044. } else {
  27045. 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)
  27046. var dat map[string]interface{}
  27047. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27048. fmt.Println(dat)
  27049. } else {
  27050. fmt.Println(err)
  27051. }
  27052. saveLog(result, request_log, "2204", "上传费用明细")
  27053. userJSONBytes, _ := json.Marshal(dat)
  27054. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27055. utils.ErrorLog("解析失败:%v", err)
  27056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27057. return
  27058. }
  27059. }
  27060. }
  27061. }
  27062. var total_two float64
  27063. if res.Infcode == -1 {
  27064. errlog := &models.HisOrderError{
  27065. UserOrgId: adminUser.CurrentOrgId,
  27066. Ctime: time.Now().Unix(),
  27067. Mtime: time.Now().Unix(),
  27068. Number: chrg_bchno,
  27069. ErrMsg: res.ErrMsg,
  27070. Status: 1,
  27071. PatientId: id,
  27072. RecordTime: recordDateTime,
  27073. Stage: 4,
  27074. }
  27075. service.CreateErrMsgLog(errlog)
  27076. c.ServeSuccessJSON(map[string]interface{}{
  27077. "failed_code": -10,
  27078. "msg": res.ErrMsg,
  27079. })
  27080. return
  27081. }
  27082. if res.Infcode == 0 {
  27083. order := &models.HisOrder{
  27084. UserOrgId: adminUser.CurrentOrgId,
  27085. HisPatientId: his.ID,
  27086. PatientId: his.PatientId,
  27087. SettleAccountsDate: recordDateTime,
  27088. Ctime: time.Now().Unix(),
  27089. Mtime: time.Now().Unix(),
  27090. MdtrtId: his.Number,
  27091. PsnNo: his.PsnNo,
  27092. MedType: strconv.FormatInt(reg_type, 10),
  27093. Status: 1,
  27094. Number: chrg_bchno,
  27095. Infcode: res.Infcode,
  27096. WarnMsg: res.WarnMsg,
  27097. Cainfo: res.Cainfo,
  27098. ErrMsg: res.ErrMsg,
  27099. RespondTime: res.RefmsgTime,
  27100. InfRefmsgid: res.InfRefmsgid,
  27101. OrderStatus: 1,
  27102. IsMedicineInsurance: 1,
  27103. SettleType: settle_accounts_type,
  27104. SettleStartTime: start_time,
  27105. SettleEndTime: end_time,
  27106. Creator: roles.AdminUserId,
  27107. Modify: roles.AdminUserId,
  27108. PType: 2,
  27109. Diagnosis: diagnosis_id,
  27110. }
  27111. err = service.CreateOrder(order)
  27112. if err != nil {
  27113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  27114. return
  27115. }
  27116. for _, item := range res.Output.Result {
  27117. temp := strings.Split(item.FeedetlSn, "-")
  27118. var advice_id int64 = 0
  27119. var project_id int64 = 0
  27120. var types int64 = 0
  27121. id, _ := strconv.ParseInt(temp[2], 10, 64)
  27122. types, _ = strconv.ParseInt(temp[1], 10, 64)
  27123. if temp[1] == "1" {
  27124. advice_id = id
  27125. project_id = 0
  27126. } else if temp[1] == "2" {
  27127. advice_id = 0
  27128. project_id = id
  27129. }
  27130. total_two = total_two + item.DetItemFeeSumamt
  27131. info := &models.HisOrderInfo{
  27132. OrderNumber: order.Number,
  27133. FeedetlSn: item.FeedetlSn,
  27134. UploadDate: time.Now().Unix(),
  27135. AdviceId: advice_id,
  27136. DetItemFeeSumamt: item.DetItemFeeSumamt,
  27137. Cnt: item.Cnt,
  27138. Pric: float64(item.Pric),
  27139. PatientId: his.PatientId,
  27140. PricUplmtAmt: item.PricUplmtAmt,
  27141. SelfpayProp: item.SelfpayProp,
  27142. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  27143. OverlmtAmt: item.OverlmtAmt,
  27144. PreselfpayAmt: item.PreselfpayAmt,
  27145. BasMednFlag: item.BasMednFlag,
  27146. MedChrgitmType: item.MedChrgitmType,
  27147. HiNegoDrugFlag: item.HiNegoDrugFlag,
  27148. Status: 1,
  27149. Memo: item.Memo,
  27150. Mtime: time.Now().Unix(),
  27151. InscpScpAmt: item.InscpScpAmt,
  27152. DrtReimFlag: item.DrtReimFlag,
  27153. Ctime: time.Now().Unix(),
  27154. ListSpItemFlag: item.ListSpItemFlag,
  27155. ChldMedcFlag: item.ChldMedcFlag,
  27156. LmtUsedFlag: item.LmtUsedFlag,
  27157. ChrgitmLv: item.ChrgitmLv,
  27158. UserOrgId: adminUser.CurrentOrgId,
  27159. HisPatientId: his.ID,
  27160. OrderId: order.ID,
  27161. ProjectId: project_id,
  27162. Type: types,
  27163. }
  27164. service.CreateOrderInfo(info)
  27165. }
  27166. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  27167. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  27168. var total float64
  27169. for _, item := range prescriptions {
  27170. if item.Type == 1 { //药品
  27171. for _, subItem := range item.HisDoctorAdviceInfo {
  27172. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27173. total_one := price * subItem.PrescribingNumber
  27174. fmt.Println("subItem")
  27175. fmt.Println(subItem.Price)
  27176. fmt.Println("price")
  27177. fmt.Println(price)
  27178. fmt.Println("total_one")
  27179. fmt.Println(total_one)
  27180. total = total + total_one
  27181. fmt.Println(total)
  27182. }
  27183. }
  27184. if item.Type == 2 { //项目
  27185. for _, subItem := range item.HisPrescriptionProject {
  27186. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  27187. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27188. total_one := price * cnt
  27189. total = total + total_one
  27190. }
  27191. }
  27192. }
  27193. allTotal := fmt.Sprintf("%.2f", total)
  27194. if res.Infcode == 0 {
  27195. var rf []*ResultFive
  27196. json.Unmarshal([]byte(his.Iinfo), &rf)
  27197. chrg_bchno := chrg_bchno
  27198. cert_no := his.Certno
  27199. var insutypes []string
  27200. var insutype string
  27201. var is390 int = 0
  27202. var is310 int = 0
  27203. for _, item := range rf {
  27204. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27205. insutypes = append(insutypes, item.Insutype)
  27206. }
  27207. }
  27208. if len(insutypes) == 1 {
  27209. insutype = insutypes[0]
  27210. } else {
  27211. for _, i := range insutypes {
  27212. if i == "390" {
  27213. is390 = 1
  27214. }
  27215. if i == "310" {
  27216. is310 = 1
  27217. }
  27218. }
  27219. }
  27220. if is390 == 1 {
  27221. insutype = "390"
  27222. }
  27223. if is310 == 1 {
  27224. insutype = "310"
  27225. }
  27226. if len(insutypes) == 0 {
  27227. insutype = "390"
  27228. }
  27229. if len(insutypes) == 2 {
  27230. insutype = strconv.FormatInt(his.SocialType, 10)
  27231. }
  27232. //insutype = "390"
  27233. if his.IdCardType == 1 {
  27234. cert_no = his.MedicalInsuranceNumber
  27235. } else {
  27236. cert_no = his.Certno
  27237. }
  27238. var res ResultSeven
  27239. var ahres ResultSevenAH
  27240. var resSeven10265 ResultSeven10265
  27241. var resSeven10265Two ResultSeven10265Two
  27242. var gzresSeven10265Two GZResultSeven10265Two
  27243. if miConfig.MdtrtareaAdmvs == "421300" {
  27244. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  27245. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27246. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27247. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27248. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27249. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27250. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27251. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  27252. resp, requestErr := http.Get(api)
  27253. if requestErr != nil {
  27254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27255. return
  27256. }
  27257. body, ioErr := ioutil.ReadAll(resp.Body)
  27258. if ioErr != nil {
  27259. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27261. return
  27262. }
  27263. var respJSON map[string]interface{}
  27264. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27265. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27267. return
  27268. }
  27269. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27270. result, _ := json.Marshal(respJSON)
  27271. fmt.Println("log")
  27272. fmt.Println(string(result))
  27273. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27274. utils.ErrorLog("解析失败:%v", err)
  27275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27276. return
  27277. }
  27278. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27279. if reg_type == 11 && his.Insutype == "390" {
  27280. reg_type = 110104
  27281. }
  27282. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27283. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27284. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27285. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27286. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27287. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27288. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  27289. resp, requestErr := http.Get(api)
  27290. if requestErr != nil {
  27291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27292. return
  27293. }
  27294. body, ioErr := ioutil.ReadAll(resp.Body)
  27295. if ioErr != nil {
  27296. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27298. return
  27299. }
  27300. var respJSON map[string]interface{}
  27301. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27302. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27304. return
  27305. }
  27306. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27307. result, _ := json.Marshal(respJSON)
  27308. fmt.Println("log")
  27309. fmt.Println(string(result))
  27310. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27311. utils.ErrorLog("解析失败:%v", err)
  27312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27313. return
  27314. }
  27315. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27316. if reg_type == 11 && his.Insutype == "390" {
  27317. reg_type = 110104
  27318. }
  27319. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27320. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27321. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27322. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27323. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27324. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27325. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  27326. resp, requestErr := http.Get(api)
  27327. if requestErr != nil {
  27328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27329. return
  27330. }
  27331. body, ioErr := ioutil.ReadAll(resp.Body)
  27332. if ioErr != nil {
  27333. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27335. return
  27336. }
  27337. var respJSON map[string]interface{}
  27338. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27339. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27341. return
  27342. }
  27343. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27344. result, _ := json.Marshal(respJSON)
  27345. fmt.Println("log")
  27346. fmt.Println(string(result))
  27347. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27348. utils.ErrorLog("解析失败:%v", err)
  27349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27350. return
  27351. }
  27352. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27353. if reg_type == 11 && his.Insutype == "390" {
  27354. reg_type = 110104
  27355. }
  27356. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27357. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27358. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27359. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27360. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27361. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27362. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  27363. resp, requestErr := http.Get(api)
  27364. if requestErr != nil {
  27365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27366. return
  27367. }
  27368. body, ioErr := ioutil.ReadAll(resp.Body)
  27369. if ioErr != nil {
  27370. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27372. return
  27373. }
  27374. var respJSON map[string]interface{}
  27375. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27376. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27378. return
  27379. }
  27380. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27381. result, _ := json.Marshal(respJSON)
  27382. fmt.Println("log")
  27383. fmt.Println(string(result))
  27384. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27385. utils.ErrorLog("解析失败:%v", err)
  27386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27387. return
  27388. }
  27389. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27390. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  27391. if result3101.Infcode == "0" {
  27392. if len(result3101.Output.Result) > 0 {
  27393. var errMsgs []string
  27394. for _, item := range result3101.Output.Result {
  27395. errMsgs = append(errMsgs, item.VolaCont)
  27396. }
  27397. c.ServeSuccessJSON(map[string]interface{}{
  27398. "failed_code": -10,
  27399. "msg": errMsgs,
  27400. })
  27401. return
  27402. } else {
  27403. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27404. if his.IdCardType != 4 {
  27405. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27406. bas := strings.Split(psn_info.CardInfo, "|")
  27407. if his.IdCardType == 1 {
  27408. cert_no = bas[2]
  27409. } else {
  27410. cert_no = bas[1]
  27411. }
  27412. } else {
  27413. cert_no = his.Certno
  27414. }
  27415. //江苏地区国家医保医疗类别
  27416. //职工透析:医疗类别选特殊情况门诊9933
  27417. //居民血透门慢: 医疗类别选门诊慢病1402
  27418. //var med_type string
  27419. //if his.Insutype == "310" {
  27420. // if reg_type == 14 {
  27421. // med_type = "9933"
  27422. // } else if reg_type == 11 {
  27423. // med_type = "11"
  27424. //
  27425. // }
  27426. //} else if his.Insutype == "390" {
  27427. // if reg_type == 14 {
  27428. // med_type = "1402"
  27429. // } else if reg_type == 11 {
  27430. // med_type = "11"
  27431. // }
  27432. //}
  27433. var api string
  27434. if miConfig.MdtrtareaAdmvs == "320921" {
  27435. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27436. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27437. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27438. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27439. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27440. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27441. "&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
  27442. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27443. } else {
  27444. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27445. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27446. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27447. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27448. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27449. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27450. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27451. "&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
  27452. }
  27453. resp, requestErr := http.Get(api)
  27454. if requestErr != nil {
  27455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27456. return
  27457. }
  27458. body, ioErr := ioutil.ReadAll(resp.Body)
  27459. if ioErr != nil {
  27460. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27462. return
  27463. }
  27464. var respJSON map[string]interface{}
  27465. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27466. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27468. return
  27469. }
  27470. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27471. result, _ := json.Marshal(respJSON)
  27472. fmt.Println("log")
  27473. fmt.Println(string(result))
  27474. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  27475. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27476. utils.ErrorLog("解析失败:%v", err)
  27477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27478. return
  27479. }
  27480. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27481. res.Output = resSeven10265.Output
  27482. res.ErrMsg = resSeven10265.ErrMsg
  27483. res.Cainfo = resSeven10265.Cainfo
  27484. res.WarnMsg = resSeven10265.WarnMsg
  27485. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27486. res.Infcode = infocode
  27487. } else {
  27488. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  27489. utils.ErrorLog("解析失败:%v", err)
  27490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27491. return
  27492. }
  27493. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  27494. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  27495. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  27496. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  27497. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  27498. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  27499. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  27500. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  27501. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  27502. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  27503. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  27504. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  27505. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  27506. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  27507. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  27508. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27509. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  27510. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  27511. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  27512. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  27513. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  27514. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27515. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  27516. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  27517. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  27518. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  27519. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  27520. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  27521. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  27522. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  27523. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27524. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  27525. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  27526. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  27527. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27528. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27529. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27530. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27531. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  27532. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  27533. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  27534. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  27535. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  27536. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  27537. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  27538. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  27539. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  27540. res.ErrMsg = resSeven10265Two.ErrMsg
  27541. res.Cainfo = resSeven10265Two.Cainfo
  27542. res.WarnMsg = resSeven10265Two.WarnMsg
  27543. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27544. res.Infcode = infocode
  27545. }
  27546. }
  27547. }
  27548. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27549. psn_info, _ := service.GetPsnByPatientId(id)
  27550. var verify_number string
  27551. if psn_info.IdCardType == 4 {
  27552. verify_number = psn_info.VerifyNumber
  27553. } else if psn_info.IdCardType == 1 {
  27554. bas := strings.Split(psn_info.CardInfo, "|")
  27555. cardNumber := bas[2]
  27556. verify_number = cardNumber
  27557. } else {
  27558. psn_info.IdCardType = 2
  27559. verify_number = psn_info.Certno
  27560. }
  27561. var api string
  27562. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27563. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  27564. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27565. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27566. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27567. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27568. "&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
  27569. resp, requestErr := http.Get(api)
  27570. if requestErr != nil {
  27571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27572. return
  27573. }
  27574. body, ioErr := ioutil.ReadAll(resp.Body)
  27575. if ioErr != nil {
  27576. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27578. return
  27579. }
  27580. var respJSON map[string]interface{}
  27581. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27582. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27584. return
  27585. }
  27586. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27587. result, _ := json.Marshal(respJSON)
  27588. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27589. utils.ErrorLog("解析失败:%v", err)
  27590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27591. return
  27592. }
  27593. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27594. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  27595. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  27596. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  27597. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  27598. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  27599. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  27600. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  27601. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  27602. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  27603. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  27604. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  27605. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  27606. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  27607. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  27608. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  27609. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  27610. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  27611. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  27612. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  27613. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27614. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  27615. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  27616. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  27617. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  27618. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  27619. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  27620. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  27621. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  27622. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  27623. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  27624. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  27625. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  27626. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  27627. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27628. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  27629. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  27630. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  27631. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  27632. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  27633. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  27634. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  27635. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  27636. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  27637. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  27638. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  27639. res.ErrMsg = resSeven10265.ErrMsg
  27640. res.Cainfo = resSeven10265.Cainfo
  27641. res.WarnMsg = resSeven10265.WarnMsg
  27642. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27643. res.Infcode = infocode
  27644. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27645. acct_used_flag := "1"
  27646. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  27647. var result string
  27648. var request_log string
  27649. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  27650. 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)
  27651. } else {
  27652. 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)
  27653. }
  27654. var dat map[string]interface{}
  27655. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27656. fmt.Println(dat)
  27657. } else {
  27658. fmt.Println(err)
  27659. }
  27660. saveLog(result, request_log, "2206", "预结算")
  27661. userJSONBytes, _ := json.Marshal(dat)
  27662. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27663. utils.ErrorLog("解析失败:%v", err)
  27664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27665. return
  27666. }
  27667. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27668. var result string
  27669. var request_log string
  27670. if his.IdCardType == 2 {
  27671. 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, "")
  27672. } else if his.IdCardType == 1 {
  27673. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27674. bas := strings.Split(psn_info.CardInfo, "|")
  27675. basNumber := bas[2]
  27676. card_sn := bas[3]
  27677. var rf []*ResultFive
  27678. json.Unmarshal([]byte(his.Iinfo), &rf)
  27679. var psn_type string
  27680. for _, item := range rf {
  27681. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27682. psn_type = item.PsnType
  27683. }
  27684. }
  27685. 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)
  27686. } else {
  27687. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27688. //bas := strings.Split(psn_info.CardInfo, "|")
  27689. //basNumber := bas[2]
  27690. //card_sn := bas[3]
  27691. var rf []*ResultFive
  27692. json.Unmarshal([]byte(his.Iinfo), &rf)
  27693. var psn_type string
  27694. for _, item := range rf {
  27695. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27696. psn_type = item.PsnType
  27697. }
  27698. }
  27699. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27700. 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)
  27701. }
  27702. var dat map[string]interface{}
  27703. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27704. fmt.Println(dat)
  27705. } else {
  27706. fmt.Println(err)
  27707. }
  27708. saveLog(result, request_log, "2206", "预结算")
  27709. userJSONBytes, _ := json.Marshal(dat)
  27710. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27711. utils.ErrorLog("解析失败:%v", err)
  27712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27713. return
  27714. }
  27715. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27716. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27717. if his.IdCardType == 4 {
  27718. psn_info.VerifyNumber = psn_info.VerifyNumber
  27719. cert_no = psn_info.Certno
  27720. } else if his.IdCardType == 2 {
  27721. cert_no = psn_info.Certno
  27722. psn_info.VerifyNumber = psn_info.Certno
  27723. } else {
  27724. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27725. bas := strings.Split(psn_info.CardInfo, "|")
  27726. if his.IdCardType == 1 {
  27727. cert_no = bas[2]
  27728. } else {
  27729. cert_no = bas[1]
  27730. }
  27731. }
  27732. var api string
  27733. var med_type string
  27734. if his.Insutype == "390" {
  27735. if reg_type == 992102 {
  27736. med_type = "992102"
  27737. }
  27738. if reg_type == 140104 {
  27739. med_type = "140104"
  27740. }
  27741. if reg_type == 14 {
  27742. med_type = "140104"
  27743. }
  27744. } else if his.Insutype == "310" {
  27745. if reg_type == 992102 {
  27746. med_type = "992102"
  27747. }
  27748. if reg_type == 14 {
  27749. med_type = "14"
  27750. }
  27751. }
  27752. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27753. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27754. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27755. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27756. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27757. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27758. "&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
  27759. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27760. resp, requestErr := http.Get(api)
  27761. if requestErr != nil {
  27762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27763. return
  27764. }
  27765. body, ioErr := ioutil.ReadAll(resp.Body)
  27766. if ioErr != nil {
  27767. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27769. return
  27770. }
  27771. var respJSON map[string]interface{}
  27772. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27773. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27775. return
  27776. }
  27777. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27778. if status == "0" {
  27779. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27780. c.ServeSuccessJSON(map[string]interface{}{
  27781. "failed_code": -10,
  27782. "msg": err_msg,
  27783. })
  27784. return
  27785. }
  27786. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27787. result, _ := json.Marshal(respJSON)
  27788. fmt.Println("log")
  27789. fmt.Println(string(result))
  27790. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  27791. utils.ErrorLog("解析失败:%v", err)
  27792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27793. return
  27794. }
  27795. res.InfRefmsgid = ahres.InfRefmsgid
  27796. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27797. // 创建对应的Time类型
  27798. t := time.UnixMilli(timestamp)
  27799. // 格式化成指定的日期字符串
  27800. str := t.Format("2006-01-02 15:04:05")
  27801. res.Output.Setlinfo.SetlTime = str
  27802. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27803. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27804. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27805. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27806. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27807. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27808. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27809. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27810. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27811. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  27812. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27813. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27814. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27815. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27816. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27817. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27818. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27819. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27820. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27821. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27822. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27823. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27824. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27825. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27826. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27827. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27828. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27829. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27830. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27831. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27832. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27833. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27834. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27835. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27836. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27837. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27838. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27839. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27840. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27841. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27842. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27843. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27844. //res.Output.Setldetail = ahres.Output.Setldetail
  27845. res.ErrMsg = ahres.ErrMsg
  27846. res.Cainfo = ahres.Cainfo
  27847. res.WarnMsg = ahres.WarnMsg
  27848. res.Infcode = ahres.Infcode
  27849. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27850. var result string
  27851. var request_log string
  27852. if his.IdCardType == 2 {
  27853. 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")
  27854. } else if his.IdCardType == 1 {
  27855. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27856. bas := strings.Split(psn_info.CardInfo, "|")
  27857. basNumber := bas[2]
  27858. card_sn := bas[3]
  27859. 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")
  27860. } else {
  27861. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27862. 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")
  27863. }
  27864. var dat map[string]interface{}
  27865. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27866. fmt.Println(dat)
  27867. } else {
  27868. fmt.Println(err)
  27869. }
  27870. saveLog(result, request_log, "2206", "预结算")
  27871. userJSONBytes, _ := json.Marshal(dat)
  27872. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27873. utils.ErrorLog("解析失败:%v", err)
  27874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27875. return
  27876. }
  27877. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27878. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27879. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27880. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27881. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27882. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27883. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27884. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  27885. resp, requestErr := http.Get(api)
  27886. if requestErr != nil {
  27887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27888. return
  27889. }
  27890. body, ioErr := ioutil.ReadAll(resp.Body)
  27891. if ioErr != nil {
  27892. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27894. return
  27895. }
  27896. var respJSON map[string]interface{}
  27897. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27898. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27900. return
  27901. }
  27902. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27903. result, _ := json.Marshal(respJSON)
  27904. fmt.Println("log")
  27905. fmt.Println(string(result))
  27906. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27907. utils.ErrorLog("解析失败:%v", err)
  27908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27909. return
  27910. }
  27911. } else {
  27912. if miConfig.MdtrtareaAdmvs == "441202" {
  27913. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  27914. if result3101.Infcode == 0 {
  27915. if len(result3101.Output.Result) > 0 {
  27916. var errMsgs []string
  27917. for _, item := range result3101.Output.Result {
  27918. errMsgs = append(errMsgs, item.VolaCont)
  27919. }
  27920. c.ServeSuccessJSON(map[string]interface{}{
  27921. "failed_code": -10,
  27922. "msg": errMsgs,
  27923. })
  27924. return
  27925. } else {
  27926. var result string
  27927. var request_log string
  27928. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27929. allTotal = fmt.Sprintf("%.2f", total_two)
  27930. if his.IdCardType == 4 {
  27931. 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)
  27932. } else {
  27933. 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)
  27934. }
  27935. var dat map[string]interface{}
  27936. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27937. fmt.Println(dat)
  27938. } else {
  27939. fmt.Println(err)
  27940. }
  27941. saveLog(result, request_log, "2206", "预结算")
  27942. //userJSONBytes, _ := json.Marshal(dat)
  27943. //
  27944. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27945. // utils.ErrorLog("解析失败:%v", err)
  27946. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27947. // return
  27948. //}
  27949. userJSONBytes, _ := json.Marshal(dat)
  27950. if miConfig.Code == "H15049901371" {
  27951. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27952. utils.ErrorLog("解析失败:%v", err)
  27953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27954. return
  27955. }
  27956. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27957. res.Output = resSeven10265.Output
  27958. res.ErrMsg = resSeven10265.ErrMsg
  27959. res.Cainfo = resSeven10265.Cainfo
  27960. res.WarnMsg = resSeven10265.WarnMsg
  27961. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27962. res.Infcode = infocode
  27963. } else {
  27964. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27965. utils.ErrorLog("解析失败:%v", err)
  27966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27967. return
  27968. }
  27969. }
  27970. }
  27971. } else {
  27972. c.ServeSuccessJSON(map[string]interface{}{
  27973. "failed_code": -10,
  27974. "msg": result3101.ErrMsg,
  27975. })
  27976. return
  27977. }
  27978. } else if miConfig.MdtrtareaAdmvs == "440205" {
  27979. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  27980. if result3101.Infcode == 0 {
  27981. if len(result3101.Output.Result) > 0 {
  27982. var errMsgs []string
  27983. for _, item := range result3101.Output.Result {
  27984. errMsgs = append(errMsgs, item.VolaCont)
  27985. }
  27986. c.ServeSuccessJSON(map[string]interface{}{
  27987. "failed_code": -10,
  27988. "msg": errMsgs,
  27989. })
  27990. return
  27991. } else {
  27992. var result string
  27993. var request_log string
  27994. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27995. allTotal = fmt.Sprintf("%.2f", total_two)
  27996. if his.IdCardType == 4 {
  27997. 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)
  27998. } else {
  27999. 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)
  28000. }
  28001. var dat map[string]interface{}
  28002. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28003. fmt.Println(dat)
  28004. } else {
  28005. fmt.Println(err)
  28006. }
  28007. saveLog(result, request_log, "2206", "预结算")
  28008. //userJSONBytes, _ := json.Marshal(dat)
  28009. //
  28010. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28011. // utils.ErrorLog("解析失败:%v", err)
  28012. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28013. // return
  28014. //}
  28015. userJSONBytes, _ := json.Marshal(dat)
  28016. if miConfig.Code == "H15049901371" {
  28017. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  28018. utils.ErrorLog("解析失败:%v", err)
  28019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28020. return
  28021. }
  28022. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28023. res.Output = resSeven10265.Output
  28024. res.ErrMsg = resSeven10265.ErrMsg
  28025. res.Cainfo = resSeven10265.Cainfo
  28026. res.WarnMsg = resSeven10265.WarnMsg
  28027. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28028. res.Infcode = infocode
  28029. } else {
  28030. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28031. utils.ErrorLog("解析失败:%v", err)
  28032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28033. return
  28034. }
  28035. }
  28036. }
  28037. } else {
  28038. c.ServeSuccessJSON(map[string]interface{}{
  28039. "failed_code": -10,
  28040. "msg": result3101.ErrMsg,
  28041. })
  28042. return
  28043. }
  28044. } else {
  28045. var result string
  28046. var request_log string
  28047. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28048. allTotal = fmt.Sprintf("%.2f", total_two)
  28049. if his.IdCardType == 4 {
  28050. 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)
  28051. } else {
  28052. 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)
  28053. }
  28054. var dat map[string]interface{}
  28055. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28056. fmt.Println(dat)
  28057. } else {
  28058. fmt.Println(err)
  28059. }
  28060. saveLog(result, request_log, "2206", "预结算")
  28061. //userJSONBytes, _ := json.Marshal(dat)
  28062. //
  28063. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28064. // utils.ErrorLog("解析失败:%v", err)
  28065. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28066. // return
  28067. //}
  28068. userJSONBytes, _ := json.Marshal(dat)
  28069. if miConfig.Code == "H15049901371" {
  28070. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  28071. utils.ErrorLog("解析失败:%v", err)
  28072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28073. return
  28074. }
  28075. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28076. res.Output = resSeven10265.Output
  28077. res.ErrMsg = resSeven10265.ErrMsg
  28078. res.Cainfo = resSeven10265.Cainfo
  28079. res.WarnMsg = resSeven10265.WarnMsg
  28080. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28081. res.Infcode = infocode
  28082. } else {
  28083. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28084. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  28085. utils.ErrorLog("解析失败:%v", err)
  28086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28087. return
  28088. }
  28089. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  28090. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  28091. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  28092. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  28093. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  28094. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  28095. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  28096. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28097. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  28098. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28099. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28100. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28101. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28102. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  28103. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  28104. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  28105. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  28106. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  28107. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  28108. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  28109. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28110. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  28111. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  28112. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  28113. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  28114. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  28115. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  28116. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  28117. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  28118. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  28119. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  28120. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  28121. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  28122. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  28123. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  28124. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  28125. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  28126. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  28127. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28128. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  28129. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  28130. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  28131. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  28132. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  28133. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  28134. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  28135. res.ErrMsg = gzresSeven10265Two.ErrMsg
  28136. res.Cainfo = gzresSeven10265Two.Cainfo
  28137. res.WarnMsg = gzresSeven10265Two.WarnMsg
  28138. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  28139. //res.Infcode = infocode
  28140. } else {
  28141. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28142. utils.ErrorLog("解析失败:%v", err)
  28143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28144. return
  28145. }
  28146. }
  28147. }
  28148. }
  28149. }
  28150. utils.ErrorLog("解析失败:%v", res.Infcode)
  28151. if res.Infcode == -1 {
  28152. errlog := &models.HisOrderError{
  28153. UserOrgId: adminUser.CurrentOrgId,
  28154. Ctime: time.Now().Unix(),
  28155. Mtime: time.Now().Unix(),
  28156. Number: chrg_bchno,
  28157. ErrMsg: res.ErrMsg,
  28158. Status: 1,
  28159. PatientId: id,
  28160. RecordTime: recordDateTime,
  28161. Stage: 20,
  28162. }
  28163. service.CreateErrMsgLog(errlog)
  28164. c.ServeSuccessJSON(map[string]interface{}{
  28165. "failed_code": -10,
  28166. "msg": res.ErrMsg,
  28167. })
  28168. return
  28169. }
  28170. if res.Infcode != 0 {
  28171. errlog := &models.HisOrderError{
  28172. UserOrgId: adminUser.CurrentOrgId,
  28173. Ctime: time.Now().Unix(),
  28174. Mtime: time.Now().Unix(),
  28175. Number: chrg_bchno,
  28176. ErrMsg: res.ErrMsg,
  28177. Status: 1,
  28178. PatientId: id,
  28179. RecordTime: recordDateTime,
  28180. Stage: 20,
  28181. }
  28182. service.CreateErrMsgLog(errlog)
  28183. c.ServeSuccessJSON(map[string]interface{}{
  28184. "failed_code": -10,
  28185. "msg": res.ErrMsg,
  28186. })
  28187. return
  28188. } else {
  28189. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  28190. order.OrderStatus = 1
  28191. order.IsPre = 1
  28192. order.Status = 1
  28193. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  28194. order.SetlId = res.Output.Setlinfo.SetlID
  28195. order.PsnNo = res.Output.Setlinfo.PsnNo
  28196. order.PsnName = res.Output.Setlinfo.PsnName
  28197. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  28198. order.Certno = res.Output.Setlinfo.Certno
  28199. order.Gend = res.Output.Setlinfo.Gend
  28200. order.Naty = res.Output.Setlinfo.Naty
  28201. order.Age = res.Output.Setlinfo.Age
  28202. order.Insutype = res.Output.Setlinfo.Insutype
  28203. order.PsnType = res.Output.Setlinfo.PsnType
  28204. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  28205. order.SetlTime = res.Output.Setlinfo.SetlTime
  28206. order.AcctUsedFlag = acct_used_flag
  28207. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  28208. if res.Output.Setlinfo.MedType == "140101" {
  28209. order.MedType = "14"
  28210. } else {
  28211. if res.Output.Setlinfo.MedType == "110104" {
  28212. order.MedType = "11"
  28213. } else {
  28214. order.MedType = res.Output.Setlinfo.MedType
  28215. }
  28216. }
  28217. if res.Output.Setlinfo.MedType == "992102" {
  28218. order.MedType = "992102"
  28219. }
  28220. if res.Output.Setlinfo.MedType == "140104" {
  28221. order.MedType = "140104"
  28222. }
  28223. if res.Output.Setlinfo.MedType == "14" {
  28224. order.MedType = "14"
  28225. }
  28226. if reg_type == 1112 {
  28227. order.MedType = "1112"
  28228. }
  28229. if reg_type == 1111 {
  28230. order.MedType = "1111"
  28231. }
  28232. order.ClrType = res.Output.Setlinfo.ClrType
  28233. if adminUser.CurrentOrgId == 10480 {
  28234. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  28235. order.ClrType = "11"
  28236. } else {
  28237. order.ClrType = "9903"
  28238. }
  28239. }
  28240. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  28241. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  28242. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  28243. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  28244. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  28245. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  28246. order.HifpPay = res.Output.Setlinfo.HifpPay
  28247. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  28248. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  28249. order.HifesPay = res.Output.Setlinfo.HifesPay
  28250. order.HifobPay = res.Output.Setlinfo.HifobPay
  28251. order.MafPay = res.Output.Setlinfo.MafPay
  28252. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  28253. order.OthPay = res.Output.Setlinfo.OthPay
  28254. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  28255. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  28256. order.AcctPay = res.Output.Setlinfo.AcctPay
  28257. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  28258. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  28259. order.Balc = res.Output.Setlinfo.Balc
  28260. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  28261. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  28262. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  28263. order.ClrWay = res.Output.Setlinfo.ClrWay
  28264. order.Creator = order.Creator
  28265. order.Modify = roles.AdminUserId
  28266. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  28267. //detailStr := string(setlDetail)
  28268. //order.SetlDetail = detailStr
  28269. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  28270. err = service.UpDateOrder(order)
  28271. if err == nil {
  28272. c.ServeSuccessJSON(map[string]interface{}{
  28273. "msg": "预结算成功",
  28274. })
  28275. } else {
  28276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  28277. return
  28278. }
  28279. }
  28280. } else {
  28281. adminUser := c.GetAdminUserInfo()
  28282. errlog := &models.HisOrderError{
  28283. UserOrgId: adminUser.CurrentOrgId,
  28284. Ctime: time.Now().Unix(),
  28285. Mtime: time.Now().Unix(),
  28286. ErrMsg: res.ErrMsg,
  28287. Status: 1,
  28288. PatientId: id,
  28289. RecordTime: recordDateTime,
  28290. Stage: 4,
  28291. }
  28292. service.CreateErrMsgLog(errlog)
  28293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  28294. return
  28295. }
  28296. } else {
  28297. if miConfig.MdtrtareaAdmvs == "150499" {
  28298. order := &models.HisOrder{
  28299. UserOrgId: adminUser.CurrentOrgId,
  28300. HisPatientId: his.ID,
  28301. PatientId: his.PatientId,
  28302. SettleAccountsDate: recordDateTime,
  28303. Ctime: time.Now().Unix(),
  28304. Mtime: time.Now().Unix(),
  28305. MdtrtId: his.Number,
  28306. PsnNo: his.PsnNo,
  28307. MedType: strconv.FormatInt(reg_type, 10),
  28308. Status: 1,
  28309. Number: chrg_bchno,
  28310. Infcode: res.Infcode,
  28311. WarnMsg: res.WarnMsg,
  28312. Cainfo: res.Cainfo,
  28313. ErrMsg: res.ErrMsg,
  28314. RespondTime: res.RefmsgTime,
  28315. InfRefmsgid: res.InfRefmsgid,
  28316. OrderStatus: 1,
  28317. IsMedicineInsurance: 1,
  28318. SettleType: settle_accounts_type,
  28319. SettleStartTime: start_time,
  28320. SettleEndTime: end_time,
  28321. Creator: roles.AdminUserId,
  28322. Modify: roles.AdminUserId,
  28323. PType: 2,
  28324. Diagnosis: diagnosis_id,
  28325. }
  28326. err = service.CreateOrder(order)
  28327. if err != nil {
  28328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  28329. return
  28330. }
  28331. }
  28332. adminUser := c.GetAdminUserInfo()
  28333. errlog := &models.HisOrderError{
  28334. UserOrgId: adminUser.CurrentOrgId,
  28335. Ctime: time.Now().Unix(),
  28336. Mtime: time.Now().Unix(),
  28337. ErrMsg: res.ErrMsg,
  28338. Status: 1,
  28339. PatientId: id,
  28340. RecordTime: recordDateTime,
  28341. Stage: 4,
  28342. }
  28343. service.CreateErrMsgLog(errlog)
  28344. c.ServeSuccessJSON(map[string]interface{}{
  28345. "failed_code": -10,
  28346. "msg": res.ErrMsg,
  28347. })
  28348. return
  28349. }
  28350. }
  28351. }
  28352. }
  28353. // 退款
  28354. func (c *HisApiController) Refund() {
  28355. order_id, _ := c.GetInt64("order_id")
  28356. admin_user_id, _ := c.GetInt64("admin_user_id")
  28357. adminUser := c.GetAdminUserInfo()
  28358. var order models.HisOrder
  28359. order, _ = service.GetHisOrderByID(order_id)
  28360. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  28361. if fapiao.ID > 0 {
  28362. c.ServeSuccessJSON(map[string]interface{}{
  28363. "failed_code": -10,
  28364. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  28365. })
  28366. return
  28367. }
  28368. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28369. if order.ID == 0 {
  28370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28371. return
  28372. }
  28373. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  28374. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28375. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28376. if config.IsOpen == 1 { //对接了医保,走医保流程
  28377. var res ResultSixteen
  28378. var ahres ResultSevenAH
  28379. var resSixteen10265 ResultSixteen10265
  28380. var resSixteen10265Two ResultSixteen10265Two
  28381. var gz ResultgzSixteen10265Two
  28382. var src_resquest string
  28383. var result string
  28384. if miConfig.MdtrtareaAdmvs == "421300" {
  28385. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  28386. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28387. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28388. resp3, requestErr3 := http.Get(api3)
  28389. if requestErr3 != nil {
  28390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28391. return
  28392. }
  28393. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28394. if ioErr3 != nil {
  28395. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28397. return
  28398. }
  28399. var respJSON3 map[string]interface{}
  28400. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28401. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28403. return
  28404. }
  28405. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28406. userJSONBytes3, _ := json.Marshal(respJSON3)
  28407. fmt.Println("log")
  28408. fmt.Println(string(userJSONBytes3))
  28409. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28410. utils.ErrorLog("解析失败:%v", err)
  28411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28412. return
  28413. }
  28414. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28415. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  28416. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28417. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28418. resp3, requestErr3 := http.Get(api3)
  28419. if requestErr3 != nil {
  28420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28421. return
  28422. }
  28423. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28424. if ioErr3 != nil {
  28425. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28427. return
  28428. }
  28429. var respJSON3 map[string]interface{}
  28430. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28431. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28433. return
  28434. }
  28435. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28436. userJSONBytes3, _ := json.Marshal(respJSON3)
  28437. fmt.Println("log")
  28438. fmt.Println(string(userJSONBytes3))
  28439. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28440. utils.ErrorLog("解析失败:%v", err)
  28441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28442. return
  28443. }
  28444. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28445. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  28446. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28447. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28448. resp3, requestErr3 := http.Get(api3)
  28449. if requestErr3 != nil {
  28450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28451. return
  28452. }
  28453. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28454. if ioErr3 != nil {
  28455. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28457. return
  28458. }
  28459. var respJSON3 map[string]interface{}
  28460. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28461. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28463. return
  28464. }
  28465. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28466. userJSONBytes3, _ := json.Marshal(respJSON3)
  28467. fmt.Println("log")
  28468. fmt.Println(string(userJSONBytes3))
  28469. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28470. utils.ErrorLog("解析失败:%v", err)
  28471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28472. return
  28473. }
  28474. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28475. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  28476. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28477. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28478. resp3, requestErr3 := http.Get(api3)
  28479. if requestErr3 != nil {
  28480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28481. return
  28482. }
  28483. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28484. if ioErr3 != nil {
  28485. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28487. return
  28488. }
  28489. var respJSON3 map[string]interface{}
  28490. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28491. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28493. return
  28494. }
  28495. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28496. userJSONBytes3, _ := json.Marshal(respJSON3)
  28497. fmt.Println("log")
  28498. fmt.Println(string(userJSONBytes3))
  28499. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28500. utils.ErrorLog("解析失败:%v", err)
  28501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28502. return
  28503. }
  28504. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28505. var api3 string
  28506. if miConfig.MdtrtareaAdmvs == "320921" {
  28507. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  28508. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28509. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28510. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28511. } else {
  28512. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28513. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  28514. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28515. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28516. }
  28517. resp3, requestErr3 := http.Get(api3)
  28518. if requestErr3 != nil {
  28519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28520. return
  28521. }
  28522. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28523. if ioErr3 != nil {
  28524. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28526. return
  28527. }
  28528. var respJSON3 map[string]interface{}
  28529. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28530. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28532. return
  28533. }
  28534. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28535. userJSONBytes3, _ := json.Marshal(respJSON3)
  28536. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  28537. utils.ErrorLog("解析失败:%v", err)
  28538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28539. return
  28540. }
  28541. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  28542. res.Output = resSixteen10265.Output
  28543. res.ErrMsg = resSixteen10265.ErrMsg
  28544. res.Cainfo = resSixteen10265.Cainfo
  28545. res.WarnMsg = resSixteen10265.WarnMsg
  28546. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  28547. res.Infcode = infocode
  28548. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28549. var api3 string
  28550. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  28551. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28552. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28553. resp3, requestErr3 := http.Get(api3)
  28554. if requestErr3 != nil {
  28555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28556. return
  28557. }
  28558. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28559. if ioErr3 != nil {
  28560. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28562. return
  28563. }
  28564. var respJSON3 map[string]interface{}
  28565. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28566. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28568. return
  28569. }
  28570. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28571. userJSONBytes3, _ := json.Marshal(respJSON3)
  28572. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  28573. utils.ErrorLog("解析失败:%v", err)
  28574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28575. return
  28576. }
  28577. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  28578. res.Output = resSixteen10265.Output
  28579. res.ErrMsg = resSixteen10265.ErrMsg
  28580. res.Cainfo = resSixteen10265.Cainfo
  28581. res.WarnMsg = resSixteen10265.WarnMsg
  28582. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  28583. res.Infcode = infocode
  28584. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28585. 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)
  28586. var dat map[string]interface{}
  28587. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28588. fmt.Println(dat)
  28589. } else {
  28590. fmt.Println(err)
  28591. }
  28592. saveLog(result, src_resquest, "2208", "退费")
  28593. userJSONBytes, _ := json.Marshal(dat)
  28594. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28595. utils.ErrorLog("解析失败:%v", err)
  28596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28597. return
  28598. }
  28599. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28600. 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, "")
  28601. var dat map[string]interface{}
  28602. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28603. fmt.Println(dat)
  28604. } else {
  28605. fmt.Println(err)
  28606. }
  28607. saveLog(result, src_resquest, "2208", "退费")
  28608. userJSONBytes, _ := json.Marshal(dat)
  28609. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28610. utils.ErrorLog("解析失败:%v", err)
  28611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28612. return
  28613. }
  28614. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28615. var api3 string
  28616. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  28617. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28618. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28619. resp3, requestErr3 := http.Get(api3)
  28620. if requestErr3 != nil {
  28621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28622. return
  28623. }
  28624. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28625. if ioErr3 != nil {
  28626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28628. return
  28629. }
  28630. var respJSON3 map[string]interface{}
  28631. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28632. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28634. return
  28635. }
  28636. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  28637. if status == "0" {
  28638. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  28639. c.ServeSuccessJSON(map[string]interface{}{
  28640. "failed_code": -10,
  28641. "msg": err_msg,
  28642. })
  28643. return
  28644. }
  28645. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28646. userJSONBytes3, _ := json.Marshal(respJSON3)
  28647. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28648. // utils.ErrorLog("解析失败:%v", err)
  28649. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28650. // return
  28651. //}
  28652. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  28653. utils.ErrorLog("解析失败:%v", err)
  28654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28655. return
  28656. }
  28657. res.InfRefmsgid = ahres.InfRefmsgid
  28658. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28659. // 创建对应的Time类型
  28660. t := time.UnixMilli(timestamp)
  28661. // 格式化成指定的日期字符串
  28662. str := t.Format("2006-01-02 15:04:05")
  28663. res.Output.Setlinfo.SetlTime = str
  28664. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  28665. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  28666. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28667. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  28668. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  28669. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  28670. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28671. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  28672. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  28673. //
  28674. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  28675. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  28676. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  28677. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28678. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  28679. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  28680. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  28681. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  28682. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  28683. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  28684. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28685. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  28686. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  28687. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  28688. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  28689. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  28690. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  28691. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  28692. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  28693. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  28694. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  28695. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  28696. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  28697. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  28698. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  28699. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  28700. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  28701. //res.Output.Setldetail = ahres.Output.Setldetail
  28702. res.ErrMsg = ahres.ErrMsg
  28703. res.Cainfo = ahres.Cainfo
  28704. res.WarnMsg = ahres.WarnMsg
  28705. res.Infcode = ahres.Infcode
  28706. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28707. 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, "")
  28708. var dat map[string]interface{}
  28709. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28710. fmt.Println(dat)
  28711. } else {
  28712. fmt.Println(err)
  28713. }
  28714. saveLog(result, src_resquest, "2208", "退费")
  28715. userJSONBytes, _ := json.Marshal(dat)
  28716. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28717. utils.ErrorLog("解析失败:%v", err)
  28718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28719. return
  28720. }
  28721. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28722. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  28723. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28724. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28725. resp3, requestErr3 := http.Get(api3)
  28726. if requestErr3 != nil {
  28727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28728. return
  28729. }
  28730. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28731. if ioErr3 != nil {
  28732. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28734. return
  28735. }
  28736. var respJSON3 map[string]interface{}
  28737. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28738. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28740. return
  28741. }
  28742. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28743. userJSONBytes3, _ := json.Marshal(respJSON3)
  28744. fmt.Println("log")
  28745. fmt.Println(string(userJSONBytes3))
  28746. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28747. utils.ErrorLog("解析失败:%v", err)
  28748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28749. return
  28750. }
  28751. } else {
  28752. if miConfig.Code == "H15049901371" {
  28753. 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)
  28754. var dat map[string]interface{}
  28755. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28756. fmt.Println(dat)
  28757. } else {
  28758. fmt.Println(err)
  28759. }
  28760. saveLog(result, src_resquest, "2208", "退费")
  28761. if strings.Contains(result, "Post") {
  28762. res.Infcode = -1
  28763. res.ErrMsg = result
  28764. }
  28765. userJSONBytes, _ := json.Marshal(dat)
  28766. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  28767. utils.ErrorLog("解析失败:%v", err)
  28768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28769. return
  28770. }
  28771. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  28772. res.Output = resSixteen10265.Output
  28773. res.ErrMsg = resSixteen10265.ErrMsg
  28774. res.Cainfo = resSixteen10265.Cainfo
  28775. res.WarnMsg = resSixteen10265.WarnMsg
  28776. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  28777. res.Infcode = infocode
  28778. } else {
  28779. 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)
  28780. var dat map[string]interface{}
  28781. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28782. fmt.Println(dat)
  28783. } else {
  28784. fmt.Println(err)
  28785. }
  28786. saveLog(result, src_resquest, "2208", "退费")
  28787. userJSONBytes, _ := json.Marshal(dat)
  28788. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28789. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  28790. utils.ErrorLog("解析失败:%v", err)
  28791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28792. return
  28793. }
  28794. res.Infcode = gz.Infcode
  28795. } else {
  28796. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28797. utils.ErrorLog("解析失败:%v", err)
  28798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28799. return
  28800. }
  28801. }
  28802. if strings.Contains(result, "Post") {
  28803. res.Infcode = -1
  28804. res.ErrMsg = result
  28805. }
  28806. }
  28807. }
  28808. if res.Infcode == -1 {
  28809. c.ServeSuccessJSON(map[string]interface{}{
  28810. "failed_code": -10,
  28811. "msg": res.ErrMsg,
  28812. })
  28813. return
  28814. }
  28815. if res.Infcode != -1 {
  28816. var res2 ResultSix
  28817. var resSix10265 ResultSix10265
  28818. if miConfig.MdtrtareaAdmvs == "421300" {
  28819. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  28820. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28821. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28822. resp3, requestErr3 := http.Get(api3)
  28823. if requestErr3 != nil {
  28824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28825. return
  28826. }
  28827. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28828. if ioErr3 != nil {
  28829. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28831. return
  28832. }
  28833. var respJSON3 map[string]interface{}
  28834. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28837. return
  28838. }
  28839. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28840. userJSONBytes3, _ := json.Marshal(respJSON3)
  28841. fmt.Println("log")
  28842. fmt.Println(string(userJSONBytes3))
  28843. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28844. utils.ErrorLog("解析失败:%v", err)
  28845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28846. return
  28847. }
  28848. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28849. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  28850. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28851. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28852. resp3, requestErr3 := http.Get(api3)
  28853. if requestErr3 != nil {
  28854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28855. return
  28856. }
  28857. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28858. if ioErr3 != nil {
  28859. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28861. return
  28862. }
  28863. var respJSON3 map[string]interface{}
  28864. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28867. return
  28868. }
  28869. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28870. userJSONBytes3, _ := json.Marshal(respJSON3)
  28871. fmt.Println("log")
  28872. fmt.Println(string(userJSONBytes3))
  28873. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28874. utils.ErrorLog("解析失败:%v", err)
  28875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28876. return
  28877. }
  28878. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28879. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  28880. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28881. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28882. resp3, requestErr3 := http.Get(api3)
  28883. if requestErr3 != nil {
  28884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28885. return
  28886. }
  28887. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28888. if ioErr3 != nil {
  28889. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28891. return
  28892. }
  28893. var respJSON3 map[string]interface{}
  28894. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28895. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28897. return
  28898. }
  28899. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28900. userJSONBytes3, _ := json.Marshal(respJSON3)
  28901. fmt.Println("log")
  28902. fmt.Println(string(userJSONBytes3))
  28903. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28904. utils.ErrorLog("解析失败:%v", err)
  28905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28906. return
  28907. }
  28908. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28909. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  28910. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28911. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28912. resp3, requestErr3 := http.Get(api3)
  28913. if requestErr3 != nil {
  28914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28915. return
  28916. }
  28917. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28918. if ioErr3 != nil {
  28919. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28921. return
  28922. }
  28923. var respJSON3 map[string]interface{}
  28924. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28927. return
  28928. }
  28929. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28930. userJSONBytes3, _ := json.Marshal(respJSON3)
  28931. fmt.Println("log")
  28932. fmt.Println(string(userJSONBytes3))
  28933. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28934. utils.ErrorLog("解析失败:%v", err)
  28935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28936. return
  28937. }
  28938. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28939. var api3 string
  28940. if miConfig.MdtrtareaAdmvs == "320921" {
  28941. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  28942. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28943. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28944. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28945. } else {
  28946. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28947. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  28948. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28949. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28950. }
  28951. resp3, requestErr3 := http.Get(api3)
  28952. if requestErr3 != nil {
  28953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28954. return
  28955. }
  28956. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28957. if ioErr3 != nil {
  28958. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28960. return
  28961. }
  28962. var respJSON3 map[string]interface{}
  28963. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28964. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28966. return
  28967. }
  28968. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28969. userJSONBytes3, _ := json.Marshal(respJSON3)
  28970. fmt.Println("log")
  28971. fmt.Println(string(userJSONBytes3))
  28972. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  28973. utils.ErrorLog("解析失败:%v", err)
  28974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28975. return
  28976. }
  28977. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28978. res2.Output = resSix10265.Output
  28979. res2.ErrMsg = resSix10265.ErrMsg
  28980. res2.Cainfo = resSix10265.Cainfo
  28981. res2.WarnMsg = resSix10265.WarnMsg
  28982. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28983. res2.Infcode = infocode
  28984. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28985. var api3 string
  28986. new_chrg_bchno := order.Number
  28987. if adminUser.CurrentOrgId == 10265 {
  28988. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  28989. new_chrg_bchno = "0000"
  28990. }
  28991. }
  28992. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  28993. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28994. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28995. resp3, requestErr3 := http.Get(api3)
  28996. if requestErr3 != nil {
  28997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28998. return
  28999. }
  29000. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29001. if ioErr3 != nil {
  29002. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29004. return
  29005. }
  29006. var respJSON3 map[string]interface{}
  29007. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29008. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29010. return
  29011. }
  29012. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29013. userJSONBytes3, _ := json.Marshal(respJSON3)
  29014. fmt.Println("log")
  29015. fmt.Println(string(userJSONBytes3))
  29016. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  29017. utils.ErrorLog("解析失败:%v", err)
  29018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29019. return
  29020. }
  29021. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29022. res2.Output = resSix10265.Output
  29023. res2.ErrMsg = resSix10265.ErrMsg
  29024. res2.Cainfo = resSix10265.Cainfo
  29025. res2.WarnMsg = resSix10265.WarnMsg
  29026. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29027. res2.Infcode = infocode
  29028. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29029. 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)
  29030. var dat map[string]interface{}
  29031. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29032. fmt.Println(dat)
  29033. } else {
  29034. fmt.Println(err)
  29035. }
  29036. saveLog(result2, src_request, "2205", "撤销明细")
  29037. userJSONBytes, _ := json.Marshal(dat)
  29038. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29039. utils.ErrorLog("解析失败:%v", err)
  29040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29041. return
  29042. }
  29043. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29044. 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, "")
  29045. var dat map[string]interface{}
  29046. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29047. fmt.Println(dat)
  29048. } else {
  29049. fmt.Println(err)
  29050. }
  29051. saveLog(result2, src_request, "2205", "撤销明细")
  29052. userJSONBytes, _ := json.Marshal(dat)
  29053. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29054. utils.ErrorLog("解析失败:%v", err)
  29055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29056. return
  29057. }
  29058. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29059. var api3 string
  29060. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  29061. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29062. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29063. resp3, requestErr3 := http.Get(api3)
  29064. if requestErr3 != nil {
  29065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29066. return
  29067. }
  29068. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29069. if ioErr3 != nil {
  29070. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29072. return
  29073. }
  29074. var respJSON3 map[string]interface{}
  29075. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29076. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29078. return
  29079. }
  29080. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  29081. if status == "0" {
  29082. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  29083. c.ServeSuccessJSON(map[string]interface{}{
  29084. "failed_code": -10,
  29085. "msg": err_msg,
  29086. })
  29087. return
  29088. }
  29089. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29090. userJSONBytes3, _ := json.Marshal(respJSON3)
  29091. fmt.Println("log")
  29092. fmt.Println(string(userJSONBytes3))
  29093. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29094. utils.ErrorLog("解析失败:%v", err)
  29095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29096. return
  29097. }
  29098. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29099. 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, "")
  29100. var dat map[string]interface{}
  29101. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29102. fmt.Println(dat)
  29103. } else {
  29104. fmt.Println(err)
  29105. }
  29106. saveLog(result2, src_request, "2205", "撤销明细")
  29107. userJSONBytes, _ := json.Marshal(dat)
  29108. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29109. utils.ErrorLog("解析失败:%v", err)
  29110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29111. return
  29112. }
  29113. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29114. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  29115. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29116. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29117. resp3, requestErr3 := http.Get(api3)
  29118. if requestErr3 != nil {
  29119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29120. return
  29121. }
  29122. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29123. if ioErr3 != nil {
  29124. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29126. return
  29127. }
  29128. var respJSON3 map[string]interface{}
  29129. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29130. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29132. return
  29133. }
  29134. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29135. userJSONBytes3, _ := json.Marshal(respJSON3)
  29136. fmt.Println("log")
  29137. fmt.Println(string(userJSONBytes3))
  29138. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29139. utils.ErrorLog("解析失败:%v", err)
  29140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29141. return
  29142. }
  29143. } else {
  29144. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  29145. res2.Infcode = 0
  29146. } else {
  29147. 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)
  29148. var dat map[string]interface{}
  29149. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29150. fmt.Println(dat)
  29151. } else {
  29152. fmt.Println(err)
  29153. }
  29154. saveLog(result2, src_request, "2205", "撤销明细")
  29155. userJSONBytes, _ := json.Marshal(dat)
  29156. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29157. utils.ErrorLog("解析失败:%v", err)
  29158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29159. return
  29160. }
  29161. }
  29162. }
  29163. if res2.Infcode == -1 {
  29164. c.ServeSuccessJSON(map[string]interface{}{
  29165. "failed_code": -10,
  29166. "msg": res2.ErrMsg,
  29167. })
  29168. return
  29169. }
  29170. if res2.Infcode == 0 {
  29171. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  29172. if err == nil {
  29173. //当押金不为零时产生退费记录
  29174. if order.Decimal != 0 {
  29175. tmp := strconv.FormatInt(order.ID, 10)
  29176. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  29177. if err != nil {
  29178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29179. return
  29180. }
  29181. }
  29182. c.ServeSuccessJSON(map[string]interface{}{
  29183. "msg": "退费成功",
  29184. })
  29185. } else {
  29186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29187. return
  29188. }
  29189. } else {
  29190. c.ServeSuccessJSON(map[string]interface{}{
  29191. "failed_code": -10,
  29192. "msg": res2.ErrMsg,
  29193. })
  29194. }
  29195. } else {
  29196. c.ServeSuccessJSON(map[string]interface{}{
  29197. "failed_code": -10,
  29198. "msg": res.ErrMsg,
  29199. })
  29200. }
  29201. }
  29202. }
  29203. func (c *HisApiController) RefundNumber() {
  29204. record_time := c.GetString("record_time")
  29205. //patient_id, _ := c.GetInt64("patient_id")
  29206. admin_user_id, _ := c.GetInt64("admin_user_id")
  29207. his_patient_id, _ := c.GetInt64("id")
  29208. timeLayout := "2006-01-02"
  29209. loc, _ := time.LoadLocation("Local")
  29210. adminUser := c.GetAdminUserInfo()
  29211. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  29212. fmt.Println(err)
  29213. if err != nil {
  29214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29215. return
  29216. }
  29217. recordDateTime := theTime.Unix()
  29218. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  29219. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  29220. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  29221. //order, _ := service.GetHisOrderByID(order_id)
  29222. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29223. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29224. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29225. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  29226. if count > 0 {
  29227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  29228. return
  29229. }
  29230. if config.IsOpen == 1 { //对接了医保,走医保流程
  29231. var res2 ResultSix
  29232. var res3 GZResultSix
  29233. var resSix10265 ResultSix10265
  29234. if miConfig.MdtrtareaAdmvs == "421300" {
  29235. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  29236. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29237. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29238. resp3, requestErr3 := http.Get(api3)
  29239. if requestErr3 != nil {
  29240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29241. return
  29242. }
  29243. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29244. if ioErr3 != nil {
  29245. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29247. return
  29248. }
  29249. var respJSON3 map[string]interface{}
  29250. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29251. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29253. return
  29254. }
  29255. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29256. userJSONBytes3, _ := json.Marshal(respJSON3)
  29257. fmt.Println("log")
  29258. fmt.Println(string(userJSONBytes3))
  29259. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29260. utils.ErrorLog("解析失败:%v", err)
  29261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29262. return
  29263. }
  29264. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29265. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  29266. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29267. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29268. resp3, requestErr3 := http.Get(api3)
  29269. if requestErr3 != nil {
  29270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29271. return
  29272. }
  29273. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29274. if ioErr3 != nil {
  29275. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29277. return
  29278. }
  29279. var respJSON3 map[string]interface{}
  29280. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29281. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29283. return
  29284. }
  29285. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29286. userJSONBytes3, _ := json.Marshal(respJSON3)
  29287. fmt.Println("log")
  29288. fmt.Println(string(userJSONBytes3))
  29289. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29290. utils.ErrorLog("解析失败:%v", err)
  29291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29292. return
  29293. }
  29294. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29295. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  29296. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29297. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29298. resp3, requestErr3 := http.Get(api3)
  29299. if requestErr3 != nil {
  29300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29301. return
  29302. }
  29303. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29304. if ioErr3 != nil {
  29305. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29307. return
  29308. }
  29309. var respJSON3 map[string]interface{}
  29310. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29311. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29313. return
  29314. }
  29315. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29316. userJSONBytes3, _ := json.Marshal(respJSON3)
  29317. fmt.Println("log")
  29318. fmt.Println(string(userJSONBytes3))
  29319. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29320. utils.ErrorLog("解析失败:%v", err)
  29321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29322. return
  29323. }
  29324. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29325. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  29326. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29327. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29328. resp3, requestErr3 := http.Get(api3)
  29329. if requestErr3 != nil {
  29330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29331. return
  29332. }
  29333. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29334. if ioErr3 != nil {
  29335. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29337. return
  29338. }
  29339. var respJSON3 map[string]interface{}
  29340. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29341. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29343. return
  29344. }
  29345. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29346. userJSONBytes3, _ := json.Marshal(respJSON3)
  29347. fmt.Println("log")
  29348. fmt.Println(string(userJSONBytes3))
  29349. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29350. utils.ErrorLog("解析失败:%v", err)
  29351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29352. return
  29353. }
  29354. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29355. var api3 string
  29356. if miConfig.MdtrtareaAdmvs == "320921" {
  29357. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  29358. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29359. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29360. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29361. } else {
  29362. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29363. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  29364. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29365. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29366. }
  29367. resp3, requestErr3 := http.Get(api3)
  29368. if requestErr3 != nil {
  29369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29370. return
  29371. }
  29372. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29373. if ioErr3 != nil {
  29374. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29376. return
  29377. }
  29378. var respJSON3 map[string]interface{}
  29379. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29380. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29382. return
  29383. }
  29384. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29385. userJSONBytes3, _ := json.Marshal(respJSON3)
  29386. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  29387. utils.ErrorLog("解析失败:%v", err)
  29388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29389. return
  29390. }
  29391. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29392. res2.Output = resSix10265.Output
  29393. res2.ErrMsg = resSix10265.ErrMsg
  29394. res2.Cainfo = resSix10265.Cainfo
  29395. res2.WarnMsg = resSix10265.WarnMsg
  29396. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29397. res2.Infcode = infocode
  29398. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29399. var api3 string
  29400. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  29401. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29402. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29403. resp3, requestErr3 := http.Get(api3)
  29404. if requestErr3 != nil {
  29405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29406. return
  29407. }
  29408. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29409. if ioErr3 != nil {
  29410. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29412. return
  29413. }
  29414. var respJSON3 map[string]interface{}
  29415. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29416. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29418. return
  29419. }
  29420. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29421. userJSONBytes3, _ := json.Marshal(respJSON3)
  29422. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  29423. utils.ErrorLog("解析失败:%v", err)
  29424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29425. return
  29426. }
  29427. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29428. res2.Output = resSix10265.Output
  29429. res2.ErrMsg = resSix10265.ErrMsg
  29430. res2.Cainfo = resSix10265.Cainfo
  29431. res2.WarnMsg = resSix10265.WarnMsg
  29432. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29433. res2.Infcode = infocode
  29434. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29435. 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)
  29436. var dat map[string]interface{}
  29437. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29438. fmt.Println(dat)
  29439. } else {
  29440. fmt.Println(err)
  29441. }
  29442. saveLog(result, request, "2202", "退号")
  29443. userJSONBytes, _ := json.Marshal(dat)
  29444. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29445. utils.ErrorLog("解析失败:%v", err)
  29446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29447. return
  29448. }
  29449. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29450. 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, "")
  29451. var dat map[string]interface{}
  29452. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29453. fmt.Println(dat)
  29454. } else {
  29455. fmt.Println(err)
  29456. }
  29457. saveLog(result, request, "2202", "退号")
  29458. userJSONBytes, _ := json.Marshal(dat)
  29459. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29460. utils.ErrorLog("解析失败:%v", err)
  29461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29462. return
  29463. }
  29464. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29465. var api3 string
  29466. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  29467. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29468. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29469. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29470. resp3, requestErr3 := http.Get(api3)
  29471. if requestErr3 != nil {
  29472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29473. return
  29474. }
  29475. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29476. if ioErr3 != nil {
  29477. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29479. return
  29480. }
  29481. var respJSON3 map[string]interface{}
  29482. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29483. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29485. return
  29486. }
  29487. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  29488. if status == "0" {
  29489. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  29490. c.ServeSuccessJSON(map[string]interface{}{
  29491. "failed_code": -10,
  29492. "msg": err_msg,
  29493. })
  29494. return
  29495. }
  29496. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29497. userJSONBytes3, _ := json.Marshal(respJSON3)
  29498. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29499. utils.ErrorLog("解析失败:%v", err)
  29500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29501. return
  29502. }
  29503. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  29504. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29505. 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, "")
  29506. var dat map[string]interface{}
  29507. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29508. fmt.Println(dat)
  29509. } else {
  29510. fmt.Println(err)
  29511. }
  29512. saveLog(result, request, "2202", "退号")
  29513. userJSONBytes, _ := json.Marshal(dat)
  29514. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29515. utils.ErrorLog("解析失败:%v", err)
  29516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29517. return
  29518. }
  29519. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29520. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  29521. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29522. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  29523. resp3, requestErr3 := http.Get(api3)
  29524. if requestErr3 != nil {
  29525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29526. return
  29527. }
  29528. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29529. if ioErr3 != nil {
  29530. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29532. return
  29533. }
  29534. var respJSON3 map[string]interface{}
  29535. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29536. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29538. return
  29539. }
  29540. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29541. userJSONBytes3, _ := json.Marshal(respJSON3)
  29542. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29543. utils.ErrorLog("解析失败:%v", err)
  29544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29545. return
  29546. }
  29547. } else {
  29548. var api3 string
  29549. if miConfig.Code == "H15049901371" {
  29550. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  29551. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29552. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29553. } else {
  29554. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  29555. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29556. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  29557. }
  29558. resp3, requestErr3 := http.Get(api3)
  29559. if requestErr3 != nil {
  29560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29561. return
  29562. }
  29563. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29564. if ioErr3 != nil {
  29565. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29567. return
  29568. }
  29569. var respJSON3 map[string]interface{}
  29570. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29573. return
  29574. }
  29575. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29576. userJSONBytes3, _ := json.Marshal(respJSON3)
  29577. if miConfig.Code == "H15049901371" {
  29578. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  29579. utils.ErrorLog("解析失败:%v", err)
  29580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29581. return
  29582. }
  29583. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29584. res2.Output = resSix10265.Output
  29585. res2.ErrMsg = resSix10265.ErrMsg
  29586. res2.Cainfo = resSix10265.Cainfo
  29587. res2.WarnMsg = resSix10265.WarnMsg
  29588. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29589. res2.Infcode = infocode
  29590. } else {
  29591. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  29592. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  29593. utils.ErrorLog("解析失败:%v", err)
  29594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29595. return
  29596. }
  29597. res2.Infcode = res3.Infcode
  29598. } else {
  29599. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29600. utils.ErrorLog("解析失败:%v", err)
  29601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29602. return
  29603. }
  29604. }
  29605. }
  29606. }
  29607. if res2.Infcode == -1 {
  29608. c.ServeSuccessJSON(map[string]interface{}{
  29609. "failed_code": -10,
  29610. "msg": res2.ErrMsg,
  29611. })
  29612. return
  29613. }
  29614. if res2.Infcode == 0 {
  29615. if err == nil {
  29616. c.ServeSuccessJSON(map[string]interface{}{
  29617. "msg": "退号成功",
  29618. })
  29619. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  29620. } else {
  29621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29622. return
  29623. }
  29624. }
  29625. } else {
  29626. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  29627. //if err == nil {
  29628. // c.ServeSuccessJSON(map[string]interface{}{
  29629. // "msg": "退费成功",
  29630. // })
  29631. //} else {
  29632. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29633. // return
  29634. //}
  29635. }
  29636. }
  29637. func (c *HisApiController) RefundDetail() {
  29638. order_id, _ := c.GetInt64("order_id")
  29639. admin_user_id, _ := c.GetInt64("admin_user_id")
  29640. //his_patient_id, _ := c.GetInt64("his_patient_id")
  29641. number := c.GetString("number")
  29642. record_time := c.GetString("record_time")
  29643. patient_id, _ := c.GetInt64("patient_id")
  29644. //med_type, _ := c.GetInt64("med_type")
  29645. timeLayout := "2006-01-02"
  29646. loc, _ := time.LoadLocation("Local")
  29647. adminUser := c.GetAdminUserInfo()
  29648. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29649. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  29650. fmt.Println(err)
  29651. if err != nil {
  29652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29653. return
  29654. }
  29655. recordDateTime := theTime.Unix()
  29656. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29657. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  29658. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29659. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29660. var order models.HisOrder
  29661. order, _ = service.GetHisOrderByID(order_id)
  29662. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  29663. if config.IsOpen == 1 { //对接了医保,走医保流程
  29664. var res2 ResultSix
  29665. if miConfig.MdtrtareaAdmvs == "421300" {
  29666. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  29667. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29668. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29669. resp3, requestErr3 := http.Get(api3)
  29670. if requestErr3 != nil {
  29671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29672. return
  29673. }
  29674. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29675. if ioErr3 != nil {
  29676. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29678. return
  29679. }
  29680. var respJSON3 map[string]interface{}
  29681. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29682. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29684. return
  29685. }
  29686. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29687. userJSONBytes3, _ := json.Marshal(respJSON3)
  29688. fmt.Println("log")
  29689. fmt.Println(string(userJSONBytes3))
  29690. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29691. utils.ErrorLog("解析失败:%v", err)
  29692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29693. return
  29694. }
  29695. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29696. if err == nil {
  29697. c.ServeSuccessJSON(map[string]interface{}{
  29698. "msg": "撤销明细成功",
  29699. })
  29700. return
  29701. } else {
  29702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29703. return
  29704. }
  29705. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29706. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  29707. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29708. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29709. resp3, requestErr3 := http.Get(api3)
  29710. if requestErr3 != nil {
  29711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29712. return
  29713. }
  29714. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29715. if ioErr3 != nil {
  29716. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29718. return
  29719. }
  29720. var respJSON3 map[string]interface{}
  29721. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29722. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29724. return
  29725. }
  29726. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29727. userJSONBytes3, _ := json.Marshal(respJSON3)
  29728. fmt.Println("log")
  29729. fmt.Println(string(userJSONBytes3))
  29730. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29731. utils.ErrorLog("解析失败:%v", err)
  29732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29733. return
  29734. }
  29735. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29736. if err == nil {
  29737. c.ServeSuccessJSON(map[string]interface{}{
  29738. "msg": "撤销明细成功",
  29739. })
  29740. return
  29741. } else {
  29742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29743. return
  29744. }
  29745. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29746. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  29747. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29748. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29749. resp3, requestErr3 := http.Get(api3)
  29750. if requestErr3 != nil {
  29751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29752. return
  29753. }
  29754. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29755. if ioErr3 != nil {
  29756. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29758. return
  29759. }
  29760. var respJSON3 map[string]interface{}
  29761. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29764. return
  29765. }
  29766. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29767. userJSONBytes3, _ := json.Marshal(respJSON3)
  29768. fmt.Println("log")
  29769. fmt.Println(string(userJSONBytes3))
  29770. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29771. utils.ErrorLog("解析失败:%v", err)
  29772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29773. return
  29774. }
  29775. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29776. if err == nil {
  29777. c.ServeSuccessJSON(map[string]interface{}{
  29778. "msg": "撤销明细成功",
  29779. })
  29780. return
  29781. } else {
  29782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29783. return
  29784. }
  29785. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29786. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  29787. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29788. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29789. resp3, requestErr3 := http.Get(api3)
  29790. if requestErr3 != nil {
  29791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29792. return
  29793. }
  29794. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29795. if ioErr3 != nil {
  29796. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29798. return
  29799. }
  29800. var respJSON3 map[string]interface{}
  29801. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29802. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29804. return
  29805. }
  29806. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29807. userJSONBytes3, _ := json.Marshal(respJSON3)
  29808. fmt.Println("log")
  29809. fmt.Println(string(userJSONBytes3))
  29810. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29811. utils.ErrorLog("解析失败:%v", err)
  29812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29813. return
  29814. }
  29815. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29816. if err == nil {
  29817. c.ServeSuccessJSON(map[string]interface{}{
  29818. "msg": "撤销明细成功",
  29819. })
  29820. return
  29821. } else {
  29822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29823. return
  29824. }
  29825. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29826. var resSix10265 ResultSix10265
  29827. var api3 string
  29828. if miConfig.MdtrtareaAdmvs == "320921" {
  29829. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  29830. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29831. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29832. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29833. } else {
  29834. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29835. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  29836. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29837. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29838. }
  29839. resp3, requestErr3 := http.Get(api3)
  29840. utils.ErrorLog("接口: %v", requestErr3)
  29841. if requestErr3 != nil {
  29842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29843. return
  29844. }
  29845. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29846. if ioErr3 != nil {
  29847. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29849. return
  29850. }
  29851. var respJSON3 map[string]interface{}
  29852. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29853. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29855. return
  29856. }
  29857. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29858. userJSONBytes3, _ := json.Marshal(respJSON3)
  29859. fmt.Println("log")
  29860. fmt.Println(string(userJSONBytes3))
  29861. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  29862. utils.ErrorLog("解析失败:%v", err)
  29863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29864. return
  29865. }
  29866. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29867. res2.Output = resSix10265.Output
  29868. res2.ErrMsg = resSix10265.ErrMsg
  29869. res2.Cainfo = resSix10265.Cainfo
  29870. res2.WarnMsg = resSix10265.WarnMsg
  29871. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29872. res2.Infcode = infocode
  29873. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29874. if err == nil {
  29875. c.ServeSuccessJSON(map[string]interface{}{
  29876. "msg": "撤销明细成功",
  29877. })
  29878. return
  29879. } else {
  29880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29881. return
  29882. }
  29883. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29884. var api3 string
  29885. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  29886. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29887. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29888. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29889. resp3, requestErr3 := http.Get(api3)
  29890. utils.ErrorLog("接口: %v", requestErr3)
  29891. if requestErr3 != nil {
  29892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29893. return
  29894. }
  29895. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29896. if ioErr3 != nil {
  29897. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29899. return
  29900. }
  29901. var respJSON3 map[string]interface{}
  29902. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29903. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29905. return
  29906. }
  29907. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  29908. if status == "0" {
  29909. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  29910. c.ServeSuccessJSON(map[string]interface{}{
  29911. "failed_code": -10,
  29912. "msg": err_msg,
  29913. })
  29914. return
  29915. }
  29916. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29917. userJSONBytes3, _ := json.Marshal(respJSON3)
  29918. fmt.Println("log")
  29919. fmt.Println(string(userJSONBytes3))
  29920. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29921. utils.ErrorLog("解析失败:%v", err)
  29922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29923. return
  29924. }
  29925. fmt.Println(res2.Infcode)
  29926. if res2.Infcode == -1 {
  29927. c.ServeSuccessJSON(map[string]interface{}{
  29928. "failed_code": -10,
  29929. "msg": res2.ErrMsg,
  29930. })
  29931. return
  29932. }
  29933. if res2.Infcode == 0 {
  29934. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29935. if err == nil {
  29936. c.ServeSuccessJSON(map[string]interface{}{
  29937. "msg": "撤销明细成功",
  29938. })
  29939. return
  29940. } else {
  29941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29942. return
  29943. }
  29944. } else {
  29945. c.ServeSuccessJSON(map[string]interface{}{
  29946. "failed_code": -10,
  29947. "msg": res2.ErrMsg,
  29948. })
  29949. }
  29950. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29951. if err == nil {
  29952. c.ServeSuccessJSON(map[string]interface{}{
  29953. "msg": "撤销明细成功",
  29954. })
  29955. return
  29956. } else {
  29957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29958. return
  29959. }
  29960. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29961. var resSix10265 ResultSix10265
  29962. new_chrg_bchno := order.Number
  29963. if adminUser.CurrentOrgId == 10265 {
  29964. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  29965. new_chrg_bchno = "0000"
  29966. }
  29967. }
  29968. var api3 string
  29969. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  29970. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29971. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29972. resp3, requestErr3 := http.Get(api3)
  29973. if requestErr3 != nil {
  29974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29975. return
  29976. }
  29977. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29978. if ioErr3 != nil {
  29979. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29981. return
  29982. }
  29983. var respJSON3 map[string]interface{}
  29984. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29985. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29987. return
  29988. }
  29989. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29990. userJSONBytes3, _ := json.Marshal(respJSON3)
  29991. fmt.Println("log")
  29992. fmt.Println(string(userJSONBytes3))
  29993. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  29994. utils.ErrorLog("解析失败:%v", err)
  29995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29996. return
  29997. }
  29998. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29999. res2.Output = resSix10265.Output
  30000. res2.ErrMsg = resSix10265.ErrMsg
  30001. res2.Cainfo = resSix10265.Cainfo
  30002. res2.WarnMsg = resSix10265.WarnMsg
  30003. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30004. res2.Infcode = infocode
  30005. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  30006. if err == nil {
  30007. c.ServeSuccessJSON(map[string]interface{}{
  30008. "msg": "撤销明细成功",
  30009. })
  30010. return
  30011. } else {
  30012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30013. return
  30014. }
  30015. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30016. 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)
  30017. var dat map[string]interface{}
  30018. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  30019. fmt.Println(dat)
  30020. } else {
  30021. fmt.Println(err)
  30022. }
  30023. saveLog(result2, src_request, "2205", "撤销明细")
  30024. userJSONBytes, _ := json.Marshal(dat)
  30025. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30026. utils.ErrorLog("解析失败:%v", err)
  30027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30028. return
  30029. }
  30030. if res2.Infcode == 0 {
  30031. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  30032. if err == nil {
  30033. c.ServeSuccessJSON(map[string]interface{}{
  30034. "msg": "撤销明细成功",
  30035. })
  30036. return
  30037. } else {
  30038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30039. return
  30040. }
  30041. } else {
  30042. c.ServeSuccessJSON(map[string]interface{}{
  30043. "failed_code": -10,
  30044. "msg": res2.ErrMsg,
  30045. })
  30046. }
  30047. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30048. 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, "")
  30049. var dat map[string]interface{}
  30050. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  30051. fmt.Println(dat)
  30052. } else {
  30053. fmt.Println(err)
  30054. }
  30055. saveLog(result2, src_request, "2205", "撤销明细")
  30056. userJSONBytes, _ := json.Marshal(dat)
  30057. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30058. utils.ErrorLog("解析失败:%v", err)
  30059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30060. return
  30061. }
  30062. if res2.Infcode == 0 {
  30063. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  30064. if err == nil {
  30065. c.ServeSuccessJSON(map[string]interface{}{
  30066. "msg": "撤销明细成功",
  30067. })
  30068. return
  30069. } else {
  30070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30071. return
  30072. }
  30073. } else {
  30074. c.ServeSuccessJSON(map[string]interface{}{
  30075. "failed_code": -10,
  30076. "msg": res2.ErrMsg,
  30077. })
  30078. }
  30079. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30080. 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, "")
  30081. var dat map[string]interface{}
  30082. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  30083. fmt.Println(dat)
  30084. } else {
  30085. fmt.Println(err)
  30086. }
  30087. saveLog(result2, src_request, "2205", "撤销明细")
  30088. userJSONBytes, _ := json.Marshal(dat)
  30089. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30090. utils.ErrorLog("解析失败:%v", err)
  30091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30092. return
  30093. }
  30094. if res2.Infcode == 0 {
  30095. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  30096. if err == nil {
  30097. c.ServeSuccessJSON(map[string]interface{}{
  30098. "msg": "撤销明细成功",
  30099. })
  30100. return
  30101. } else {
  30102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30103. return
  30104. }
  30105. } else {
  30106. c.ServeSuccessJSON(map[string]interface{}{
  30107. "failed_code": -10,
  30108. "msg": res2.ErrMsg,
  30109. })
  30110. }
  30111. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30112. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  30113. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30114. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  30115. resp2, requestErr2 := http.Get(api2)
  30116. if requestErr2 != nil {
  30117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30118. return
  30119. }
  30120. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  30121. if ioErr2 != nil {
  30122. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  30123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30124. return
  30125. }
  30126. var respJSON2 map[string]interface{}
  30127. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  30128. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30130. return
  30131. }
  30132. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30133. userJSONBytes3, _ := json.Marshal(respJSON2)
  30134. fmt.Println("log")
  30135. fmt.Println(string(userJSONBytes3))
  30136. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  30137. utils.ErrorLog("解析失败:%v", err)
  30138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30139. return
  30140. }
  30141. if res2.Infcode == 0 {
  30142. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  30143. if err == nil {
  30144. c.ServeSuccessJSON(map[string]interface{}{
  30145. "msg": "撤销明细成功",
  30146. })
  30147. return
  30148. } else {
  30149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30150. return
  30151. }
  30152. } else {
  30153. c.ServeSuccessJSON(map[string]interface{}{
  30154. "failed_code": -10,
  30155. "msg": res2.ErrMsg,
  30156. })
  30157. }
  30158. } else {
  30159. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  30160. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  30161. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  30162. resp2, requestErr2 := http.Get(api2)
  30163. if requestErr2 != nil {
  30164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30165. return
  30166. }
  30167. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  30168. if ioErr2 != nil {
  30169. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  30170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30171. return
  30172. }
  30173. var respJSON2 map[string]interface{}
  30174. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  30175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30177. return
  30178. }
  30179. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30180. userJSONBytes3, _ := json.Marshal(respJSON2)
  30181. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  30182. utils.ErrorLog("解析失败:%v", err)
  30183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30184. return
  30185. }
  30186. if res2.Infcode == -1 {
  30187. c.ServeSuccessJSON(map[string]interface{}{
  30188. "failed_code": -10,
  30189. "msg": res2.ErrMsg,
  30190. })
  30191. return
  30192. } else {
  30193. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  30194. if err == nil {
  30195. c.ServeSuccessJSON(map[string]interface{}{
  30196. "msg": "撤销明细成功",
  30197. })
  30198. return
  30199. } else {
  30200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30201. return
  30202. }
  30203. }
  30204. }
  30205. } else {
  30206. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  30207. if err == nil {
  30208. c.ServeSuccessJSON(map[string]interface{}{
  30209. "msg": "退费成功",
  30210. })
  30211. } else {
  30212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30213. return
  30214. }
  30215. }
  30216. }
  30217. // 对账
  30218. func (c *HisApiController) GetCheckAccount() {
  30219. start_time := c.GetString("start_time")
  30220. end_time := c.GetString("end_time")
  30221. insutype := c.GetString("insutype")
  30222. clr_type := c.GetString("clr_type")
  30223. clr_org := c.GetString("clr_optins")
  30224. admin_user_id, _ := c.GetInt64("admin_user_id")
  30225. adminUser := c.GetAdminUserInfo()
  30226. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30227. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30228. if len(clr_org) == 0 {
  30229. clr_org = miConfig.InsuplcAdmdvs
  30230. }
  30231. timeLayout := "2006-01-02"
  30232. loc, _ := time.LoadLocation("Local")
  30233. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  30234. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  30235. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  30236. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  30237. fixmedins_setl_cnt := int64(len(orders))
  30238. var medfee_sumamt float64
  30239. var acct_pay float64
  30240. var fund_pay_sumamt float64
  30241. for _, item := range orders {
  30242. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30243. acct_pay = acct_pay + item.AcctPay
  30244. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  30245. }
  30246. var user_name string
  30247. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30248. if role.ID == 0 {
  30249. user_name = "xxx"
  30250. } else {
  30251. user_name = role.UserName
  30252. }
  30253. var res ResultEight
  30254. var res10188 ResultEightFor10188
  30255. if config.IsOpen == 1 {
  30256. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  30257. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  30258. "insutype=" + insutype +
  30259. "&clr_type=" + clr_type +
  30260. "&setl_optins=" + clr_org +
  30261. "&stmt_begndate=" + start_time +
  30262. "&stm_enddate=" + end_time +
  30263. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  30264. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  30265. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  30266. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  30267. "&fixmedins_code=" + miConfig.Code +
  30268. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30269. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30270. "&secret_key=" + miConfig.SecretKey +
  30271. "&org_name=" + miConfig.OrgName +
  30272. "&doctor=" + user_name +
  30273. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30274. fmt.Println(api)
  30275. resp, requestErr := http.Get(api)
  30276. if requestErr != nil {
  30277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30278. return
  30279. }
  30280. body, ioErr := ioutil.ReadAll(resp.Body)
  30281. fmt.Println(body)
  30282. if ioErr != nil {
  30283. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30285. return
  30286. }
  30287. var respJSON map[string]interface{}
  30288. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30289. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30291. return
  30292. }
  30293. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30294. userJSONBytes, _ := json.Marshal(respJSON)
  30295. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30296. utils.ErrorLog("解析失败:%v", err)
  30297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30298. return
  30299. }
  30300. res.InfRefmsgid = res10188.InfRefmsgid
  30301. res.Output = res10188.Output
  30302. res.ErrMsg = res10188.ErrMsg
  30303. res.Cainfo = res10188.Cainfo
  30304. res.WarnMsg = res10188.WarnMsg
  30305. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  30306. res.Infcode = infocode
  30307. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30308. if clr_type != "9903" {
  30309. clr_type = "99" // 就诊 ID(来自2201接口返回)
  30310. }
  30311. if clr_type == "9903" {
  30312. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  30313. }
  30314. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  30315. "insutype=" + insutype +
  30316. "&clr_type=" + clr_type +
  30317. "&setl_optins=" + clr_org +
  30318. "&stmt_begndate=" + start_time +
  30319. "&stm_enddate=" + end_time +
  30320. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  30321. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  30322. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  30323. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  30324. "&fixmedins_code=" + miConfig.Code +
  30325. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30326. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30327. "&secret_key=" + miConfig.SecretKey +
  30328. "&org_name=" + miConfig.OrgName +
  30329. "&doctor=" + user_name
  30330. resp, requestErr := http.Get(api)
  30331. if requestErr != nil {
  30332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30333. return
  30334. }
  30335. body, ioErr := ioutil.ReadAll(resp.Body)
  30336. if ioErr != nil {
  30337. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30339. return
  30340. }
  30341. var respJSON map[string]interface{}
  30342. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30343. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30345. return
  30346. }
  30347. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30348. result, _ := json.Marshal(respJSON)
  30349. fmt.Println("log")
  30350. fmt.Println(string(result))
  30351. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  30352. utils.ErrorLog("解析失败:%v", err)
  30353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30354. return
  30355. }
  30356. res.InfRefmsgid = res10188.InfRefmsgid
  30357. res.Output = res10188.Output
  30358. res.ErrMsg = res10188.ErrMsg
  30359. res.Cainfo = res10188.Cainfo
  30360. res.WarnMsg = res10188.WarnMsg
  30361. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  30362. res.Infcode = infocode
  30363. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30364. var baseParams models.BaseParams
  30365. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  30366. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  30367. baseParams.SecretKey = miConfig.SecretKey
  30368. baseParams.OrgName = miConfig.OrgName
  30369. baseParams.FixmedinsCode = miConfig.Code
  30370. baseParams.EncKey = miConfig.EncKey
  30371. baseParams.AppSecret = miConfig.AppSecret
  30372. baseParams.SignKey = miConfig.SignKey
  30373. baseParams.AppID = miConfig.Code
  30374. baseParams.Doctor = role.UserName
  30375. baseParams.RequestUrl = miConfig.Url
  30376. businessParams := models.BusinessParams{
  30377. Insutype: insutype,
  30378. ClrType: clr_type,
  30379. SetlOptins: clr_org,
  30380. StmtBegndate: start_time,
  30381. StmtEnddate: end_time,
  30382. MedfeeSumamt: medfee_sumamt,
  30383. FundPaySumamt: fund_pay_sumamt,
  30384. AcctPay: acct_pay,
  30385. FixmedinsSetlCnt: fixmedins_setl_cnt,
  30386. }
  30387. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  30388. fmt.Println(requestLog)
  30389. fmt.Println(result)
  30390. fmt.Println(err_msg)
  30391. var dat map[string]interface{}
  30392. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30393. fmt.Println(dat)
  30394. } else {
  30395. fmt.Println(err)
  30396. }
  30397. userJSONBytes, _ := json.Marshal(dat)
  30398. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30399. utils.ErrorLog("解析失败:%v", err)
  30400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30401. return
  30402. }
  30403. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30404. var baseParams models.BaseParams
  30405. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  30406. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  30407. baseParams.SecretKey = miConfig.SecretKey
  30408. baseParams.OrgName = miConfig.OrgName
  30409. baseParams.FixmedinsCode = miConfig.Code
  30410. baseParams.EncKey = miConfig.EncKey
  30411. baseParams.AppSecret = miConfig.AppSecret
  30412. baseParams.SignKey = miConfig.SignKey
  30413. baseParams.AppID = miConfig.Code
  30414. baseParams.Doctor = role.UserName
  30415. baseParams.RequestUrl = miConfig.Url
  30416. baseParams.AccessKey = miConfig.AccessKey
  30417. businessParams := models.BusinessParams{
  30418. Insutype: insutype,
  30419. ClrType: clr_type,
  30420. SetlOptins: "430822",
  30421. StmtBegndate: start_time,
  30422. StmtEnddate: end_time,
  30423. MedfeeSumamt: medfee_sumamt,
  30424. FundPaySumamt: fund_pay_sumamt,
  30425. AcctPay: acct_pay,
  30426. FixmedinsSetlCnt: fixmedins_setl_cnt,
  30427. }
  30428. 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)
  30429. fmt.Println(requestLog)
  30430. fmt.Println(result)
  30431. var dat map[string]interface{}
  30432. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30433. fmt.Println(dat)
  30434. } else {
  30435. fmt.Println(err)
  30436. }
  30437. userJSONBytes, _ := json.Marshal(dat)
  30438. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30439. utils.ErrorLog("解析失败:%v", err)
  30440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30441. return
  30442. }
  30443. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30444. var baseParams models.BaseParams
  30445. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  30446. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  30447. baseParams.SecretKey = miConfig.SecretKey
  30448. baseParams.OrgName = miConfig.OrgName
  30449. baseParams.FixmedinsCode = miConfig.Code
  30450. baseParams.EncKey = miConfig.EncKey
  30451. baseParams.AppSecret = miConfig.AppSecret
  30452. baseParams.SignKey = miConfig.SignKey
  30453. baseParams.AppID = miConfig.Code
  30454. baseParams.Doctor = role.UserName
  30455. baseParams.RequestUrl = miConfig.Url
  30456. businessParams := models.BusinessParams{
  30457. Insutype: insutype,
  30458. ClrType: clr_type,
  30459. SetlOptins: clr_org,
  30460. StmtBegndate: start_time,
  30461. StmtEnddate: end_time,
  30462. MedfeeSumamt: medfee_sumamt,
  30463. FundPaySumamt: fund_pay_sumamt,
  30464. AcctPay: acct_pay,
  30465. FixmedinsSetlCnt: fixmedins_setl_cnt,
  30466. }
  30467. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  30468. fmt.Println(requestLog)
  30469. fmt.Println(result)
  30470. fmt.Println(err_msg)
  30471. var dat map[string]interface{}
  30472. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30473. fmt.Println(dat)
  30474. } else {
  30475. fmt.Println(err)
  30476. }
  30477. userJSONBytes, _ := json.Marshal(dat)
  30478. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30479. utils.ErrorLog("解析失败:%v", err)
  30480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30481. return
  30482. }
  30483. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30484. if len(clr_type) == 0 {
  30485. clr_type = "11"
  30486. }
  30487. api := miConfig.Url + "gdyb/ten?" +
  30488. "insutype=" + insutype +
  30489. "&clr_type=" + clr_type +
  30490. "&setl_optins=" + clr_org +
  30491. "&stmt_begndate=" + start_time +
  30492. "&stm_enddate=" + end_time +
  30493. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  30494. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  30495. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  30496. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  30497. "&fixmedins_code=" + miConfig.Code +
  30498. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30499. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30500. "&secret_key=" + miConfig.SecretKey +
  30501. "&org_name=" + miConfig.OrgName +
  30502. "&doctor=" + user_name
  30503. fmt.Println(api)
  30504. resp, requestErr := http.Get(api)
  30505. if requestErr != nil {
  30506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30507. return
  30508. }
  30509. body, ioErr := ioutil.ReadAll(resp.Body)
  30510. fmt.Println(body)
  30511. if ioErr != nil {
  30512. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30514. return
  30515. }
  30516. var respJSON map[string]interface{}
  30517. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30518. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30520. return
  30521. }
  30522. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30523. userJSONBytes, _ := json.Marshal(respJSON)
  30524. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30525. utils.ErrorLog("解析失败:%v", err)
  30526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30527. return
  30528. }
  30529. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30530. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  30531. fixmedins_setl_cnt := int64(len(orders_two))
  30532. var medfee_sumamt float64
  30533. var acct_pay float64
  30534. var fund_pay_sumamt float64
  30535. for _, item := range orders_two {
  30536. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30537. acct_pay = acct_pay + item.AcctPay
  30538. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  30539. }
  30540. var baseParams models.BaseParams
  30541. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  30542. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  30543. baseParams.SecretKey = miConfig.SecretKey
  30544. baseParams.OrgName = miConfig.OrgName
  30545. baseParams.FixmedinsCode = miConfig.Code
  30546. baseParams.EncKey = miConfig.EncKey
  30547. baseParams.AppSecret = miConfig.AppSecret
  30548. baseParams.SignKey = miConfig.SignKey
  30549. baseParams.AppID = miConfig.Code
  30550. baseParams.Doctor = role.UserName
  30551. baseParams.RequestUrl = miConfig.Url
  30552. if clr_type == "9903" {
  30553. clr_type = "9994"
  30554. }
  30555. businessParams := models.BusinessParams{
  30556. Insutype: insutype,
  30557. ClrType: clr_type,
  30558. SetlOptins: "360302",
  30559. StmtBegndate: start_time,
  30560. StmtEnddate: end_time,
  30561. MedfeeSumamt: 0,
  30562. FundPaySumamt: 0,
  30563. AcctPay: 0,
  30564. FixmedinsSetlCnt: fixmedins_setl_cnt,
  30565. }
  30566. 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))
  30567. fmt.Println(requestLog)
  30568. fmt.Println(result)
  30569. var dat map[string]interface{}
  30570. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30571. fmt.Println(dat)
  30572. } else {
  30573. fmt.Println(err)
  30574. }
  30575. userJSONBytes, _ := json.Marshal(dat)
  30576. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30577. utils.ErrorLog("解析失败:%v", err)
  30578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30579. return
  30580. }
  30581. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30582. var api string
  30583. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  30584. "&clr_type=" + clr_type +
  30585. "&setl_optins=" + clr_org +
  30586. "&stmt_begndate=" + start_time +
  30587. "&stm_enddate=" + end_time +
  30588. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  30589. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  30590. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  30591. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  30592. "&fixmedins_code=" + miConfig.Code +
  30593. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30594. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30595. "&secret_key=" + miConfig.SecretKey +
  30596. "&org_name=" + miConfig.OrgName +
  30597. "&doctor=" + user_name + "&url=" + miConfig.Url
  30598. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30599. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30600. resp, requestErr := http.Get(api)
  30601. if requestErr != nil {
  30602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30603. return
  30604. }
  30605. body, ioErr := ioutil.ReadAll(resp.Body)
  30606. if ioErr != nil {
  30607. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30609. return
  30610. }
  30611. var respJSON map[string]interface{}
  30612. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30613. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30615. return
  30616. }
  30617. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30618. if status == "0" {
  30619. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30620. c.ServeSuccessJSON(map[string]interface{}{
  30621. "failed_code": -10,
  30622. "msg": err_msg,
  30623. })
  30624. return
  30625. }
  30626. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30627. userJSONBytes, _ := json.Marshal(respJSON)
  30628. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30629. utils.ErrorLog("解析失败:%v", err)
  30630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30631. return
  30632. }
  30633. } else {
  30634. if len(clr_type) == 0 {
  30635. clr_type = "11"
  30636. }
  30637. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  30638. "insutype=" + insutype +
  30639. "&clr_type=" + clr_type +
  30640. "&setl_optins=" + clr_org +
  30641. "&stmt_begndate=" + start_time +
  30642. "&stm_enddate=" + end_time +
  30643. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  30644. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  30645. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  30646. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  30647. "&fixmedins_code=" + miConfig.Code +
  30648. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30649. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30650. "&secret_key=" + miConfig.SecretKey +
  30651. "&org_name=" + miConfig.OrgName +
  30652. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  30653. fmt.Println(api)
  30654. resp, requestErr := http.Get(api)
  30655. if requestErr != nil {
  30656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30657. return
  30658. }
  30659. body, ioErr := ioutil.ReadAll(resp.Body)
  30660. fmt.Println(body)
  30661. if ioErr != nil {
  30662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30664. return
  30665. }
  30666. var respJSON map[string]interface{}
  30667. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30670. return
  30671. }
  30672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30673. userJSONBytes, _ := json.Marshal(respJSON)
  30674. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30675. utils.ErrorLog("解析失败:%v", err)
  30676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30677. return
  30678. }
  30679. }
  30680. if res.Infcode == 0 {
  30681. if res.Output.Stmtinfo.StmtRslt == "0" {
  30682. micc := &models.MedicalInsuranceCostCompare{
  30683. StartTime: startime.Unix(),
  30684. EndTime: endtime.Unix(),
  30685. Insutype: insutype,
  30686. CheckType: 1,
  30687. Num: fixmedins_setl_cnt,
  30688. Mtime: time.Now().Unix(),
  30689. Status: 1,
  30690. UserOrgId: adminUser.CurrentOrgId,
  30691. CostTotal: medfee_sumamt,
  30692. FuncTotal: fund_pay_sumamt,
  30693. PsnPay: acct_pay,
  30694. Creator: admin_user_id,
  30695. Ctime: time.Now().Unix(),
  30696. ClrType: clr_type,
  30697. }
  30698. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  30699. if err == nil {
  30700. c.ServeSuccessJSON(map[string]interface{}{
  30701. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  30702. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  30703. })
  30704. } else {
  30705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30706. }
  30707. } else {
  30708. c.ServeSuccessJSON(map[string]interface{}{
  30709. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  30710. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  30711. })
  30712. }
  30713. } else {
  30714. c.ServeSuccessJSON(map[string]interface{}{
  30715. "failed_code": -10,
  30716. "msg": res.ErrMsg,
  30717. })
  30718. }
  30719. }
  30720. }
  30721. func (c *HisApiController) Check310() {
  30722. adminUser := c.GetAdminUserInfo()
  30723. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30724. var user_name string
  30725. user_name = "高慧裕"
  30726. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  30727. "insutype=" + "310" +
  30728. "&clr_type=" + "" +
  30729. "&setl_optins=" + "441202" +
  30730. "&stmt_begndate=" + "2022-03-01" +
  30731. "&stm_enddate=" + "2022-03-31" +
  30732. "&medfee_sumamt=" + "194930.12" +
  30733. "&fund_pay_sumamt=" + "188741.46" +
  30734. "&acct_pay=" + "0" +
  30735. "&fixmedins_setl_cnt=" + "452" +
  30736. "&fixmedins_code=" + miConfig.Code +
  30737. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30738. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30739. "&secret_key=" + miConfig.SecretKey +
  30740. "&org_name=" + miConfig.OrgName +
  30741. "&doctor=" + user_name
  30742. fmt.Println(api)
  30743. resp, requestErr := http.Get(api)
  30744. if requestErr != nil {
  30745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30746. return
  30747. }
  30748. body, ioErr := ioutil.ReadAll(resp.Body)
  30749. fmt.Println(body)
  30750. if ioErr != nil {
  30751. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30753. return
  30754. }
  30755. var respJSON map[string]interface{}
  30756. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30757. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30759. return
  30760. }
  30761. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30762. userJSONBytes, _ := json.Marshal(respJSON)
  30763. var res ResultEight
  30764. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30765. utils.ErrorLog("解析失败:%v", err)
  30766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30767. return
  30768. }
  30769. }
  30770. func (c *HisApiController) Check390() {
  30771. adminUser := c.GetAdminUserInfo()
  30772. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30773. var user_name string
  30774. user_name = "高慧裕"
  30775. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  30776. "insutype=" + "390" +
  30777. "&clr_type=" + "" +
  30778. "&setl_optins=" + "441202" +
  30779. "&stmt_begndate=" + "2022-03-01" +
  30780. "&stm_enddate=" + "2022-03-31" +
  30781. "&medfee_sumamt=" + "1068448.89" +
  30782. "&fund_pay_sumamt=" + "1014677.62" +
  30783. "&acct_pay=" + "0" +
  30784. "&fixmedins_setl_cnt=" + "1950" +
  30785. "&fixmedins_code=" + miConfig.Code +
  30786. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30787. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30788. "&secret_key=" + miConfig.SecretKey +
  30789. "&org_name=" + miConfig.OrgName +
  30790. "&doctor=" + user_name
  30791. fmt.Println(api)
  30792. resp, requestErr := http.Get(api)
  30793. if requestErr != nil {
  30794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30795. return
  30796. }
  30797. body, ioErr := ioutil.ReadAll(resp.Body)
  30798. fmt.Println(body)
  30799. if ioErr != nil {
  30800. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30802. return
  30803. }
  30804. var respJSON map[string]interface{}
  30805. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30806. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30808. return
  30809. }
  30810. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30811. userJSONBytes, _ := json.Marshal(respJSON)
  30812. var res ResultEight
  30813. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30814. utils.ErrorLog("解析失败:%v", err)
  30815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30816. return
  30817. }
  30818. }
  30819. // 对账明细
  30820. func (c *HisApiController) GetCheckDetailAccount() {
  30821. start_time := c.GetString("start_time")
  30822. end_time := c.GetString("end_time")
  30823. admin_user_id, _ := c.GetInt64("admin_user_id")
  30824. adminUser := c.GetAdminUserInfo()
  30825. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30826. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30827. timeLayout := "2006-01-02"
  30828. loc, _ := time.LoadLocation("Local")
  30829. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  30830. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  30831. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  30832. rand.Seed(time.Now().UnixNano())
  30833. num := rand.Intn(30000)
  30834. Mkdir(miConfig.OrgName)
  30835. file := strconv.FormatInt(int64(num), 10)
  30836. file_name := file + ".txt"
  30837. zip_name := file + ".zip"
  30838. zip_path := miConfig.OrgName + "/" + zip_name
  30839. file_path := miConfig.OrgName + "/" + file_name
  30840. decimal.DivisionPrecision = 2
  30841. var medfee_sumamt float64
  30842. var psn_cash_pay float64
  30843. var fund_pay_sumamt float64
  30844. fixmedins_setl_cnt := int64(len(orders))
  30845. for _, item := range orders {
  30846. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30847. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  30848. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  30849. }
  30850. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  30851. defer f.Close()
  30852. if err != nil {
  30853. fmt.Println(err.Error())
  30854. } else {
  30855. for _, item := range orders {
  30856. var refd_setl_flag string
  30857. if item.OrderStatus == 2 {
  30858. refd_setl_flag = "0"
  30859. var str string
  30860. str = item.SetlId + " " +
  30861. item.MdtrtId + " " +
  30862. item.PsnNo + " " +
  30863. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  30864. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  30865. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  30866. _, err = f.Write([]byte(str))
  30867. }
  30868. if item.OrderStatus == 3 {
  30869. var str string
  30870. str = item.SetlId + " " +
  30871. item.MdtrtId + " " +
  30872. item.PsnNo + " " +
  30873. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  30874. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  30875. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  30876. _, err = f.Write([]byte(str))
  30877. var str2 string
  30878. str2 = item.SetlId + " " +
  30879. item.MdtrtId + " " +
  30880. item.PsnNo + " " +
  30881. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  30882. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  30883. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  30884. _, err = f.Write([]byte(str2))
  30885. }
  30886. }
  30887. }
  30888. Zip(file_path, zip_path)
  30889. fmt.Println(ReadFile(zip_path))
  30890. fmt.Println(string(ReadFile(zip_path)))
  30891. if config.IsOpen == 1 {
  30892. var user_name string
  30893. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30894. if role.ID == 0 {
  30895. user_name = "管理员"
  30896. } else {
  30897. user_name = role.UserName
  30898. }
  30899. baseParams := models.BaseParams{
  30900. SecretKey: miConfig.SecretKey,
  30901. FixmedinsCode: miConfig.Code,
  30902. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  30903. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  30904. OrgName: miConfig.OrgName,
  30905. Doctor: user_name,
  30906. }
  30907. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  30908. var dat map[string]interface{}
  30909. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30910. fmt.Println(dat)
  30911. } else {
  30912. fmt.Println(err)
  30913. }
  30914. userJSONBytes, _ := json.Marshal(dat)
  30915. var res ResultNine
  30916. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30917. utils.ErrorLog("解析失败:%v", err)
  30918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30919. return
  30920. }
  30921. if res.Infcode == 0 {
  30922. fileNo := res.Output.FileQuryNo
  30923. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  30924. "file_qury_no=" + fileNo +
  30925. "&setl_optins=" + "定点医保中心" +
  30926. "&stmt_begndate=" + start_time +
  30927. "&stm_enddate=" + end_time +
  30928. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  30929. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  30930. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  30931. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  30932. "&fixmedins_code=" + miConfig.Code +
  30933. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30934. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30935. "&secret_key=" + miConfig.SecretKey +
  30936. "&org_name=" + miConfig.OrgName +
  30937. "&doctor=" + user_name
  30938. resp, requestErr := http.Get(api)
  30939. if requestErr != nil {
  30940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30941. return
  30942. }
  30943. body, ioErr := ioutil.ReadAll(resp.Body)
  30944. if ioErr != nil {
  30945. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30947. return
  30948. }
  30949. var respJSON map[string]interface{}
  30950. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30953. return
  30954. }
  30955. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30956. userJSONBytes, _ := json.Marshal(respJSON)
  30957. var res ResultTen
  30958. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30959. utils.ErrorLog("解析失败:%v", err)
  30960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30961. return
  30962. }
  30963. if res.Infcode == 0 {
  30964. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  30965. micc := &models.MedicalInsuranceCostCompare{
  30966. StartTime: startime.Unix(),
  30967. EndTime: endtime.Unix(),
  30968. Insutype: "0",
  30969. CheckType: 2,
  30970. Num: fixmedins_setl_cnt,
  30971. Mtime: time.Now().Unix(),
  30972. Status: 1,
  30973. UserOrgId: adminUser.CurrentOrgId,
  30974. CostTotal: medfee_sumamt,
  30975. FuncTotal: fund_pay_sumamt,
  30976. PsnPay: psn_cash_pay,
  30977. Creator: admin_user_id,
  30978. Ctime: time.Now().Unix(),
  30979. }
  30980. service.CreateMedicalInsuranceCostCompareRecord(micc)
  30981. c.ServeSuccessJSON(map[string]interface{}{
  30982. "msg": "明细对账成功",
  30983. })
  30984. }
  30985. } else {
  30986. }
  30987. }
  30988. }
  30989. type CustomOrderInfo struct {
  30990. Name string
  30991. Spec string
  30992. Unit string
  30993. Count float64
  30994. Price float64
  30995. Total float64
  30996. }
  30997. func (c *HisApiController) GetBatchSettleAccounts() {
  30998. admin_user_id, _ := c.GetInt64("admin_user_id")
  30999. order_ids := c.GetString("order_ids")
  31000. order_ids_arr := strings.Split(order_ids, ",")
  31001. data3 := []map[string]interface{}{}
  31002. for _, item := range order_ids_arr {
  31003. id, _ := strconv.ParseInt(item, 10, 64)
  31004. order_id := id
  31005. adminUser := c.GetAdminUserInfo()
  31006. order, _ := service.GetHisOrderByID(order_id)
  31007. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  31008. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  31009. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  31010. orderInfos = append(orderInfos, orderInfos_two...)
  31011. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  31012. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  31013. var diagnosis_ids []string
  31014. if his.ID > 0 {
  31015. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  31016. } else {
  31017. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  31018. }
  31019. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  31020. var dia_config []*models.HisXtDiagnoseConfig
  31021. var name string
  31022. for _, item := range diagnosis_ids {
  31023. id, _ := strconv.ParseInt(item, 10, 64)
  31024. diagnosisConfig, _ := service.FindDiagnoseById(id)
  31025. dia_config = append(dia_config, &diagnosisConfig)
  31026. if len(name) == 0 {
  31027. name = diagnosisConfig.ClassName
  31028. }
  31029. //} else {
  31030. // name = name + "," + diagnosisConfig.ClassName
  31031. //}
  31032. }
  31033. var bedCostTotal float64 = 0 //床位总费
  31034. var bedCostSelfTotal float64 = 0 //床位自费
  31035. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  31036. var bedSelfTotal float64 = 0 //床位部分项目自费
  31037. var bedInscpTotal float64 = 0 //床位部分项目自费
  31038. var operationCostTotal float64 = 0 //手术费
  31039. var operationCostSelfTotal float64 = 0 //手术费
  31040. var operationCostPartSelfTotal float64 = 0 //手术费
  31041. var operationSelfTotal float64 = 0 //床位部分项目自费
  31042. var operationInscpTotal float64 = 0 //床位部分项目自费
  31043. var otherCostTotal float64 = 0 //其他费用
  31044. var otherCostSelfTotal float64 = 0 //其他费用
  31045. var otherCostPartSelfTotal float64 = 0 //其他费用
  31046. var otherSelfTotal float64 = 0 //床位部分项目自费
  31047. var otherInscpTotal float64 = 0 //床位部分项目自费
  31048. var materialCostTotal float64 = 0 //材料费
  31049. var materialCostSelfTotal float64 = 0 //材料费
  31050. var materialCostPartSelfTotal float64 = 0 //材料费
  31051. var materialSelfTotal float64 = 0 //床位部分项目自费
  31052. var materialInscpTotal float64 = 0 //床位部分项目自费
  31053. var westernMedicineCostTotal float64 = 0 //西药费
  31054. var westernMedicineCostSelfTotal float64 = 0 //西药费
  31055. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  31056. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  31057. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  31058. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  31059. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  31060. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  31061. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  31062. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  31063. var checkCostTotal float64 = 0 //检查费
  31064. var checkCostSelfTotal float64 = 0 //检查费
  31065. var checkCostPartSelfTotal float64 = 0 //检查费
  31066. var checkSelfTotal float64 = 0 //床位部分项目自费
  31067. var checkInscpTotal float64 = 0 //床位部分项目自费
  31068. var laboratoryCostTotal float64 = 0 //化验费
  31069. var laboratoryCostSelfTotal float64 = 0 //化验费
  31070. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  31071. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  31072. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  31073. var treatCostTotal float64 = 0 //治疗费用
  31074. var treatCostSelfTotal float64 = 0 //治疗费用
  31075. var treatCostPartSelfTotal float64 = 0 //治疗费用
  31076. var treatSelfTotal float64 = 0 //床位部分项目自费
  31077. var treatInscpTotal float64 = 0 //床位部分项目自费
  31078. decimal.DivisionPrecision = 2
  31079. for _, item := range orderInfos {
  31080. if item.MedChrgitmType == "01" { //床位费
  31081. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31082. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31083. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31084. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31085. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31086. }
  31087. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  31088. if item.MedChrgitmType == "03" { //检查费
  31089. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31090. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31091. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31092. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31093. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31094. }
  31095. } else {
  31096. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  31097. fmt.Println("------------")
  31098. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31099. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31100. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31101. }
  31102. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  31103. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31104. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31105. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31106. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31107. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31108. }
  31109. }
  31110. if item.MedChrgitmType == "04" { //化验费
  31111. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31112. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31113. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31114. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31115. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31116. }
  31117. if item.MedChrgitmType == "05" { //治疗费
  31118. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31119. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31120. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31121. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31122. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31123. }
  31124. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  31125. fmt.Println("------------")
  31126. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31127. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31128. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31129. }
  31130. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  31131. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31132. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31133. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31134. }
  31135. //if item.MedChrgitmType == "06" { //手术费
  31136. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31137. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31138. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31139. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31140. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31141. //
  31142. //}
  31143. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  31144. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31145. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31146. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31147. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31148. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31149. }
  31150. if item.MedChrgitmType == "09" { //西药费
  31151. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31152. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31153. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31154. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31155. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31156. }
  31157. if item.MedChrgitmType == "11" { //中成费
  31158. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31159. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31160. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31161. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31162. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31163. }
  31164. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  31165. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31166. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31167. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31168. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31169. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31170. }
  31171. }
  31172. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31173. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31174. var user_name string
  31175. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31176. if role.ID == 0 {
  31177. user_name = "管理员"
  31178. } else {
  31179. user_name = role.UserName
  31180. }
  31181. baseParams := models.BaseParams{
  31182. SecretKey: miConfig.SecretKey,
  31183. FixmedinsCode: miConfig.Code,
  31184. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  31185. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  31186. OrgName: miConfig.OrgName,
  31187. Doctor: user_name,
  31188. RequestUrl: miConfig.Url,
  31189. AccessKey: miConfig.AccessKey,
  31190. }
  31191. businessParams := models.BusinessParams{
  31192. PsnNo: order.PsnNo,
  31193. MdtrtId: order.MdtrtId,
  31194. SetlId: order.SetlId,
  31195. }
  31196. var res ResultEleven
  31197. var resEleven10265 ResultEleven10265
  31198. if config.IsOpen == 1 {
  31199. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  31200. result := service.Gdyb5203(baseParams, businessParams)
  31201. service.Gdyb5204(baseParams, businessParams)
  31202. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  31203. var dat map[string]interface{}
  31204. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31205. fmt.Println(dat)
  31206. } else {
  31207. fmt.Println(err)
  31208. }
  31209. userJSONBytes, _ := json.Marshal(dat)
  31210. if miConfig.Code == "H15049901371" {
  31211. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  31212. utils.ErrorLog("解析失败:%v", err)
  31213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31214. return
  31215. }
  31216. res.InfRefmsgid = resEleven10265.InfRefmsgid
  31217. res.Output = resEleven10265.Output
  31218. res.ErrMsg = resEleven10265.ErrMsg
  31219. res.Cainfo = resEleven10265.Cainfo
  31220. res.WarnMsg = resEleven10265.WarnMsg
  31221. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  31222. res.Infcode = infocode
  31223. } else {
  31224. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31225. utils.ErrorLog("解析失败:%v", err)
  31226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31227. return
  31228. }
  31229. }
  31230. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31231. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  31232. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  31233. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  31234. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  31235. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31236. var doctor_name string
  31237. if roles.ID == 0 {
  31238. doctor_name = "管理员"
  31239. } else {
  31240. doctor_name = roles.UserName
  31241. }
  31242. yiliao_leibie := ""
  31243. switch order.MedType {
  31244. case "11":
  31245. yiliao_leibie = "普通门诊"
  31246. break
  31247. case "12":
  31248. yiliao_leibie = "门诊挂号"
  31249. break
  31250. case "13":
  31251. yiliao_leibie = "急诊"
  31252. break
  31253. case "14":
  31254. yiliao_leibie = "门诊特殊病"
  31255. break
  31256. case "15":
  31257. yiliao_leibie = "门诊统筹"
  31258. break
  31259. case "16":
  31260. yiliao_leibie = "门诊慢性病"
  31261. break
  31262. case "21":
  31263. yiliao_leibie = "普通住院"
  31264. break
  31265. }
  31266. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  31267. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  31268. if res.Infcode == 0 {
  31269. data2 := map[string]interface{}{
  31270. "diagnosis": name,
  31271. "order_infos": orderInfos,
  31272. "number": order.MdtrtId,
  31273. "date": order.SettleAccountsDate,
  31274. "charge_admin": charge_admin,
  31275. "printor_admin": printor_admin,
  31276. "info": res.Output.Setlinfo,
  31277. "order": order,
  31278. "bedCostTotal": bedCostTotal,
  31279. "bedCostSelfTotal": bedCostSelfTotal,
  31280. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  31281. "bedSelfTotal": bedSelfTotal,
  31282. "bedInscpTotal": bedInscpTotal,
  31283. "operationCostTotal": operationCostTotal,
  31284. "operationCostSelfTotal": operationCostSelfTotal,
  31285. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  31286. "operationSelfTotal": operationSelfTotal,
  31287. "operationInscpTotal": operationInscpTotal,
  31288. "otherCostTotal": otherCostTotal,
  31289. "otherCostSelfTotal": otherCostSelfTotal,
  31290. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  31291. "otherSelfTotal": otherSelfTotal,
  31292. "otherInscpTotal": otherInscpTotal,
  31293. "materialCostTotal": materialCostTotal,
  31294. "materialCostSelfTotal": materialCostSelfTotal,
  31295. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  31296. "materialSelfTotal": materialSelfTotal,
  31297. "materialInscpTotal": materialInscpTotal,
  31298. "westernMedicineCostTotal": westernMedicineCostTotal,
  31299. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  31300. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  31301. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  31302. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  31303. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  31304. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  31305. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  31306. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  31307. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  31308. "checkCostTotal": checkCostTotal,
  31309. "checkCostSelfTotal": checkCostSelfTotal,
  31310. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  31311. "checkSelfTotal": checkSelfTotal,
  31312. "checkInscpTotal": checkInscpTotal,
  31313. "laboratoryCostTotal": laboratoryCostTotal,
  31314. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  31315. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  31316. "laboratorySelfTotal": laboratorySelfTotal,
  31317. "laboratoryInscpTotal": laboratoryInscpTotal,
  31318. "treatCostTotal": treatCostTotal,
  31319. "treatCostSelfTotal": treatCostSelfTotal,
  31320. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  31321. "treatSelfTotal": treatSelfTotal,
  31322. "treatInscpTotal": treatInscpTotal,
  31323. "doctor_info": doctor_info,
  31324. "doctor_code": adminRole_two.DoctorCode,
  31325. "doctor_name": doctor_name,
  31326. "health_card_no": order.PsnNo,
  31327. "department": departments.Name,
  31328. "yiliao_leibie": yiliao_leibie,
  31329. "after_money": order.AccountPrice,
  31330. "patient": patient,
  31331. "org_name": miConfig.OrgName,
  31332. "org_code": miConfig.Code,
  31333. "order_number": order.Number,
  31334. "his_hospital": his_hospital,
  31335. "his": his,
  31336. "dia_config": dia_config,
  31337. "psn_cash_pay": order.PsnCashPay,
  31338. //"check_order_info": cus_slice,
  31339. }
  31340. data3 = append(data3, data2)
  31341. }
  31342. }
  31343. }
  31344. c.ServeSuccessJSON(map[string]interface{}{
  31345. "infos": data3,
  31346. })
  31347. }
  31348. func (c *HisApiController) GetSettleAccounts() {
  31349. //id, _ := c.GetInt64("id")
  31350. //record_time := c.GetString("record_time")
  31351. order_id, _ := c.GetInt64("order_id")
  31352. admin_user_id, _ := c.GetInt64("admin_user_id")
  31353. //timeLayout := "2006-01-02"
  31354. //loc, _ := time.LoadLocation("Local")
  31355. //
  31356. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  31357. //if err != nil {
  31358. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  31359. // return
  31360. //}Hbyb5203
  31361. //recordDateTime := theTime.Unix()
  31362. adminUser := c.GetAdminUserInfo()
  31363. order, _ := service.GetHisOrderByID(order_id)
  31364. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  31365. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  31366. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  31367. orderInfos = append(orderInfos, orderInfos_two...)
  31368. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  31369. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  31370. var diagnosis_ids []string
  31371. if his.ID > 0 {
  31372. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  31373. } else {
  31374. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  31375. }
  31376. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  31377. var dia_config []*models.HisXtDiagnoseConfig
  31378. var name string
  31379. for _, item := range diagnosis_ids {
  31380. id, _ := strconv.ParseInt(item, 10, 64)
  31381. diagnosisConfig, _ := service.FindDiagnoseById(id)
  31382. dia_config = append(dia_config, &diagnosisConfig)
  31383. if len(name) == 0 {
  31384. name = diagnosisConfig.ClassName
  31385. } else {
  31386. name = name + "," + diagnosisConfig.ClassName
  31387. }
  31388. }
  31389. if patient.UserOrgId == 10215 {
  31390. name = "慢性肾功能不全(血透治疗)"
  31391. }
  31392. var bedCostTotal float64 = 0 //床位总费
  31393. var bedCostSelfTotal float64 = 0 //床位自费
  31394. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  31395. var bedSelfTotal float64 = 0 //床位部分项目自费
  31396. var bedInscpTotal float64 = 0 //床位部分项目自费
  31397. var operationCostTotal float64 = 0 //手术费
  31398. var operationCostSelfTotal float64 = 0 //手术费
  31399. var operationCostPartSelfTotal float64 = 0 //手术费
  31400. var operationSelfTotal float64 = 0 //床位部分项目自费
  31401. var operationInscpTotal float64 = 0 //床位部分项目自费
  31402. var otherCostTotal float64 = 0 //其他费用
  31403. var otherCostSelfTotal float64 = 0 //其他费用
  31404. var otherCostPartSelfTotal float64 = 0 //其他费用
  31405. var otherSelfTotal float64 = 0 //床位部分项目自费
  31406. var otherInscpTotal float64 = 0 //床位部分项目自费
  31407. var materialCostTotal float64 = 0 //材料费
  31408. var materialCostSelfTotal float64 = 0 //材料费
  31409. var materialCostPartSelfTotal float64 = 0 //材料费
  31410. var materialSelfTotal float64 = 0 //床位部分项目自费
  31411. var materialInscpTotal float64 = 0 //床位部分项目自费
  31412. var westernMedicineCostTotal float64 = 0 //西药费
  31413. var westernMedicineCostSelfTotal float64 = 0 //西药费
  31414. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  31415. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  31416. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  31417. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  31418. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  31419. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  31420. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  31421. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  31422. var checkCostTotal float64 = 0 //检查费
  31423. var checkCostSelfTotal float64 = 0 //检查费
  31424. var checkCostPartSelfTotal float64 = 0 //检查费
  31425. var checkSelfTotal float64 = 0 //床位部分项目自费
  31426. var checkInscpTotal float64 = 0 //床位部分项目自费
  31427. var laboratoryCostTotal float64 = 0 //化验费
  31428. var laboratoryCostSelfTotal float64 = 0 //化验费
  31429. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  31430. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  31431. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  31432. var treatCostTotal float64 = 0 //治疗费用
  31433. var treatCostSelfTotal float64 = 0 //治疗费用
  31434. var treatCostPartSelfTotal float64 = 0 //治疗费用
  31435. var treatSelfTotal float64 = 0 //床位部分项目自费
  31436. var treatInscpTotal float64 = 0 //床位部分项目自费
  31437. var zcCostTotal float64 = 0 //治疗费用
  31438. var zcCostSelfTotal float64 = 0 //治疗费用
  31439. var zcCostPartSelfTotal float64 = 0 //治疗费用
  31440. var zcSelfTotal float64 = 0 //床位部分项目自费
  31441. var zcInscpTotal float64 = 0 //床位部分项目自费
  31442. var huliCostTotal float64 = 0 //治疗费用
  31443. var huliCostSelfTotal float64 = 0 //治疗费用
  31444. var huliCostPartSelfTotal float64 = 0 //治疗费用
  31445. var huliSelfTotal float64 = 0 //床位部分项目自费
  31446. var huliInscpTotal float64 = 0 //床位部分项目自费
  31447. decimal.DivisionPrecision = 2
  31448. for _, item := range orderInfos {
  31449. if item.MedChrgitmType == "01" { //床位费
  31450. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31451. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31452. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31453. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31454. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31455. }
  31456. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  31457. if item.MedChrgitmType == "03" { //检查费
  31458. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31459. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31460. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31461. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31462. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31463. }
  31464. } else {
  31465. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  31466. fmt.Println("------------")
  31467. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31468. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31469. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31470. }
  31471. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  31472. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31473. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31474. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31475. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31476. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31477. }
  31478. }
  31479. if item.MedChrgitmType == "04" { //化验费
  31480. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31481. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31482. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31483. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31484. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31485. }
  31486. if item.MedChrgitmType == "05" { //治疗费
  31487. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31488. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31489. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31490. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31491. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31492. }
  31493. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  31494. fmt.Println("------------")
  31495. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31496. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31497. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31498. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31499. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31500. }
  31501. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  31502. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31503. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31504. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31505. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31506. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31507. }
  31508. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  31509. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31510. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31511. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31512. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31513. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31514. }
  31515. if item.MedChrgitmType == "09" { //西药费
  31516. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31517. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31518. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31519. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31520. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31521. }
  31522. if item.MedChrgitmType == "11" { //中成费
  31523. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31524. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31525. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31526. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31527. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31528. }
  31529. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  31530. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31531. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31532. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31533. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31534. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31535. }
  31536. if item.MedChrgitmType == "02" { //其他费
  31537. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31538. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31539. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31540. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31541. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31542. }
  31543. if item.MedChrgitmType == "07" { //其他费
  31544. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31545. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31546. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31547. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31548. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31549. }
  31550. }
  31551. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31552. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31553. var user_name string
  31554. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31555. if role.ID == 0 {
  31556. user_name = "管理员"
  31557. } else {
  31558. user_name = role.UserName
  31559. }
  31560. baseParams := models.BaseParams{
  31561. SecretKey: miConfig.SecretKey,
  31562. FixmedinsCode: miConfig.Code,
  31563. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  31564. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  31565. OrgName: miConfig.OrgName,
  31566. Doctor: user_name,
  31567. RequestUrl: miConfig.Url,
  31568. AccessKey: miConfig.AccessKey,
  31569. }
  31570. businessParams := models.BusinessParams{
  31571. PsnNo: order.PsnNo,
  31572. MdtrtId: order.MdtrtId,
  31573. SetlId: order.SetlId,
  31574. }
  31575. var res ResultEleven
  31576. var resah ResultElevenah
  31577. var resEleven10265 ResultEleven10265
  31578. if config.IsOpen == 1 {
  31579. if miConfig.MdtrtareaAdmvs == "421300" {
  31580. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31581. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31582. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31583. resp, requestErr := http.Get(api)
  31584. if requestErr != nil {
  31585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31586. return
  31587. }
  31588. body, ioErr := ioutil.ReadAll(resp.Body)
  31589. if ioErr != nil {
  31590. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31592. return
  31593. }
  31594. var respJSON map[string]interface{}
  31595. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31596. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31598. return
  31599. }
  31600. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31601. result, _ := json.Marshal(respJSON)
  31602. fmt.Println("log")
  31603. fmt.Println(string(result))
  31604. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31605. utils.ErrorLog("解析失败:%v", err)
  31606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31607. return
  31608. }
  31609. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31610. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31611. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31612. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31613. resp, requestErr := http.Get(api)
  31614. if requestErr != nil {
  31615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31616. return
  31617. }
  31618. body, ioErr := ioutil.ReadAll(resp.Body)
  31619. if ioErr != nil {
  31620. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31622. return
  31623. }
  31624. var respJSON map[string]interface{}
  31625. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31626. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31628. return
  31629. }
  31630. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31631. result, _ := json.Marshal(respJSON)
  31632. fmt.Println("log")
  31633. fmt.Println(string(result))
  31634. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31635. utils.ErrorLog("解析失败:%v", err)
  31636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31637. return
  31638. }
  31639. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31640. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31641. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31642. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31643. resp, requestErr := http.Get(api)
  31644. if requestErr != nil {
  31645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31646. return
  31647. }
  31648. body, ioErr := ioutil.ReadAll(resp.Body)
  31649. if ioErr != nil {
  31650. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31652. return
  31653. }
  31654. var respJSON map[string]interface{}
  31655. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31656. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31658. return
  31659. }
  31660. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31661. result, _ := json.Marshal(respJSON)
  31662. fmt.Println("log")
  31663. fmt.Println(string(result))
  31664. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31665. utils.ErrorLog("解析失败:%v", err)
  31666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31667. return
  31668. }
  31669. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31670. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31671. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31672. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  31673. resp, requestErr := http.Get(api)
  31674. if requestErr != nil {
  31675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31676. return
  31677. }
  31678. body, ioErr := ioutil.ReadAll(resp.Body)
  31679. if ioErr != nil {
  31680. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31682. return
  31683. }
  31684. var respJSON map[string]interface{}
  31685. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31686. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31688. return
  31689. }
  31690. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31691. result, _ := json.Marshal(respJSON)
  31692. fmt.Println("log")
  31693. fmt.Println(string(result))
  31694. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31695. utils.ErrorLog("解析失败:%v", err)
  31696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31697. return
  31698. }
  31699. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31700. var api string
  31701. if miConfig.MdtrtareaAdmvs == "320921" {
  31702. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31703. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31704. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31705. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31706. } else {
  31707. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31708. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31709. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31710. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31711. }
  31712. resp, requestErr := http.Get(api)
  31713. if requestErr != nil {
  31714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31715. return
  31716. }
  31717. body, ioErr := ioutil.ReadAll(resp.Body)
  31718. if ioErr != nil {
  31719. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31721. return
  31722. }
  31723. var respJSON map[string]interface{}
  31724. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31725. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31727. return
  31728. }
  31729. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31730. result, _ := json.Marshal(respJSON)
  31731. fmt.Println("log")
  31732. fmt.Println(string(result))
  31733. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  31734. utils.ErrorLog("解析失败:%v", err)
  31735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31736. return
  31737. }
  31738. res.InfRefmsgid = resEleven10265.InfRefmsgid
  31739. res.Output = resEleven10265.Output
  31740. res.ErrMsg = resEleven10265.ErrMsg
  31741. res.Cainfo = resEleven10265.Cainfo
  31742. res.WarnMsg = resEleven10265.WarnMsg
  31743. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  31744. res.Infcode = infocode
  31745. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31746. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  31747. saveLog(result, requestLog, "5203", "结算单")
  31748. var dat map[string]interface{}
  31749. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31750. fmt.Println(dat)
  31751. } else {
  31752. fmt.Println(err)
  31753. }
  31754. userJSONBytes, _ := json.Marshal(dat)
  31755. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31756. utils.ErrorLog("解析失败:%v", err)
  31757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31758. return
  31759. }
  31760. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31761. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  31762. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  31763. fmt.Println(result3)
  31764. fmt.Println(requestLog3)
  31765. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  31766. fmt.Println(result2)
  31767. fmt.Println(requestLog2)
  31768. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  31769. saveLog(result, requestLog, "5203", "结算单")
  31770. var dat map[string]interface{}
  31771. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31772. fmt.Println(dat)
  31773. } else {
  31774. fmt.Println(err)
  31775. }
  31776. userJSONBytes, _ := json.Marshal(dat)
  31777. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31778. utils.ErrorLog("解析失败:%v", err)
  31779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31780. return
  31781. }
  31782. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31783. var api string
  31784. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31785. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31786. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31787. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31788. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31789. resp, requestErr := http.Get(api)
  31790. if requestErr != nil {
  31791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31792. return
  31793. }
  31794. body, ioErr := ioutil.ReadAll(resp.Body)
  31795. if ioErr != nil {
  31796. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31798. return
  31799. }
  31800. var respJSON map[string]interface{}
  31801. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31802. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31804. return
  31805. }
  31806. status := respJSON["data"].(map[string]interface{})["status"].(string)
  31807. if status == "0" {
  31808. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  31809. c.ServeSuccessJSON(map[string]interface{}{
  31810. "failed_code": -10,
  31811. "msg": err_msg,
  31812. })
  31813. return
  31814. }
  31815. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31816. result, _ := json.Marshal(respJSON)
  31817. fmt.Println("log")
  31818. fmt.Println(string(result))
  31819. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  31820. utils.ErrorLog("解析失败:%v", err)
  31821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31822. return
  31823. }
  31824. res.InfRefmsgid = resah.InfRefmsgid
  31825. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31826. // 创建对应的Time类型
  31827. t := time.UnixMilli(timestamp)
  31828. // 格式化成指定的日期字符串
  31829. str := t.Format("2006-01-02 15:04:05")
  31830. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31831. // 创建对应的Time类型
  31832. t3 := time.UnixMilli(timestamp2)
  31833. // 格式化成指定的日期字符串
  31834. str2 := t3.Format("2006-01-02 15:04:05")
  31835. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  31836. // 创建对应的Time类型
  31837. t4 := time.UnixMilli(timestamp3)
  31838. // 格式化成指定的日期字符串
  31839. str3 := t4.Format("2006-01-02 15:04:05")
  31840. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  31841. // 创建对应的Time类型
  31842. t5 := time.UnixMilli(timestamp4)
  31843. // 格式化成指定的日期字符串
  31844. str5 := t5.Format("2006-01-02 15:04:05")
  31845. res.Output.Setlinfo.Brdy = str2
  31846. res.Output.Setlinfo.SetlTime = str
  31847. res.Output.Setlinfo.Begndate = str3
  31848. res.Output.Setlinfo.Enddate = str5
  31849. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  31850. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  31851. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  31852. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  31853. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  31854. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  31855. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  31856. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  31857. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  31858. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  31859. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  31860. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  31861. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31862. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  31863. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  31864. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  31865. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  31866. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  31867. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  31868. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  31869. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  31870. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  31871. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  31872. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  31873. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  31874. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31875. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  31876. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  31877. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  31878. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  31879. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31880. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  31881. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  31882. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  31883. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  31884. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  31885. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  31886. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  31887. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  31888. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  31889. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  31890. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  31891. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  31892. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  31893. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  31894. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31895. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  31896. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  31897. //res.Output.Setldetail = resah.Output.Setldetail
  31898. res.ErrMsg = resah.ErrMsg
  31899. res.Cainfo = resah.Cainfo
  31900. res.WarnMsg = resah.WarnMsg
  31901. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31902. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  31903. saveLog(result, requestLog, "5203", "结算单")
  31904. var dat map[string]interface{}
  31905. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31906. fmt.Println(dat)
  31907. } else {
  31908. fmt.Println(err)
  31909. }
  31910. userJSONBytes, _ := json.Marshal(dat)
  31911. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31912. utils.ErrorLog("解析失败:%v", err)
  31913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31914. return
  31915. }
  31916. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31917. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31918. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31919. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31920. resp, requestErr := http.Get(api)
  31921. if requestErr != nil {
  31922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31923. return
  31924. }
  31925. body, ioErr := ioutil.ReadAll(resp.Body)
  31926. if ioErr != nil {
  31927. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31929. return
  31930. }
  31931. var respJSON map[string]interface{}
  31932. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31933. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31935. return
  31936. }
  31937. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31938. result, _ := json.Marshal(respJSON)
  31939. fmt.Println("log")
  31940. fmt.Println(string(result))
  31941. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  31942. utils.ErrorLog("解析失败:%v", err)
  31943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31944. return
  31945. }
  31946. res.InfRefmsgid = resEleven10265.InfRefmsgid
  31947. res.Output = resEleven10265.Output
  31948. res.ErrMsg = resEleven10265.ErrMsg
  31949. res.Cainfo = resEleven10265.Cainfo
  31950. res.WarnMsg = resEleven10265.WarnMsg
  31951. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  31952. res.Infcode = infocode
  31953. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31954. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31955. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31956. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31957. resp, requestErr := http.Get(api)
  31958. if requestErr != nil {
  31959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31960. return
  31961. }
  31962. body, ioErr := ioutil.ReadAll(resp.Body)
  31963. if ioErr != nil {
  31964. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31966. return
  31967. }
  31968. var respJSON map[string]interface{}
  31969. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31970. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31972. return
  31973. }
  31974. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31975. result, _ := json.Marshal(respJSON)
  31976. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31977. utils.ErrorLog("解析失败:%v", err)
  31978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31979. return
  31980. }
  31981. } else if miConfig.MdtrtareaAdmvs == "450721" {
  31982. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  31983. //return
  31984. } else {
  31985. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  31986. if len(his.InsuplcAdmdvs) == 0 {
  31987. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  31988. } else {
  31989. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  31990. }
  31991. result := service.Gdyb5203(baseParams, businessParams)
  31992. //service.Gdyb5204(baseParams, businessParams)
  31993. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  31994. var dat map[string]interface{}
  31995. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31996. fmt.Println(dat)
  31997. } else {
  31998. fmt.Println(err)
  31999. }
  32000. userJSONBytes, _ := json.Marshal(dat)
  32001. if miConfig.Code == "H15049901371" {
  32002. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  32003. utils.ErrorLog("解析失败:%v", err)
  32004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32005. return
  32006. }
  32007. res.InfRefmsgid = resEleven10265.InfRefmsgid
  32008. res.Output = resEleven10265.Output
  32009. res.ErrMsg = resEleven10265.ErrMsg
  32010. res.Cainfo = resEleven10265.Cainfo
  32011. res.WarnMsg = resEleven10265.WarnMsg
  32012. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  32013. res.Infcode = infocode
  32014. } else {
  32015. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32016. utils.ErrorLog("解析失败:%v", err)
  32017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32018. return
  32019. }
  32020. }
  32021. }
  32022. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32023. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  32024. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  32025. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  32026. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  32027. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32028. var doctor_name string
  32029. if roles.ID == 0 {
  32030. doctor_name = "管理员"
  32031. } else {
  32032. doctor_name = roles.UserName
  32033. }
  32034. yiliao_leibie := ""
  32035. switch order.MedType {
  32036. case "11":
  32037. yiliao_leibie = "普通门诊"
  32038. break
  32039. case "12":
  32040. yiliao_leibie = "门诊挂号"
  32041. break
  32042. case "13":
  32043. yiliao_leibie = "急诊"
  32044. break
  32045. case "14":
  32046. yiliao_leibie = "门诊特殊病"
  32047. break
  32048. case "15":
  32049. yiliao_leibie = "门诊统筹"
  32050. break
  32051. case "16":
  32052. yiliao_leibie = "门诊慢性病"
  32053. break
  32054. case "21":
  32055. yiliao_leibie = "普通住院"
  32056. break
  32057. }
  32058. //var rf []CustomFundPay
  32059. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  32060. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  32061. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  32062. if res.Infcode == 0 {
  32063. 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 {
  32064. c.ServeSuccessJSON(map[string]interface{}{
  32065. "diagnosis": name,
  32066. "order_infos": orderInfos,
  32067. "number": order.MdtrtId,
  32068. "date": order.SettleAccountsDate,
  32069. "charge_admin": charge_admin,
  32070. "printor_admin": printor_admin,
  32071. "info": res.Output.Setlinfo,
  32072. "order": order,
  32073. "bedCostTotal": bedCostTotal,
  32074. "bedCostSelfTotal": bedCostSelfTotal,
  32075. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  32076. "bedSelfTotal": bedSelfTotal,
  32077. "bedInscpTotal": bedInscpTotal,
  32078. "operationCostTotal": operationCostTotal,
  32079. "operationCostSelfTotal": operationCostSelfTotal,
  32080. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  32081. "operationSelfTotal": operationSelfTotal,
  32082. "operationInscpTotal": operationInscpTotal,
  32083. "otherCostTotal": otherCostTotal,
  32084. "otherCostSelfTotal": otherCostSelfTotal,
  32085. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  32086. "otherSelfTotal": otherSelfTotal,
  32087. "otherInscpTotal": otherInscpTotal,
  32088. "materialCostTotal": materialCostTotal,
  32089. "materialCostSelfTotal": materialCostSelfTotal,
  32090. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  32091. "materialSelfTotal": materialSelfTotal,
  32092. "materialInscpTotal": materialInscpTotal,
  32093. "westernMedicineCostTotal": westernMedicineCostTotal,
  32094. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  32095. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  32096. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  32097. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  32098. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  32099. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  32100. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  32101. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  32102. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  32103. "checkCostTotal": checkCostTotal,
  32104. "checkCostSelfTotal": checkCostSelfTotal,
  32105. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  32106. "checkSelfTotal": checkSelfTotal,
  32107. "checkInscpTotal": checkInscpTotal,
  32108. "laboratoryCostTotal": laboratoryCostTotal,
  32109. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  32110. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  32111. "laboratorySelfTotal": laboratorySelfTotal,
  32112. "laboratoryInscpTotal": laboratoryInscpTotal,
  32113. "treatCostTotal": treatCostTotal,
  32114. "treatCostSelfTotal": treatCostSelfTotal,
  32115. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  32116. "treatSelfTotal": treatSelfTotal,
  32117. "treatInscpTotal": treatInscpTotal,
  32118. "doctor_info": doctor_info,
  32119. "doctor_code": adminRole_two.DoctorCode,
  32120. "doctor_name": doctor_name,
  32121. "health_card_no": order.PsnNo,
  32122. "department": departments.Name,
  32123. "yiliao_leibie": yiliao_leibie,
  32124. "after_money": order.AccountPrice,
  32125. "patient": patient,
  32126. "org_name": miConfig.OrgName,
  32127. "org_code": miConfig.Code,
  32128. "order_number": order.Number,
  32129. "his_hospital": his_hospital,
  32130. "his": his,
  32131. "dia_config": dia_config,
  32132. "psn_cash_pay": order.PsnCashPay,
  32133. "zcCostTotal": zcCostTotal,
  32134. "zcCostSelfTotal": zcCostSelfTotal,
  32135. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  32136. "zcSelfTotal": zcSelfTotal,
  32137. "zcInscpTotal": zcInscpTotal,
  32138. "huliCostTotal": huliCostTotal,
  32139. "huliCostSelfTotal": huliCostSelfTotal,
  32140. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  32141. "huliSelfTotal": huliSelfTotal,
  32142. "huliInscpTotal": huliInscpTotal,
  32143. //"funds": rf,
  32144. //"check_order_info": cus_slice,
  32145. })
  32146. } else {
  32147. c.ServeSuccessJSON(map[string]interface{}{
  32148. "diagnosis": name,
  32149. "order_infos": orderInfos,
  32150. "number": order.MdtrtId,
  32151. "date": order.SettleAccountsDate,
  32152. "charge_admin": charge_admin,
  32153. "printor_admin": printor_admin,
  32154. "info": order,
  32155. "order": order,
  32156. "bedCostTotal": bedCostTotal,
  32157. "bedCostSelfTotal": bedCostSelfTotal,
  32158. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  32159. "bedSelfTotal": bedSelfTotal,
  32160. "bedInscpTotal": bedInscpTotal,
  32161. "operationCostTotal": operationCostTotal,
  32162. "operationCostSelfTotal": operationCostSelfTotal,
  32163. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  32164. "operationSelfTotal": operationSelfTotal,
  32165. "operationInscpTotal": operationInscpTotal,
  32166. "otherCostTotal": otherCostTotal,
  32167. "otherCostSelfTotal": otherCostSelfTotal,
  32168. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  32169. "otherSelfTotal": otherSelfTotal,
  32170. "otherInscpTotal": otherInscpTotal,
  32171. "materialCostTotal": materialCostTotal,
  32172. "materialCostSelfTotal": materialCostSelfTotal,
  32173. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  32174. "materialSelfTotal": materialSelfTotal,
  32175. "materialInscpTotal": materialInscpTotal,
  32176. "westernMedicineCostTotal": westernMedicineCostTotal,
  32177. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  32178. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  32179. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  32180. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  32181. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  32182. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  32183. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  32184. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  32185. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  32186. "checkCostTotal": checkCostTotal,
  32187. "checkCostSelfTotal": checkCostSelfTotal,
  32188. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  32189. "checkSelfTotal": checkSelfTotal,
  32190. "checkInscpTotal": checkInscpTotal,
  32191. "laboratoryCostTotal": laboratoryCostTotal,
  32192. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  32193. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  32194. "laboratorySelfTotal": laboratorySelfTotal,
  32195. "laboratoryInscpTotal": laboratoryInscpTotal,
  32196. "treatCostTotal": treatCostTotal,
  32197. "treatCostSelfTotal": treatCostSelfTotal,
  32198. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  32199. "treatSelfTotal": treatSelfTotal,
  32200. "treatInscpTotal": treatInscpTotal,
  32201. "doctor_info": doctor_info,
  32202. "doctor_code": adminRole_two.DoctorCode,
  32203. "doctor_name": doctor_name,
  32204. "health_card_no": order.PsnNo,
  32205. "department": departments.Name,
  32206. "yiliao_leibie": yiliao_leibie,
  32207. "after_money": order.AccountPrice,
  32208. "patient": patient,
  32209. "org_name": miConfig.OrgName,
  32210. "org_code": miConfig.Code,
  32211. "order_number": order.Number,
  32212. "his_hospital": his_hospital,
  32213. "his": his,
  32214. "dia_config": dia_config,
  32215. "psn_cash_pay": order.PsnCashPay,
  32216. "zcCostTotal": zcCostTotal,
  32217. "zcCostSelfTotal": zcCostSelfTotal,
  32218. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  32219. "zcSelfTotal": zcSelfTotal,
  32220. "zcInscpTotal": zcInscpTotal,
  32221. "huliCostTotal": huliCostTotal,
  32222. "huliCostSelfTotal": huliCostSelfTotal,
  32223. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  32224. "huliSelfTotal": huliSelfTotal,
  32225. "huliInscpTotal": huliInscpTotal,
  32226. //"funds": rf,
  32227. //"check_order_info": cus_slice,
  32228. })
  32229. }
  32230. }
  32231. }
  32232. }
  32233. //func (c *HisApiController) CheckTreatment() {
  32234. // patient_id, _ := c.GetInt64("patient_id")
  32235. // id_card_no := c.GetString("id_card_no")
  32236. // insutype := c.GetString("insutype")
  32237. // med_type := c.GetString("med_type")
  32238. // admin_user_id, _ := c.GetInt64("admin_user_id")
  32239. //
  32240. // adminUser := c.GetAdminUserInfo()
  32241. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  32242. //
  32243. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32244. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32245. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32246. //
  32247. // if miConfig.MdtrtareaAdmvs == "421300" {
  32248. // var res ResultTwo
  32249. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  32250. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32251. // "&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)
  32252. // resp, requestErr := http.Get(api)
  32253. // if requestErr != nil {
  32254. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32255. // return
  32256. // }
  32257. //
  32258. // body, ioErr := ioutil.ReadAll(resp.Body)
  32259. // if ioErr != nil {
  32260. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32261. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32262. // return
  32263. // }
  32264. // var respJSON map[string]interface{}
  32265. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32266. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32267. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32268. // return
  32269. // }
  32270. //
  32271. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32272. // result, _ := json.Marshal(respJSON)
  32273. //
  32274. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  32275. // utils.ErrorLog("解析失败:%v", err)
  32276. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32277. // return
  32278. // }
  32279. //
  32280. // if res.Infcode == 0 {
  32281. //
  32282. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  32283. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32284. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  32285. // resp, requestErr := http.Get(api)
  32286. // if requestErr != nil {
  32287. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32288. // return
  32289. // }
  32290. //
  32291. // body, ioErr := ioutil.ReadAll(resp.Body)
  32292. // if ioErr != nil {
  32293. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32294. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32295. // return
  32296. // }
  32297. // var respJSON map[string]interface{}
  32298. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32299. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32300. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32301. // return
  32302. // }
  32303. // var res Result2001
  32304. //
  32305. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32306. // result2, _ := json.Marshal(respJSON)
  32307. //
  32308. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  32309. // utils.ErrorLog("解析失败:%v", err)
  32310. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32311. // return
  32312. // }
  32313. //
  32314. // if res.Infcode == 0 {
  32315. // c.ServeSuccessJSON(map[string]interface{}{
  32316. // "msg": res.Output.Trtinfo,
  32317. // })
  32318. // }
  32319. //
  32320. // } else {
  32321. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  32322. // return
  32323. // }
  32324. //
  32325. // } else {
  32326. //
  32327. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  32328. // var dat map[string]interface{}
  32329. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32330. // fmt.Println(dat)
  32331. // } else {
  32332. // fmt.Println(err)
  32333. // }
  32334. // userJSONBytes, _ := json.Marshal(dat)
  32335. // var res ResultTwo
  32336. // var res10265 ResultTwo10265
  32337. // if miConfig.Code == "H15049901371" {
  32338. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  32339. // utils.ErrorLog("解析失败:%v", err)
  32340. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32341. // return
  32342. // }
  32343. // res.ErrMsg = res10265.ErrMsg
  32344. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  32345. // res.Infcode = infocode
  32346. // res.Output = res10265.Output
  32347. // res.InfRefmsgid = res10265.InfRefmsgid
  32348. // } else {
  32349. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32350. // utils.ErrorLog("解析失败:%v", err)
  32351. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32352. // return
  32353. // }
  32354. // }
  32355. //
  32356. // var user_name string
  32357. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  32358. // if role.ID == 0 {
  32359. // user_name = "xxx"
  32360. // } else {
  32361. // user_name = role.UserName
  32362. // }
  32363. //
  32364. // baseParams := models.BaseParams{
  32365. // SecretKey: miConfig.SecretKey,
  32366. // FixmedinsCode: miConfig.Code,
  32367. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  32368. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  32369. // OrgName: miConfig.OrgName,
  32370. // Doctor: user_name,
  32371. // }
  32372. //
  32373. // if config.IsOpen == 1 {
  32374. // if miConfig.Code == "H15049901371" {
  32375. // if med_type == "14" {
  32376. // if insutype == "390" {
  32377. // med_type = "9933"
  32378. // } else if insutype == "310" {
  32379. // med_type = "990502"
  32380. // }
  32381. // } else if med_type == "11" {
  32382. // med_type = "11"
  32383. // }
  32384. // }
  32385. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  32386. // var dat map[string]interface{}
  32387. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32388. // fmt.Println(dat)
  32389. // } else {
  32390. // fmt.Println(err)
  32391. // }
  32392. // var res Result2001
  32393. // var res10265 Result2001Org10265
  32394. // if miConfig.Code == "H15049901371" {
  32395. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  32396. // utils.ErrorLog("解析失败:%v", err)
  32397. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32398. // return
  32399. // }
  32400. // res.ErrMsg = res10265.ErrMsg
  32401. // res.Output = res10265.Output
  32402. // res.InfRefmsgid = res10265.InfRefmsgid
  32403. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  32404. // res.Infcode = infocode
  32405. // } else {
  32406. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  32407. // utils.ErrorLog("解析失败:%v", err)
  32408. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32409. // return
  32410. // }
  32411. // }
  32412. // if res.Infcode == 0 {
  32413. // c.ServeSuccessJSON(map[string]interface{}{
  32414. // "msg": res.Output.Trtinfo,
  32415. // })
  32416. // }
  32417. // }
  32418. // }
  32419. //}
  32420. //func (c *HisApiController) PutRecord() {
  32421. // id, _ := c.GetInt64("id")
  32422. // record_time := c.GetString("record_time")
  32423. // timeLayout := "2006-01-02"
  32424. // loc, _ := time.LoadLocation("Local")
  32425. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32426. // if err != nil {
  32427. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32428. // return
  32429. // }
  32430. // recordDateTime := theTime.Unix()
  32431. //
  32432. // adminInfo := c.GetAdminUserInfo()
  32433. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  32434. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  32435. //
  32436. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  32437. //
  32438. // fmt.Println(miConfig.SecretKey)
  32439. //
  32440. // if patient == nil {
  32441. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  32442. // return
  32443. // }
  32444. // if len(patient.IdCardNo) == 0 {
  32445. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  32446. // return
  32447. // }
  32448. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  32449. // if config.IsOpen == 1 {
  32450. // 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
  32451. // resp, requestErr := http.Get(api)
  32452. // if requestErr != nil {
  32453. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32454. // return
  32455. // }
  32456. // defer resp.Body.Close()
  32457. // body, ioErr := ioutil.ReadAll(resp.Body)
  32458. // if ioErr != nil {
  32459. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32460. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32461. // return
  32462. // }
  32463. // var respJSON map[string]interface{}
  32464. //
  32465. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32466. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32467. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32468. // return
  32469. // }
  32470. //
  32471. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32472. // userJSONBytes, _ := json.Marshal(userJSON)
  32473. // var res ResultTwo
  32474. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32475. // utils.ErrorLog("解析失败:%v", err)
  32476. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32477. // return
  32478. // }
  32479. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  32480. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  32481. // infoStr := string(Iinfos)
  32482. // idetinfoStr := string(Idetinfos)
  32483. //
  32484. // if res.Infcode == 0 {
  32485. // his := models.VMHisPatient{
  32486. // Status: 1,
  32487. // Ctime: time.Now().Unix(),
  32488. // Mtime: time.Now().Unix(),
  32489. // PsnNo: res.Output.Baseinfo.PsnNo,
  32490. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  32491. // Certno: res.Output.Baseinfo.Certno,
  32492. // PsnName: res.Output.Baseinfo.PsnName,
  32493. // Gend: res.Output.Baseinfo.Gend,
  32494. // Naty: res.Output.Baseinfo.Naty,
  32495. // Brdy: res.Output.Baseinfo.Brdy,
  32496. // Age: res.Output.Baseinfo.Age,
  32497. // Iinfo: infoStr,
  32498. // Idetinfo: idetinfoStr,
  32499. // PatientId: patient.ID,
  32500. // RecordDate: theTime.Unix(),
  32501. // UserOrgId: adminInfo.CurrentOrgId,
  32502. // AdminUserId: adminInfo.AdminUser.Id,
  32503. // IsReturn: 1,
  32504. // }
  32505. //
  32506. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  32507. // //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")
  32508. // //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")
  32509. //
  32510. // //var dat map[string]interface{}
  32511. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32512. // // fmt.Println(dat)
  32513. // //} else {
  32514. // // fmt.Println(err)
  32515. // //}
  32516. //
  32517. // var dat2 map[string]interface{}
  32518. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  32519. // fmt.Println(dat2)
  32520. // } else {
  32521. // fmt.Println(err)
  32522. // }
  32523. //
  32524. // } else {
  32525. // adminUser := c.GetAdminUserInfo()
  32526. // errlog := &models.HisOrderError{
  32527. // UserOrgId: adminUser.CurrentOrgId,
  32528. // Ctime: time.Now().Unix(),
  32529. // Mtime: time.Now().Unix(),
  32530. // ErrMsg: res.ErrMsg,
  32531. // Status: 1,
  32532. // PatientId: id,
  32533. // RecordTime: recordDateTime,
  32534. // Stage: 1,
  32535. // }
  32536. // service.CreateErrMsgLog(errlog)
  32537. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  32538. // return
  32539. // }
  32540. // }
  32541. //
  32542. //}
  32543. //func (c *HisApiController) GetUploadDiag() {
  32544. // id, _ := c.GetInt64("id")
  32545. // record_time := c.GetString("record_time")
  32546. //
  32547. // diagnosis_id, _ := c.GetInt64("diagnosis")
  32548. // sick_type, _ := c.GetInt64("sick_type")
  32549. // reg_type, _ := c.GetInt64("reg_type")
  32550. //
  32551. // timeLayout := "2006-01-02"
  32552. // loc, _ := time.LoadLocation("Local")
  32553. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32554. // if err != nil {
  32555. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32556. // return
  32557. // }
  32558. //
  32559. // var patientPrescription models.HisPrescriptionInfo
  32560. // recordDateTime := theTime.Unix()
  32561. // adminInfo := c.GetAdminUserInfo()
  32562. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  32563. //
  32564. // if patientPrescription.ID == 0 {
  32565. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  32566. // }
  32567. //
  32568. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  32569. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  32570. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  32571. // sickConfig, _ := service.FindSickById(sick_type)
  32572. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  32573. //
  32574. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  32575. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  32576. // "&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 +
  32577. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  32578. // resp2, requestErr2 := http.Get(api2)
  32579. // if requestErr2 != nil {
  32580. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32581. // return
  32582. // }
  32583. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  32584. // if ioErr2 != nil {
  32585. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  32586. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32587. // return
  32588. // }
  32589. // var respJSON2 map[string]interface{}
  32590. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  32591. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32592. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32593. // return
  32594. // }
  32595. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32596. // userJSONBytes2, _ := json.Marshal(respJSON2)
  32597. //
  32598. // var res2 ResultSix
  32599. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  32600. // utils.ErrorLog("解析失败:%v", err)
  32601. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32602. // return
  32603. // }
  32604. // if res2.Infcode != 0 {
  32605. // adminUser := c.GetAdminUserInfo()
  32606. // errlog := &models.HisOrderError{
  32607. // UserOrgId: adminUser.CurrentOrgId,
  32608. // Ctime: time.Now().Unix(),
  32609. // Mtime: time.Now().Unix(),
  32610. // ErrMsg: res2.ErrMsg,
  32611. // Status: 1,
  32612. // PatientId: id,
  32613. // RecordTime: recordDateTime,
  32614. // Stage: 3,
  32615. // }
  32616. // service.CreateErrMsgLog(errlog)
  32617. //
  32618. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  32619. // return
  32620. // }
  32621. //
  32622. // c.ServeSuccessJSON(map[string]interface{}{
  32623. // "msg": "上传成功",
  32624. // })
  32625. //
  32626. //}
  32627. type QueryResult struct {
  32628. ID int64
  32629. Name string
  32630. Code string
  32631. List_type_code string
  32632. }
  32633. func (c *HisApiController) GetCheckCode() {
  32634. ids_str := c.GetString("ids")
  32635. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  32636. ids_arr := strings.Split(ids_str, ",")
  32637. var queryResult []QueryResult
  32638. ids := make([]int64, 0)
  32639. for _, item := range ids_arr {
  32640. id, _ := strconv.ParseInt(item, 10, 64)
  32641. ids = append(ids, id)
  32642. }
  32643. if record_type == 1 {
  32644. drugs, _ := service.GetBatchDrugList(ids)
  32645. for _, item := range drugs {
  32646. result := QueryResult{
  32647. ID: item.ID,
  32648. Name: item.DrugName,
  32649. Code: item.MedicalInsuranceNumber,
  32650. List_type_code: "101",
  32651. }
  32652. queryResult = append(queryResult, result)
  32653. }
  32654. } else if record_type == 2 {
  32655. goods, _ := service.GetBatchGoodInformationList(ids)
  32656. fmt.Println(goods)
  32657. for _, item := range goods {
  32658. result := QueryResult{
  32659. ID: item.ID,
  32660. Name: item.GoodName,
  32661. Code: item.SocialSecurityDirectoryCode,
  32662. List_type_code: "301",
  32663. }
  32664. queryResult = append(queryResult, result)
  32665. }
  32666. } else if record_type == 3 {
  32667. projects, _ := service.GetBathchMyPorjecgList(ids)
  32668. for _, item := range projects {
  32669. result := QueryResult{
  32670. ID: item.ID,
  32671. Name: item.ProjectName,
  32672. Code: item.MedicalCode,
  32673. List_type_code: "201",
  32674. }
  32675. queryResult = append(queryResult, result)
  32676. }
  32677. }
  32678. admin_user_id, _ := c.GetInt64("admin_user_id")
  32679. adminUser := c.GetAdminUserInfo()
  32680. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32681. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32682. var user_name string
  32683. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32684. if role.ID == 0 {
  32685. user_name = "管理员"
  32686. } else {
  32687. user_name = role.UserName
  32688. }
  32689. baseParams := models.BaseParams{
  32690. SecretKey: miConfig.SecretKey,
  32691. FixmedinsCode: miConfig.Code,
  32692. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  32693. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  32694. OrgName: miConfig.OrgName,
  32695. Doctor: user_name,
  32696. }
  32697. var result string
  32698. if miConfig.MdtrtareaAdmvs == "430800" {
  32699. for _, item := range queryResult {
  32700. if record_type == 1 {
  32701. 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)
  32702. } else if record_type == 2 {
  32703. fmt.Println(item.Code)
  32704. 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)
  32705. } else if record_type == 3 {
  32706. 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)
  32707. }
  32708. var dat map[string]interface{}
  32709. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32710. fmt.Println(dat)
  32711. } else {
  32712. fmt.Println(err)
  32713. }
  32714. userJSONBytes, _ := json.Marshal(dat)
  32715. var res ResultSix
  32716. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32717. utils.ErrorLog("解析失败:%v", err)
  32718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32719. return
  32720. }
  32721. if res.Infcode == 0 {
  32722. if record_type == 1 {
  32723. service.UpdateBaseDrugById(item.ID)
  32724. } else if record_type == 2 {
  32725. service.UpdateGoodInformaitonByDetail(item.ID)
  32726. } else if record_type == 3 {
  32727. service.UpdateProjectById(item.ID)
  32728. }
  32729. c.ServeSuccessJSON(map[string]interface{}{
  32730. "failed_code": 0,
  32731. "msg": "目录对照成功",
  32732. })
  32733. } else {
  32734. c.ServeSuccessJSON(map[string]interface{}{
  32735. "failed_code": -10,
  32736. "msg": res.ErrMsg,
  32737. })
  32738. }
  32739. }
  32740. } else {
  32741. for _, item := range queryResult {
  32742. var result string
  32743. if record_type == 1 {
  32744. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  32745. } else if record_type == 2 {
  32746. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  32747. } else if record_type == 3 {
  32748. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  32749. }
  32750. var dat map[string]interface{}
  32751. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32752. fmt.Println(dat)
  32753. } else {
  32754. fmt.Println(err)
  32755. }
  32756. userJSONBytes, _ := json.Marshal(dat)
  32757. var res ResultSix
  32758. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32759. utils.ErrorLog("解析失败:%v", err)
  32760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32761. return
  32762. }
  32763. if res.Infcode == 0 {
  32764. if record_type == 1 {
  32765. service.UpdateBaseDrugById(item.ID)
  32766. } else if record_type == 2 {
  32767. service.UpdateGoodInformaitonByDetail(item.ID)
  32768. } else if record_type == 3 {
  32769. service.UpdateProjectById(item.ID)
  32770. }
  32771. c.ServeSuccessJSON(map[string]interface{}{
  32772. "failed_code": 0,
  32773. "msg": "目录对照成功",
  32774. })
  32775. } else {
  32776. c.ServeSuccessJSON(map[string]interface{}{
  32777. "failed_code": -10,
  32778. "msg": res.ErrMsg,
  32779. })
  32780. }
  32781. }
  32782. }
  32783. }
  32784. func (c *HisApiController) UnCheckCode() {
  32785. ids_str := c.GetString("ids")
  32786. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  32787. admin_user_id, _ := c.GetInt64("admin_user_id")
  32788. ids_arr := strings.Split(ids_str, ",")
  32789. var queryResult []QueryResult
  32790. ids := make([]int64, 0)
  32791. for _, item := range ids_arr {
  32792. id, _ := strconv.ParseInt(item, 10, 64)
  32793. ids = append(ids, id)
  32794. }
  32795. if record_type == 1 {
  32796. drugs, _ := service.GetBatchDrugList(ids)
  32797. for _, item := range drugs {
  32798. result := QueryResult{
  32799. ID: item.ID,
  32800. Name: item.DrugName,
  32801. Code: item.MedicalInsuranceNumber,
  32802. List_type_code: "101",
  32803. }
  32804. queryResult = append(queryResult, result)
  32805. }
  32806. } else if record_type == 2 {
  32807. goods, _ := service.GetBatchGoodInformationList(ids)
  32808. for _, item := range goods {
  32809. result := QueryResult{
  32810. ID: item.ID,
  32811. Name: item.GoodName,
  32812. Code: item.SocialSecurityDirectoryCode,
  32813. List_type_code: "301",
  32814. }
  32815. queryResult = append(queryResult, result)
  32816. }
  32817. } else if record_type == 3 {
  32818. projects, _ := service.GetBathchMyPorjecgList(ids)
  32819. for _, item := range projects {
  32820. result := QueryResult{
  32821. ID: item.ID,
  32822. Name: item.ProjectName,
  32823. Code: item.MedicalCode,
  32824. List_type_code: "201",
  32825. }
  32826. queryResult = append(queryResult, result)
  32827. }
  32828. }
  32829. adminUser := c.GetAdminUserInfo()
  32830. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32831. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32832. var user_name string
  32833. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32834. if role.ID == 0 {
  32835. user_name = "xxx"
  32836. } else {
  32837. user_name = role.UserName
  32838. }
  32839. baseParams := &models.BaseParams{
  32840. SecretKey: miConfig.SecretKey,
  32841. FixmedinsCode: miConfig.Code,
  32842. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  32843. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  32844. OrgName: miConfig.OrgName,
  32845. Doctor: user_name,
  32846. }
  32847. if config.IsOpen == 1 {
  32848. if miConfig.MdtrtareaAdmvs == "430800" {
  32849. for _, item := range queryResult {
  32850. var result string
  32851. if record_type == 1 {
  32852. 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)
  32853. } else if record_type == 2 {
  32854. fmt.Println(item.Code)
  32855. 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)
  32856. } else if record_type == 3 {
  32857. 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)
  32858. }
  32859. var dat map[string]interface{}
  32860. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32861. fmt.Println(dat)
  32862. } else {
  32863. fmt.Println(err)
  32864. }
  32865. userJSONBytes, _ := json.Marshal(dat)
  32866. var res ResultSix
  32867. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32868. utils.ErrorLog("解析失败:%v", err)
  32869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32870. return
  32871. }
  32872. if res.Infcode == 0 {
  32873. if record_type == 1 {
  32874. service.UpdateBaseDrugById(item.ID)
  32875. } else if record_type == 2 {
  32876. service.UpdateGoodInformaitonByDetail(item.ID)
  32877. } else if record_type == 3 {
  32878. service.UpdateProjectById(item.ID)
  32879. }
  32880. c.ServeSuccessJSON(map[string]interface{}{
  32881. "failed_code": 0,
  32882. "msg": "目录对照成功",
  32883. })
  32884. } else {
  32885. c.ServeSuccessJSON(map[string]interface{}{
  32886. "failed_code": -10,
  32887. "msg": res.ErrMsg,
  32888. })
  32889. }
  32890. }
  32891. } else {
  32892. for _, item := range queryResult {
  32893. var result string
  32894. if record_type == 1 {
  32895. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  32896. } else if record_type == 2 {
  32897. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  32898. } else if record_type == 3 {
  32899. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  32900. }
  32901. var dat2 map[string]interface{}
  32902. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  32903. fmt.Println(dat2)
  32904. } else {
  32905. fmt.Println(err)
  32906. }
  32907. userJSONBytes, _ := json.Marshal(dat2)
  32908. var res ResultSix
  32909. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32910. utils.ErrorLog("解析失败:%v", err)
  32911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32912. return
  32913. }
  32914. if res.Infcode == 0 {
  32915. if record_type == 1 {
  32916. service.UpdateDrugByIdDetail(item.ID)
  32917. } else if record_type == 2 {
  32918. service.UpdateGoodInfoById(item.ID)
  32919. } else if record_type == 3 {
  32920. service.UpdateMyProjectById(item.ID)
  32921. }
  32922. c.ServeSuccessJSON(map[string]interface{}{
  32923. "failed_code": 0,
  32924. "msg": "撤销目录对照成功",
  32925. })
  32926. } else {
  32927. c.ServeSuccessJSON(map[string]interface{}{
  32928. "failed_code": -10,
  32929. "msg": res.ErrMsg,
  32930. })
  32931. }
  32932. }
  32933. }
  32934. }
  32935. }
  32936. func (c *HisApiController) GetPatientInfo() {
  32937. id_card_no := c.GetString("id_card_no")
  32938. admin_user_id, _ := c.GetInt64("admin_user_id")
  32939. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  32940. if patient.ID == 0 {
  32941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  32942. return
  32943. }
  32944. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  32945. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  32946. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  32947. var res ResultTwo
  32948. var res10265 ResultTwo10265
  32949. if config.IsOpen == 1 {
  32950. if miConfig.MdtrtareaAdmvs == "150499" {
  32951. //请求内网数据
  32952. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  32953. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  32954. "&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
  32955. resp, requestErr := http.Get(api)
  32956. if requestErr != nil {
  32957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32958. return
  32959. }
  32960. body, ioErr := ioutil.ReadAll(resp.Body)
  32961. if ioErr != nil {
  32962. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32964. return
  32965. }
  32966. var respJSON map[string]interface{}
  32967. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32968. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32970. return
  32971. }
  32972. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32973. result_byte, _ := json.Marshal(respJSON)
  32974. result := string(result_byte)
  32975. var dat map[string]interface{}
  32976. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32977. fmt.Println(dat)
  32978. } else {
  32979. fmt.Println(err)
  32980. }
  32981. userJSONBytes, _ := json.Marshal(dat)
  32982. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  32983. utils.ErrorLog("解析失败:%v", err)
  32984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32985. return
  32986. }
  32987. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  32988. res.Infcode = Infcode
  32989. res.ErrMsg = res10265.ErrMsg
  32990. res.Output = res10265.Output
  32991. res.InfRefmsgid = res10265.InfRefmsgid
  32992. res.RespondTime = res10265.RespondTime
  32993. res.WarnInfo = res10265.WarnInfo
  32994. } else {
  32995. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  32996. var dat map[string]interface{}
  32997. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32998. fmt.Println(dat)
  32999. } else {
  33000. fmt.Println(err)
  33001. }
  33002. userJSONBytes, _ := json.Marshal(dat)
  33003. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33004. utils.ErrorLog("解析失败:%v", err)
  33005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33006. return
  33007. }
  33008. }
  33009. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33010. // utils.ErrorLog("解析失败:%v", err)
  33011. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33012. // return
  33013. //}
  33014. for index, item := range res.Output.Iinfo {
  33015. if item.PsnInsuStas == "2" {
  33016. fmt.Println("--------")
  33017. res.Output.Iinfo[index].Insutype = "300"
  33018. res.Output.Iinfo[index].PsnInsuStas = "1"
  33019. }
  33020. }
  33021. fmt.Println(res.Output.Iinfo)
  33022. if res.Infcode != 0 {
  33023. c.ServeSuccessJSON(map[string]interface{}{
  33024. "failed_code": -10,
  33025. "msg": res.ErrMsg,
  33026. })
  33027. } else {
  33028. c.ServeSuccessJSON(map[string]interface{}{
  33029. "failed_code": 0,
  33030. "info": res,
  33031. })
  33032. }
  33033. }
  33034. }
  33035. func (c *HisApiController) PsnPutOnRecord() {
  33036. record_type, _ := c.GetInt64("type")
  33037. patient_id, _ := c.GetInt64("patient_id")
  33038. admin_user_id, _ := c.GetInt64("admin_user_id")
  33039. start_time := c.GetString("start_time")
  33040. end_time := c.GetString("end_time")
  33041. adminUser := c.GetAdminUserInfo()
  33042. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33043. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33044. var patients []*models.Patients
  33045. if record_type == 1 { //全部备案
  33046. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  33047. patients = append(patients, patient...)
  33048. } else { //单个备案
  33049. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  33050. patients = append(patients, patient)
  33051. }
  33052. var user_name string
  33053. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33054. if role.ID == 0 {
  33055. user_name = "xxx"
  33056. } else {
  33057. user_name = role.UserName
  33058. }
  33059. if config.IsOpen == 1 {
  33060. for _, item := range patients {
  33061. 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
  33062. resp, requestErr := http.Get(api)
  33063. if requestErr != nil {
  33064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33065. return
  33066. }
  33067. defer resp.Body.Close()
  33068. body, ioErr := ioutil.ReadAll(resp.Body)
  33069. if ioErr != nil {
  33070. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33072. return
  33073. }
  33074. var respJSON map[string]interface{}
  33075. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33076. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33078. return
  33079. }
  33080. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33081. userJSONBytes, _ := json.Marshal(userJSON)
  33082. var res ResultTwo
  33083. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33084. utils.ErrorLog("解析失败:%v", err)
  33085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33086. return
  33087. }
  33088. if res.Infcode == 0 {
  33089. 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)
  33090. var dat map[string]interface{}
  33091. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33092. fmt.Println(dat)
  33093. } else {
  33094. fmt.Println(err)
  33095. }
  33096. userJSONBytes, _ := json.Marshal(dat)
  33097. var res2 ResultThirteen
  33098. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33099. utils.ErrorLog("解析失败:%v", err)
  33100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33101. return
  33102. }
  33103. if res2.Infcode == 0 {
  33104. psnResult := &models.GdybPsnRecord{
  33105. UserOrgId: adminUser.CurrentOrgId,
  33106. PatientId: item.ID,
  33107. PsnNo: res.Output.Baseinfo.PsnNo,
  33108. Ctime: time.Now().Unix(),
  33109. Mtime: time.Now().Unix(),
  33110. Status: 1,
  33111. IsCancel: 1,
  33112. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  33113. }
  33114. service.CreatePsnRecord(psnResult)
  33115. } else {
  33116. c.ServeSuccessJSON(map[string]interface{}{
  33117. "failed_code": -10,
  33118. "msg": res2.ErrMsg,
  33119. })
  33120. return
  33121. }
  33122. }
  33123. }
  33124. }
  33125. }
  33126. func (c *HisApiController) PsnUnPutOnRecord() {
  33127. id, _ := c.GetInt64("id")
  33128. //record_type, _ := c.GetInt64("type")
  33129. admin_user_id, _ := c.GetInt64("admin_user_id")
  33130. adminUser := c.GetAdminUserInfo()
  33131. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33132. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33133. var user_name string
  33134. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33135. if role.ID == 0 {
  33136. user_name = "xxx"
  33137. } else {
  33138. user_name = role.UserName
  33139. }
  33140. psn_record, _ := service.GetPsnRecordById(id)
  33141. if psn_record.ID == 0 {
  33142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  33143. return
  33144. }
  33145. if config.IsOpen == 1 {
  33146. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  33147. var dat map[string]interface{}
  33148. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33149. fmt.Println(dat)
  33150. } else {
  33151. fmt.Println(err)
  33152. }
  33153. userJSONBytes, _ := json.Marshal(dat)
  33154. var res ResultFourteen
  33155. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33156. utils.ErrorLog("解析失败:%v", err)
  33157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33158. return
  33159. }
  33160. if res.Infcode == 0 {
  33161. psn_record.IsCancel = 2
  33162. service.CreatePsnRecord(&psn_record)
  33163. } else {
  33164. c.ServeSuccessJSON(map[string]interface{}{
  33165. "failed_code": -10,
  33166. "msg": res.ErrMsg,
  33167. })
  33168. return
  33169. }
  33170. }
  33171. }
  33172. func (c *HisApiController) PsnPutNCDSOnRecord() {
  33173. patient_id, _ := c.GetInt64("patient_id")
  33174. insutype_two := c.GetString("insutype")
  33175. psn_no := c.GetString("psn_no")
  33176. doctor_id, _ := c.GetInt64("doctor_id")
  33177. sick_id, _ := c.GetInt64("sick_id")
  33178. department_id, _ := c.GetInt64("department_id")
  33179. start_time := c.GetString("start_time")
  33180. end_time := c.GetString("end_time")
  33181. check_time := c.GetString("check_time")
  33182. hospital_code := c.GetString("hospital_code")
  33183. hospital_name := c.GetString("hospital_name")
  33184. adminUser := c.GetAdminUserInfo()
  33185. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  33186. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33187. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33188. sick, _ := service.FindSickById(sick_id)
  33189. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  33190. if len(hospital_code) == 0 {
  33191. hospital_code = miConfig.Code
  33192. }
  33193. if len(hospital_name) == 0 {
  33194. hospital_name = miConfig.OrgName
  33195. }
  33196. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  33197. var res ResultTwo
  33198. var res10265 ResultTwo10265
  33199. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33200. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  33201. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  33202. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  33203. "&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
  33204. resp, requestErr := http.Get(api)
  33205. if requestErr != nil {
  33206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33207. return
  33208. }
  33209. body, ioErr := ioutil.ReadAll(resp.Body)
  33210. if ioErr != nil {
  33211. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33213. return
  33214. }
  33215. var respJSON map[string]interface{}
  33216. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33217. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33219. return
  33220. }
  33221. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33222. result, _ := json.Marshal(respJSON)
  33223. fmt.Println("log")
  33224. fmt.Println(string(result))
  33225. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  33226. utils.ErrorLog("解析失败:%v", err)
  33227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33228. return
  33229. }
  33230. res.ErrMsg = res10265.ErrMsg
  33231. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  33232. res.Infcode = infocode
  33233. res.Output = res10265.Output
  33234. res.InfRefmsgid = res10265.InfRefmsgid
  33235. } else {
  33236. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  33237. if miConfig.Code == "H15049901371" {
  33238. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  33239. utils.ErrorLog("解析失败:%v", err)
  33240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33241. return
  33242. }
  33243. res.ErrMsg = res10265.ErrMsg
  33244. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  33245. res.Infcode = infocode
  33246. res.Output = res10265.Output
  33247. res.InfRefmsgid = res10265.InfRefmsgid
  33248. } else {
  33249. if err := json.Unmarshal([]byte(result), &res); err != nil {
  33250. utils.ErrorLog("解析失败:%v", err)
  33251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33252. return
  33253. }
  33254. }
  33255. }
  33256. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  33257. infoStr := string(Iinfos)
  33258. var rf []*ResultFive
  33259. json.Unmarshal([]byte(infoStr), &rf)
  33260. var insuplc_admdvs string
  33261. var insutype string
  33262. var is390 int = 0
  33263. var is310 int = 0
  33264. var insutypes []*ResultFive
  33265. for _, item := range rf {
  33266. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  33267. insutypes = append(insutypes, item)
  33268. }
  33269. }
  33270. if len(insutypes) == 1 {
  33271. insutype = insutypes[0].Insutype
  33272. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  33273. } else {
  33274. for _, i := range insutypes {
  33275. if i.Insutype == "390" {
  33276. is390 = 1
  33277. }
  33278. if i.Insutype == "310" {
  33279. is310 = 1
  33280. }
  33281. }
  33282. }
  33283. if is390 == 1 {
  33284. insutype = "390"
  33285. }
  33286. if is310 == 1 {
  33287. insutype = "310"
  33288. }
  33289. if len(insutypes) == 2 {
  33290. insutype = insutype_two
  33291. }
  33292. if len(insutypes) == 0 {
  33293. insutype = "310"
  33294. }
  33295. insutype = insutype_two
  33296. fmt.Println(insutype)
  33297. for _, item := range rf {
  33298. fmt.Println(item.Insutype)
  33299. fmt.Println(insutype)
  33300. if item.Insutype == insutype {
  33301. fmt.Println(item.Insutype)
  33302. fmt.Println(insutype)
  33303. insuplc_admdvs = item.InsuplcAdmdvs
  33304. }
  33305. }
  33306. fmt.Println(insuplc_admdvs)
  33307. var res2 ResultThirteen
  33308. var res10265_2 ResultThirteen10265
  33309. if config.IsOpen == 1 {
  33310. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33311. } else {
  33312. if miConfig.MdtrtareaAdmvs == "150499" {
  33313. //
  33314. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  33315. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  33316. // "&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
  33317. //resp, requestErr := http.Get(api)
  33318. //if requestErr != nil {
  33319. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33320. // return
  33321. //}
  33322. //
  33323. //body, ioErr := ioutil.ReadAll(resp.Body)
  33324. //if ioErr != nil {
  33325. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33326. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33327. // return
  33328. //}
  33329. //var respJSON map[string]interface{}
  33330. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33331. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33332. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33333. // return
  33334. //}
  33335. //
  33336. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33337. //result, _ := json.Marshal(respJSON)
  33338. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  33339. // utils.ErrorLog("解析失败:%v", err)
  33340. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33341. // return
  33342. //}
  33343. //infocode = resThree.Infcode
  33344. //result, _ := json.Marshal(respJSON)
  33345. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  33346. // utils.ErrorLog("解析失败:%v", err)
  33347. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33348. // return
  33349. //}
  33350. //
  33351. //resThree.ErrMsg = resThree10265.ErrMsg
  33352. //
  33353. //resThree.Output = resThree10265.Output
  33354. //
  33355. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  33356. //
  33357. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  33358. //
  33359. } else {
  33360. 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)
  33361. var dat map[string]interface{}
  33362. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33363. fmt.Println(dat)
  33364. } else {
  33365. fmt.Println(err)
  33366. }
  33367. userJSONBytes, _ := json.Marshal(dat)
  33368. if miConfig.Code == "H15049901371" {
  33369. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  33370. utils.ErrorLog("解析失败:%v", err)
  33371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33372. return
  33373. }
  33374. res2.ErrMsg = res10265_2.ErrMsg
  33375. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  33376. res2.Infcode = infocode
  33377. res2.Output = res10265_2.Output
  33378. res2.InfRefmsgid = res10265_2.InfRefmsgid
  33379. } else {
  33380. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33381. utils.ErrorLog("解析失败:%v", err)
  33382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33383. return
  33384. }
  33385. }
  33386. }
  33387. }
  33388. if res2.Infcode == 0 {
  33389. psnResult := &models.GdybPsnNcdsRecord{
  33390. UserOrgId: adminUser.CurrentOrgId,
  33391. PatientId: patient.ID,
  33392. PsnNo: psn_no,
  33393. DoctorId: doctor.AdminUserId,
  33394. DepartmentId: department_id,
  33395. SickType: sick_id,
  33396. Insutype: insutype,
  33397. Ctime: time.Now().Unix(),
  33398. Mtime: time.Now().Unix(),
  33399. Status: 1,
  33400. IsCancel: 1,
  33401. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  33402. }
  33403. service.CreatePsnNCDSRecord(psnResult)
  33404. c.ServeSuccessJSON(map[string]interface{}{
  33405. "failed_code": 0,
  33406. "msg": "备案成功",
  33407. "result": psnResult,
  33408. })
  33409. } else {
  33410. c.ServeSuccessJSON(map[string]interface{}{
  33411. "failed_code": -10,
  33412. "msg": res2.ErrMsg,
  33413. })
  33414. return
  33415. }
  33416. }
  33417. }
  33418. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  33419. id, _ := c.GetInt64("id")
  33420. admin_user_id, _ := c.GetInt64("admin_user_id")
  33421. adminUser := c.GetAdminUserInfo()
  33422. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33423. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33424. //config, _ := service.Ge(adminUser.CurrentOrgId)
  33425. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  33426. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33427. //var user_name string
  33428. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33429. //if role.ID == 0 {
  33430. // user_name = "xxx"
  33431. //} else {
  33432. // user_name = role.UserName
  33433. //}
  33434. psn_record, _ := service.GetPsnNCDSRecordById(id)
  33435. if psn_record.ID == 0 {
  33436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  33437. return
  33438. }
  33439. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  33440. var res ResultTwo
  33441. var res10265 ResultTwo10265
  33442. if miConfig.Code == "H15049901371" {
  33443. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  33444. utils.ErrorLog("解析失败:%v", err)
  33445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33446. return
  33447. }
  33448. res.ErrMsg = res10265.ErrMsg
  33449. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  33450. res.Infcode = infocode
  33451. res.Output = res10265.Output
  33452. res.InfRefmsgid = res10265.InfRefmsgid
  33453. } else {
  33454. if err := json.Unmarshal([]byte(result), &res); err != nil {
  33455. utils.ErrorLog("解析失败:%v", err)
  33456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33457. return
  33458. }
  33459. }
  33460. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  33461. infoStr := string(Iinfos)
  33462. var rf []*ResultFive
  33463. json.Unmarshal([]byte(infoStr), &rf)
  33464. var insuplc_admdvs string
  33465. var insutype string
  33466. var is390 int = 0
  33467. var is310 int = 0
  33468. var insutypes []*ResultFive
  33469. for _, item := range rf {
  33470. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  33471. insutypes = append(insutypes, item)
  33472. }
  33473. }
  33474. if len(insutypes) == 1 {
  33475. insutype = insutypes[0].Insutype
  33476. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  33477. } else {
  33478. for _, i := range insutypes {
  33479. if i.Insutype == "390" {
  33480. is390 = 1
  33481. }
  33482. if i.Insutype == "310" {
  33483. is310 = 1
  33484. }
  33485. }
  33486. }
  33487. if is390 == 1 {
  33488. insutype = "390"
  33489. }
  33490. if is310 == 1 {
  33491. insutype = "310"
  33492. }
  33493. if len(insutypes) == 0 {
  33494. insutype = "310"
  33495. }
  33496. insutype = psn_record.Insutype
  33497. for _, item := range rf {
  33498. if item.Insutype == insutype {
  33499. insuplc_admdvs = item.InsuplcAdmdvs
  33500. }
  33501. }
  33502. if config.IsOpen == 1 {
  33503. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  33504. var dat map[string]interface{}
  33505. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33506. fmt.Println(dat)
  33507. } else {
  33508. fmt.Println(err)
  33509. }
  33510. userJSONBytes, _ := json.Marshal(dat)
  33511. var res ResultFourteen
  33512. var res10265 ResultFourteen10265
  33513. if miConfig.Code == "H15049901371" {
  33514. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  33515. utils.ErrorLog("解析失败:%v", err)
  33516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33517. return
  33518. }
  33519. res.ErrMsg = res10265.ErrMsg
  33520. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  33521. res.Infcode = infocode
  33522. res.Output = res10265.Output
  33523. res.InfRefmsgid = res10265.InfRefmsgid
  33524. } else {
  33525. if err := json.Unmarshal([]byte(result), &res); err != nil {
  33526. utils.ErrorLog("解析失败:%v", err)
  33527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33528. return
  33529. }
  33530. }
  33531. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33532. // utils.ErrorLog("解析失败:%v", err)
  33533. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33534. // return
  33535. //}
  33536. if res.Infcode == 0 {
  33537. psn_record.IsCancel = 2
  33538. service.CreatePsnNCDSRecord(&psn_record)
  33539. c.ServeSuccessJSON(map[string]interface{}{
  33540. "failed_code": 0,
  33541. "msg": "撤销备案成功",
  33542. })
  33543. } else {
  33544. c.ServeSuccessJSON(map[string]interface{}{
  33545. "failed_code": -10,
  33546. "msg": res.ErrMsg,
  33547. })
  33548. return
  33549. }
  33550. }
  33551. }
  33552. func (c *HisApiController) TestTest() {
  33553. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  33554. fmt.Println(patient.Iinfo)
  33555. }
  33556. type CustomData struct {
  33557. MsgId string
  33558. PsnNo string
  33559. Info string
  33560. }
  33561. func (c *HisApiController) ReversalData() {
  33562. var customData []*CustomData
  33563. custom := &CustomData{
  33564. MsgId: "H44022900158202103301714472004",
  33565. PsnNo: "44020000001101329945",
  33566. Info: "2207",
  33567. }
  33568. customData = append(customData, custom)
  33569. custom1 := &CustomData{
  33570. MsgId: "H4402290015820210330172057803",
  33571. PsnNo: "44020000001101161813",
  33572. Info: "2207",
  33573. }
  33574. customData = append(customData, custom1)
  33575. custom2 := &CustomData{
  33576. MsgId: "H44022900158202103301705198813",
  33577. PsnNo: "44190000133097375417",
  33578. Info: "2207",
  33579. }
  33580. customData = append(customData, custom2)
  33581. custom3 := &CustomData{
  33582. MsgId: "H44022900158202103301715524756",
  33583. PsnNo: "44020000001100187221",
  33584. Info: "2207",
  33585. }
  33586. customData = append(customData, custom3)
  33587. custom4 := &CustomData{
  33588. MsgId: "H44022900158202103301730376224",
  33589. PsnNo: "44020000001101959155",
  33590. Info: "2207",
  33591. }
  33592. customData = append(customData, custom4)
  33593. custom5 := &CustomData{
  33594. MsgId: "H44022900158202103301748008725",
  33595. PsnNo: "44020000001104246641",
  33596. Info: "2207",
  33597. }
  33598. customData = append(customData, custom5)
  33599. custom6 := &CustomData{
  33600. MsgId: "H44022900158202103301718096755",
  33601. PsnNo: "44020000001102211860",
  33602. Info: "2207",
  33603. }
  33604. customData = append(customData, custom6)
  33605. custom7 := &CustomData{
  33606. MsgId: "H44022900158202103301736551640",
  33607. PsnNo: "44020000001102687718",
  33608. Info: "2207",
  33609. }
  33610. customData = append(customData, custom7)
  33611. custom8 := &CustomData{
  33612. MsgId: "H44022900158202103301743097676",
  33613. PsnNo: "44020000001102127785",
  33614. Info: "2207",
  33615. }
  33616. customData = append(customData, custom8)
  33617. custom9 := &CustomData{
  33618. MsgId: "H44022900158202103301712304203",
  33619. PsnNo: "44020000001101518097",
  33620. Info: "2207",
  33621. }
  33622. customData = append(customData, custom9)
  33623. custom10 := &CustomData{
  33624. MsgId: "H44022900158202103301738448785",
  33625. PsnNo: "44020000001100500813",
  33626. Info: "2207",
  33627. }
  33628. customData = append(customData, custom10)
  33629. custom11 := &CustomData{
  33630. MsgId: "H44022900158202103301732455843",
  33631. PsnNo: "44020000001102690557",
  33632. Info: "2207",
  33633. }
  33634. customData = append(customData, custom11)
  33635. custom12 := &CustomData{
  33636. MsgId: "H44022900158202103301745421708",
  33637. PsnNo: "44020000001102211928",
  33638. Info: "2207",
  33639. }
  33640. customData = append(customData, custom12)
  33641. custom1212 := &CustomData{
  33642. MsgId: "H440229001582021033017351627",
  33643. PsnNo: "44020000001102481733",
  33644. Info: "2207",
  33645. }
  33646. customData = append(customData, custom1212)
  33647. custom13 := &CustomData{
  33648. MsgId: "H44022900158202103301740327951",
  33649. PsnNo: "44020000001103174866",
  33650. Info: "2207",
  33651. }
  33652. customData = append(customData, custom13)
  33653. custom14 := &CustomData{
  33654. MsgId: "H4402290015820210330174922668",
  33655. PsnNo: "44020000001102927272",
  33656. Info: "2207",
  33657. }
  33658. customData = append(customData, custom14)
  33659. custom15 := &CustomData{
  33660. MsgId: "H44022900158202103301752362273",
  33661. PsnNo: "44020000001102942890",
  33662. Info: "2207",
  33663. }
  33664. customData = append(customData, custom15)
  33665. custom16 := &CustomData{
  33666. MsgId: "H44022900158202103301751082917",
  33667. PsnNo: "44020000001101662162",
  33668. Info: "2207",
  33669. }
  33670. customData = append(customData, custom16)
  33671. custom17 := &CustomData{
  33672. MsgId: "H44022900158202103301754147728",
  33673. PsnNo: "44020000000229014511",
  33674. Info: "2207",
  33675. }
  33676. customData = append(customData, custom17)
  33677. adminUser := c.GetAdminUserInfo()
  33678. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33679. for _, item := range customData {
  33680. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  33681. fmt.Println(result)
  33682. }
  33683. }
  33684. func (c *HisApiController) GetAllopatry() {
  33685. year := c.GetString("year")
  33686. month := c.GetString("month")
  33687. admin_user_id, _ := c.GetInt64("admin_user_id")
  33688. adminUser := c.GetAdminUserInfo()
  33689. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33690. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33691. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  33692. var dat map[string]interface{}
  33693. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33694. fmt.Println(dat)
  33695. } else {
  33696. fmt.Println(err)
  33697. }
  33698. userJSONBytes, _ := json.Marshal(dat)
  33699. var res models.Result9001
  33700. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33701. utils.ErrorLog("解析失败:%v", err)
  33702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33703. return
  33704. }
  33705. fmt.Println(res.Output.Signinoutb)
  33706. fmt.Println(res.Output.Signinoutb.SignNo)
  33707. fmt.Println(string(userJSONBytes))
  33708. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  33709. var dat3 map[string]interface{}
  33710. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  33711. fmt.Println(dat3)
  33712. } else {
  33713. fmt.Println(err)
  33714. }
  33715. userJSONBytes3, _ := json.Marshal(dat3)
  33716. var res3 models.Result3260
  33717. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  33718. utils.ErrorLog("解析失败:%v", err)
  33719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33720. return
  33721. }
  33722. var curpage int
  33723. var pagesize int = 100
  33724. var start int = 1
  33725. //var stop int
  33726. //pagecount := 10
  33727. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  33728. var res22 []models.Result3260
  33729. for curpage = 1; curpage <= pagecount; curpage++ {
  33730. if curpage == 1 {
  33731. start = 0
  33732. } else {
  33733. start = (curpage-1)*pagesize + 1
  33734. }
  33735. fmt.Println(start)
  33736. //stop = curpage * pagesize
  33737. //if stop > int(res3.Output.Totalrow) {
  33738. // stop =int(res3.Output.Totalrow)
  33739. //}
  33740. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  33741. var dat2 map[string]interface{}
  33742. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  33743. fmt.Println(dat)
  33744. } else {
  33745. fmt.Println(err)
  33746. }
  33747. userJSONBytes2, _ := json.Marshal(dat2)
  33748. var res2 models.Result3260
  33749. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  33750. utils.ErrorLog("解析失败:%v", err)
  33751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33752. return
  33753. }
  33754. if res2.Infcode == 0 {
  33755. res22 = append(res22, res2)
  33756. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  33757. //var dat2 map[string]interface{}
  33758. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  33759. // fmt.Println(dat)
  33760. //} else {
  33761. // fmt.Println(err)
  33762. //}
  33763. //c.ServeSuccessJSON(map[string]interface{}{
  33764. // "list": res2.Output.Data,
  33765. //})
  33766. //continue
  33767. }
  33768. }
  33769. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  33770. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  33771. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  33772. //var dat2 map[string]interface{}
  33773. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  33774. // fmt.Println(dat)
  33775. //} else {
  33776. // fmt.Println(err)
  33777. //}
  33778. //userJSONBytes2, _ := json.Marshal(dat2)
  33779. //var res2 models.Result3260
  33780. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  33781. // utils.ErrorLog("解析失败:%v", err)
  33782. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33783. // return
  33784. //}
  33785. //if res2.Infcode == 0 {
  33786. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  33787. // var dat2 map[string]interface{}
  33788. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  33789. // fmt.Println(dat)
  33790. // } else {
  33791. // fmt.Println(err)
  33792. // }
  33793. // c.ServeSuccessJSON(map[string]interface{}{
  33794. // "list": res2.Output.Data,
  33795. // })
  33796. //}
  33797. }
  33798. func (c *HisApiController) ComfirmAllopatry() {
  33799. year := c.GetString("year")
  33800. month := c.GetString("month")
  33801. admin_user_id, _ := c.GetInt64("admin_user_id")
  33802. adminUser := c.GetAdminUserInfo()
  33803. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33804. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33805. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  33806. var dat map[string]interface{}
  33807. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33808. fmt.Println(dat)
  33809. } else {
  33810. fmt.Println(err)
  33811. }
  33812. userJSONBytes, _ := json.Marshal(dat)
  33813. var res models.Result9001
  33814. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33815. utils.ErrorLog("解析失败:%v", err)
  33816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33817. return
  33818. }
  33819. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  33820. var dat2 map[string]interface{}
  33821. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  33822. fmt.Println(dat)
  33823. } else {
  33824. fmt.Println(err)
  33825. }
  33826. userJSONBytes2, _ := json.Marshal(dat2)
  33827. var res2 models.Result3260
  33828. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  33829. utils.ErrorLog("解析失败:%v", err)
  33830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33831. return
  33832. }
  33833. //if res2.Infcode == 0 {
  33834. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  33835. // var dat map[string]interface{}
  33836. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33837. // fmt.Println(dat)
  33838. // } else {
  33839. // fmt.Println(err)
  33840. // }
  33841. // userJSONBytes, _ := json.Marshal(dat)
  33842. // var res3 models.Result3261
  33843. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  33844. // utils.ErrorLog("解析失败:%v", err)
  33845. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33846. // return
  33847. // }
  33848. //
  33849. // if res3.Infcode == 0 {
  33850. // record := &models.HisYidiClearRecord{
  33851. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  33852. // Ctime: time.Now().Unix(),
  33853. // Mtime: time.Now().Unix(),
  33854. // Status: 1,
  33855. // MsgId: msgId,
  33856. // }
  33857. // service.SaveClearRecord(record)
  33858. // c.ServeSuccessJSON(map[string]interface{}{
  33859. // "msg": "提取成功",
  33860. // })
  33861. // }
  33862. //}
  33863. }
  33864. func (c *HisApiController) RefundAllopatry() {
  33865. year := c.GetString("year")
  33866. month := c.GetString("month")
  33867. //id, _ := c.GetInt64("id")
  33868. admin_user_id, _ := c.GetInt64("admin_user_id")
  33869. adminUser := c.GetAdminUserInfo()
  33870. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33871. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33872. //record, _ := service.GetClearRecordById(id)
  33873. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  33874. var dat map[string]interface{}
  33875. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33876. fmt.Println(dat)
  33877. } else {
  33878. fmt.Println(err)
  33879. }
  33880. userJSONBytes, _ := json.Marshal(dat)
  33881. var res models.Result9001
  33882. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33883. utils.ErrorLog("解析失败:%v", err)
  33884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33885. return
  33886. }
  33887. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  33888. var dat2 map[string]interface{}
  33889. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  33890. fmt.Println(dat)
  33891. } else {
  33892. fmt.Println(err)
  33893. }
  33894. userJSONBytes2, _ := json.Marshal(dat2)
  33895. var empty ResultFourteen
  33896. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  33897. utils.ErrorLog("解析失败:%v", err)
  33898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33899. return
  33900. }
  33901. if empty.Infcode == 0 {
  33902. c.ServeSuccessJSON(map[string]interface{}{
  33903. "msg": "撤销成功",
  33904. })
  33905. return
  33906. }
  33907. }
  33908. func (c *HisApiController) ReversalOtherData() {
  33909. var customData []*CustomData
  33910. custom := &CustomData{
  33911. MsgId: "H44022900158202103301714472004",
  33912. PsnNo: "44020000001101329945",
  33913. Info: "2208",
  33914. }
  33915. customData = append(customData, custom)
  33916. custom1 := &CustomData{
  33917. MsgId: "H4402290015820210330172057803",
  33918. PsnNo: "44020000001101161813",
  33919. Info: "2208",
  33920. }
  33921. customData = append(customData, custom1)
  33922. custom2 := &CustomData{
  33923. MsgId: "H44022900158202103301705198813",
  33924. PsnNo: "44190000133097375417",
  33925. Info: "2208",
  33926. }
  33927. customData = append(customData, custom2)
  33928. custom3 := &CustomData{
  33929. MsgId: "H44022900158202103301715524756",
  33930. PsnNo: "44020000001100187221",
  33931. Info: "2208",
  33932. }
  33933. customData = append(customData, custom3)
  33934. custom4 := &CustomData{
  33935. MsgId: "H44022900158202103301730376224",
  33936. PsnNo: "44020000001101959155",
  33937. Info: "2208",
  33938. }
  33939. customData = append(customData, custom4)
  33940. custom5 := &CustomData{
  33941. MsgId: "H44022900158202103301748008725",
  33942. PsnNo: "44020000001104246641",
  33943. Info: "2208",
  33944. }
  33945. customData = append(customData, custom5)
  33946. custom6 := &CustomData{
  33947. MsgId: "H44022900158202103301718096755",
  33948. PsnNo: "44020000001102211860",
  33949. Info: "2208",
  33950. }
  33951. customData = append(customData, custom6)
  33952. custom7 := &CustomData{
  33953. MsgId: "H44022900158202103301736551640",
  33954. PsnNo: "44020000001102687718",
  33955. Info: "2208",
  33956. }
  33957. customData = append(customData, custom7)
  33958. custom8 := &CustomData{
  33959. MsgId: "H44022900158202103301743097676",
  33960. PsnNo: "44020000001102127785",
  33961. Info: "2208",
  33962. }
  33963. customData = append(customData, custom8)
  33964. custom9 := &CustomData{
  33965. MsgId: "H44022900158202103301712304203",
  33966. PsnNo: "44020000001101518097",
  33967. Info: "2208",
  33968. }
  33969. customData = append(customData, custom9)
  33970. custom10 := &CustomData{
  33971. MsgId: "H44022900158202103301738448785",
  33972. PsnNo: "44020000001100500813",
  33973. Info: "2208",
  33974. }
  33975. customData = append(customData, custom10)
  33976. custom11 := &CustomData{
  33977. MsgId: "H44022900158202103301732455843",
  33978. PsnNo: "44020000001102690557",
  33979. Info: "2208",
  33980. }
  33981. customData = append(customData, custom11)
  33982. custom12 := &CustomData{
  33983. MsgId: "H44022900158202103301745421708",
  33984. PsnNo: "44020000001102211928",
  33985. Info: "2208",
  33986. }
  33987. customData = append(customData, custom12)
  33988. custom1212 := &CustomData{
  33989. MsgId: "H440229001582021033017351627",
  33990. PsnNo: "44020000001102481733",
  33991. Info: "2208",
  33992. }
  33993. customData = append(customData, custom1212)
  33994. custom13 := &CustomData{
  33995. MsgId: "H44022900158202103301740327951",
  33996. PsnNo: "44020000001103174866",
  33997. Info: "2208",
  33998. }
  33999. customData = append(customData, custom13)
  34000. custom14 := &CustomData{
  34001. MsgId: "H4402290015820210330174922668",
  34002. PsnNo: "44020000001102927272",
  34003. Info: "2208",
  34004. }
  34005. customData = append(customData, custom14)
  34006. custom15 := &CustomData{
  34007. MsgId: "H44022900158202103301752362273",
  34008. PsnNo: "44020000001102942890",
  34009. Info: "2208",
  34010. }
  34011. customData = append(customData, custom15)
  34012. custom16 := &CustomData{
  34013. MsgId: "H44022900158202103301751082917",
  34014. PsnNo: "44020000001101662162",
  34015. Info: "2208",
  34016. }
  34017. customData = append(customData, custom16)
  34018. custom17 := &CustomData{
  34019. MsgId: "H44022900158202103301754147728",
  34020. PsnNo: "44020000000229014511",
  34021. Info: "2208",
  34022. }
  34023. customData = append(customData, custom17)
  34024. adminUser := c.GetAdminUserInfo()
  34025. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34026. for _, item := range customData {
  34027. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  34028. fmt.Println(result)
  34029. }
  34030. }
  34031. func PathExists(path string) (bool, error) {
  34032. _, err := os.Stat(path)
  34033. if err == nil {
  34034. return true, nil
  34035. }
  34036. if os.IsNotExist(err) {
  34037. return false, nil
  34038. }
  34039. return false, err
  34040. }
  34041. // 创建文件夹
  34042. func Mkdir(dir string) {
  34043. // 创建文件夹
  34044. exist, err := PathExists(dir)
  34045. if err != nil {
  34046. fmt.Println(err.Error())
  34047. } else {
  34048. if exist {
  34049. fmt.Println(dir + "文件夹已存在!")
  34050. } else {
  34051. // 文件夹名称,权限
  34052. err := os.Mkdir(dir, os.ModePerm)
  34053. if err != nil {
  34054. fmt.Println(dir+"文件夹创建失败:", err.Error())
  34055. } else {
  34056. fmt.Println(dir + "文件夹创建成功!")
  34057. }
  34058. }
  34059. }
  34060. }
  34061. // 压缩文件
  34062. func Zip(srcFile string, destZip string) error {
  34063. zipfile, err := os.Create(destZip)
  34064. if err != nil {
  34065. return err
  34066. }
  34067. defer zipfile.Close()
  34068. archive := zip.NewWriter(zipfile)
  34069. defer archive.Close()
  34070. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  34071. if err != nil {
  34072. return err
  34073. }
  34074. header, err := zip.FileInfoHeader(info)
  34075. if err != nil {
  34076. return err
  34077. }
  34078. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  34079. // header.Name = path
  34080. if info.IsDir() {
  34081. header.Name += "/"
  34082. } else {
  34083. header.Method = zip.Deflate
  34084. }
  34085. writer, err := archive.CreateHeader(header)
  34086. if err != nil {
  34087. return err
  34088. }
  34089. if !info.IsDir() {
  34090. file, err := os.Open(path)
  34091. if err != nil {
  34092. return err
  34093. }
  34094. defer file.Close()
  34095. _, err = io.Copy(writer, file)
  34096. }
  34097. return err
  34098. })
  34099. return err
  34100. }
  34101. func ReadFile(filePath string) []byte {
  34102. f, err := os.Open(filePath)
  34103. if err != nil {
  34104. fmt.Println("read file fail", err)
  34105. return nil
  34106. }
  34107. defer f.Close()
  34108. fd, err := ioutil.ReadAll(f)
  34109. if err != nil {
  34110. fmt.Println("read to fd fail", err)
  34111. return nil
  34112. }
  34113. return fd
  34114. }
  34115. func saveLogq(result string, request string, infno string, desc string) {
  34116. dir := "日志"
  34117. utils.Mkdir(dir)
  34118. month := time.Unix(1557042972, 0).Format("1")
  34119. year := time.Now().Format("2006")
  34120. month = time.Now().Format("01")
  34121. day := time.Now().Format("02")
  34122. hour := time.Now().Format("15")
  34123. min := time.Now().Format("04")
  34124. sec := time.Now().Format("05")
  34125. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  34126. file := year + month + day + "_log"
  34127. file_name := file + ".txt"
  34128. file_path := "日志" + "/" + file_name
  34129. exist, _ := utils.PathExists(file_path)
  34130. if exist { //存在
  34131. fmt.Println("存在")
  34132. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  34133. if err != nil {
  34134. fmt.Println("read fail")
  34135. }
  34136. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  34137. n, _ := f.Seek(0, 2)
  34138. _, err = f.WriteAt([]byte(content), n)
  34139. } else { //不存在
  34140. fmt.Println("文件不存在,创建文件")
  34141. f, err := os.Create("日志" + "/" + file_name)
  34142. defer f.Close()
  34143. if err != nil {
  34144. } else {
  34145. _, err = f.Write([]byte("记录日志"))
  34146. }
  34147. }
  34148. }
  34149. func saveLog(result string, request string, infno string, desc string) {
  34150. org_id, _ := beego.AppConfig.Int64("org_id")
  34151. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  34152. dir := miConfig.OrgName + "日志"
  34153. utils.Mkdir(dir)
  34154. month := time.Unix(1557042972, 0).Format("1")
  34155. year := time.Now().Format("2006")
  34156. month = time.Now().Format("01")
  34157. day := time.Now().Format("02")
  34158. hour := time.Now().Format("15")
  34159. min := time.Now().Format("04")
  34160. sec := time.Now().Format("05")
  34161. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  34162. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  34163. file_name := file + ".txt"
  34164. file_path := miConfig.OrgName + "日志" + "/" + file_name
  34165. exist, _ := utils.PathExists(file_path)
  34166. if exist { //存在
  34167. fmt.Println("存在")
  34168. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  34169. if err != nil {
  34170. fmt.Println("read fail")
  34171. }
  34172. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  34173. n, _ := f.Seek(0, 2)
  34174. _, err = f.WriteAt([]byte(content), n)
  34175. } else { //不存在
  34176. fmt.Println("文件不存在,创建文件")
  34177. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  34178. defer f.Close()
  34179. if err != nil {
  34180. } else {
  34181. _, err = f.Write([]byte("记录日志"))
  34182. }
  34183. }
  34184. }
  34185. type Charset string
  34186. const (
  34187. UTF8 = Charset("UTF-8")
  34188. GB18030 = Charset("GB18030")
  34189. )
  34190. func ConvertToString(src string, srcCode string, tagCode string) string {
  34191. srcCoder := mahonia.NewDecoder(srcCode)
  34192. srcResult := srcCoder.ConvertString(src)
  34193. tagCoder := mahonia.NewDecoder(tagCode)
  34194. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  34195. result := string(cdata)
  34196. return result
  34197. }
  34198. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  34199. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  34200. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  34201. var token string
  34202. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34203. var api string
  34204. if miConfig.MdtrtareaAdmvs == "320921" {
  34205. 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 +
  34206. "&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
  34207. fmt.Println(api)
  34208. } else {
  34209. 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 +
  34210. "&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
  34211. }
  34212. resp, requestErr := http.Get(api)
  34213. if requestErr != nil {
  34214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34215. return ""
  34216. }
  34217. body, ioErr := ioutil.ReadAll(resp.Body)
  34218. if ioErr != nil {
  34219. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34221. return ""
  34222. }
  34223. var respJSON map[string]interface{}
  34224. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34225. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34227. return ""
  34228. }
  34229. var status string
  34230. status = respJSON["data"].(map[string]interface{})["status"].(string)
  34231. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  34232. var res ResultTwo //1101结果
  34233. var res10265 ResultTwo10265 //1101结果
  34234. if status == "0" { //读卡成功
  34235. var card_info string //卡信息
  34236. var busi_card_info string
  34237. token = respJSON["data"].(map[string]interface{})["token"].(string)
  34238. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  34239. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  34240. fmt.Println(card_info)
  34241. fmt.Println(busi_card_info)
  34242. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  34243. result, _ := json.Marshal(respJSON)
  34244. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  34245. utils.ErrorLog("解析失败:%v", err)
  34246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34247. return ""
  34248. }
  34249. res.ErrMsg = res10265.ErrMsg
  34250. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  34251. res.Infcode = infocode
  34252. res.Output = res10265.Output
  34253. res.InfRefmsgid = res10265.InfRefmsgid
  34254. if res.Infcode == 0 {
  34255. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  34256. if err == gorm.ErrRecordNotFound {
  34257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  34258. return ""
  34259. } else if err != nil {
  34260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  34261. return ""
  34262. } else {
  34263. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  34264. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  34265. infoStr := string(Iinfos)
  34266. idetinfoStr := string(Idetinfos)
  34267. psn := &models.HisPsn{
  34268. PsnNo: res.Output.Baseinfo.PsnNo,
  34269. PatientId: patient.ID,
  34270. Certno: res.Output.Baseinfo.Certno,
  34271. Gend: res.Output.Baseinfo.Gend,
  34272. Naty: res.Output.Baseinfo.Naty,
  34273. PsnCertType: res.Output.Baseinfo.PsnCertType,
  34274. PsnName: res.Output.Baseinfo.PsnName,
  34275. Idetinfo: idetinfoStr,
  34276. Insuinfo: infoStr,
  34277. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  34278. CardInfo: card_info,
  34279. VerifyNumber: token,
  34280. }
  34281. service.CreateHisPsn(psn)
  34282. return token
  34283. }
  34284. }
  34285. } else {
  34286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  34287. return ""
  34288. }
  34289. } else { //读卡失败
  34290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  34291. return ""
  34292. }
  34293. return token
  34294. }
  34295. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  34296. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  34297. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  34298. var token string
  34299. var api string
  34300. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  34301. "&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
  34302. fmt.Println(api)
  34303. resp, requestErr := http.Get(api)
  34304. if requestErr != nil {
  34305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34306. return ""
  34307. }
  34308. body, ioErr := ioutil.ReadAll(resp.Body)
  34309. if ioErr != nil {
  34310. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34312. return ""
  34313. }
  34314. var respJSON map[string]interface{}
  34315. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34316. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34318. return ""
  34319. }
  34320. var status string
  34321. status = respJSON["data"].(map[string]interface{})["status"].(string)
  34322. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  34323. var res ResultTwo //1101结果
  34324. if status == "1" { //读卡成功
  34325. var card_info string //卡信息
  34326. var busi_card_info string
  34327. token = respJSON["data"].(map[string]interface{})["token"].(string)
  34328. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  34329. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  34330. fmt.Println(card_info)
  34331. fmt.Println(busi_card_info)
  34332. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  34333. result, _ := json.Marshal(respJSON)
  34334. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34335. utils.ErrorLog("解析失败:%v", err)
  34336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34337. return ""
  34338. }
  34339. if res.Infcode == 0 {
  34340. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  34341. if err == gorm.ErrRecordNotFound {
  34342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  34343. return ""
  34344. } else if err != nil {
  34345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  34346. return ""
  34347. } else {
  34348. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  34349. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  34350. infoStr := string(Iinfos)
  34351. idetinfoStr := string(Idetinfos)
  34352. psn := &models.HisPsn{
  34353. PsnNo: res.Output.Baseinfo.PsnNo,
  34354. PatientId: patient.ID,
  34355. Certno: res.Output.Baseinfo.Certno,
  34356. Gend: res.Output.Baseinfo.Gend,
  34357. Naty: res.Output.Baseinfo.Naty,
  34358. PsnCertType: res.Output.Baseinfo.PsnCertType,
  34359. PsnName: res.Output.Baseinfo.PsnName,
  34360. Idetinfo: idetinfoStr,
  34361. Insuinfo: infoStr,
  34362. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  34363. CardInfo: card_info,
  34364. VerifyNumber: token,
  34365. }
  34366. service.CreateHisPsn(psn)
  34367. return token
  34368. }
  34369. }
  34370. } else {
  34371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  34372. return ""
  34373. }
  34374. return token
  34375. }
  34376. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  34377. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  34378. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  34379. var token string
  34380. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34381. var api string
  34382. if miConfig.MdtrtareaAdmvs == "320921" {
  34383. 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 +
  34384. "&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
  34385. fmt.Println(api)
  34386. } else {
  34387. 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 +
  34388. "&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
  34389. }
  34390. resp, requestErr := http.Get(api)
  34391. if requestErr != nil {
  34392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34393. return ""
  34394. }
  34395. body, ioErr := ioutil.ReadAll(resp.Body)
  34396. if ioErr != nil {
  34397. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34399. return ""
  34400. }
  34401. var respJSON map[string]interface{}
  34402. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34403. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34405. return ""
  34406. }
  34407. var status string
  34408. status = respJSON["data"].(map[string]interface{})["status"].(string)
  34409. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  34410. var res ResultTwo //1101结果
  34411. var res10265 ResultTwo10265 //1101结果
  34412. if status == "0" { //读卡成功
  34413. var card_info string //卡信息
  34414. var busi_card_info string
  34415. token = respJSON["data"].(map[string]interface{})["token"].(string)
  34416. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  34417. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  34418. fmt.Println(card_info)
  34419. fmt.Println(busi_card_info)
  34420. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  34421. result, _ := json.Marshal(respJSON)
  34422. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  34423. utils.ErrorLog("解析失败:%v", err)
  34424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34425. return ""
  34426. }
  34427. res.ErrMsg = res10265.ErrMsg
  34428. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  34429. res.Infcode = infocode
  34430. res.Output = res10265.Output
  34431. res.InfRefmsgid = res10265.InfRefmsgid
  34432. if res.Infcode == 0 {
  34433. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  34434. if err == gorm.ErrRecordNotFound {
  34435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  34436. return ""
  34437. } else if err != nil {
  34438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  34439. return ""
  34440. } else {
  34441. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  34442. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  34443. infoStr := string(Iinfos)
  34444. idetinfoStr := string(Idetinfos)
  34445. psn := &models.HisPsn{
  34446. PsnNo: res.Output.Baseinfo.PsnNo,
  34447. PatientId: patient.ID,
  34448. Certno: res.Output.Baseinfo.Certno,
  34449. Gend: res.Output.Baseinfo.Gend,
  34450. Naty: res.Output.Baseinfo.Naty,
  34451. PsnCertType: res.Output.Baseinfo.PsnCertType,
  34452. PsnName: res.Output.Baseinfo.PsnName,
  34453. Idetinfo: idetinfoStr,
  34454. Insuinfo: infoStr,
  34455. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  34456. CardInfo: card_info,
  34457. VerifyNumber: token,
  34458. }
  34459. service.CreateHisPsn(psn)
  34460. return token
  34461. }
  34462. }
  34463. } else {
  34464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  34465. return ""
  34466. }
  34467. } else { //读卡失败
  34468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  34469. return ""
  34470. }
  34471. return token
  34472. }
  34473. func DeleteExtraSpaceTwo(s string) string {
  34474. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  34475. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  34476. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  34477. reg, _ := regexp.Compile(regstr) //编译正则表达式
  34478. s2 := make([]byte, len(s1)) //定义字符数组切片
  34479. copy(s2, s1) //将字符串复制到切片
  34480. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  34481. for len(spc_index) > 0 { //找到适配项
  34482. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  34483. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  34484. }
  34485. return string(s2)
  34486. }
  34487. func Remove0000(s string) string {
  34488. str := make([]rune, 0, len(s))
  34489. for _, v := range []rune(s) {
  34490. if v == 0 {
  34491. continue
  34492. }
  34493. str = append(str, v)
  34494. }
  34495. return string(str)
  34496. }
  34497. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  34498. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  34499. readCard := DllDef.MustFindProc("EcQuery")
  34500. pCardInfo := make([]byte, 8192)
  34501. pBusiCardInfo := make([]byte, 8192)
  34502. data := make(map[string]interface{})
  34503. //pData := make(map[string]interface{})
  34504. inputData := make(map[string]interface{})
  34505. inputData["orgId"] = code
  34506. inputData["businessType"] = "01101"
  34507. inputData["operatorId"] = operator_id
  34508. inputData["operatorName"] = operator_name
  34509. inputData["officeId"] = "001"
  34510. inputData["officeName"] = "血透室"
  34511. //
  34512. data["data"] = inputData
  34513. data["transType"] = "ec.query"
  34514. data["orgId"] = code
  34515. bytesData, _ := json.Marshal(data)
  34516. pCardInfo = bytesData
  34517. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  34518. fmt.Println(ret2)
  34519. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  34520. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  34521. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  34522. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  34523. if ret2 != 0 {
  34524. return "", ""
  34525. }
  34526. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  34527. }
  34528. func DeleteExtraSpace(s string) string {
  34529. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  34530. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  34531. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  34532. reg, _ := regexp.Compile(regstr) //编译正则表达式
  34533. s2 := make([]byte, len(s1)) //定义字符数组切片
  34534. copy(s2, s1) //将字符串复制到切片
  34535. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  34536. for len(spc_index) > 0 { //找到适配项
  34537. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  34538. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  34539. }
  34540. return string(s2)
  34541. }
  34542. // 对账
  34543. func (c *HisApiController) Post3202() {
  34544. start_time := c.GetString("start_time")
  34545. end_time := c.GetString("end_time")
  34546. //insutype := c.GetString("insutype")
  34547. clr_type := c.GetString("clr_type")
  34548. clr_org := c.GetString("clr_optins")
  34549. admin_user_id, _ := c.GetInt64("admin_user_id")
  34550. adminUser := c.GetAdminUserInfo()
  34551. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34552. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34553. if len(clr_org) == 0 {
  34554. clr_org = miConfig.MdtrtareaAdmvs
  34555. }
  34556. timeLayout := "2006-01-02"
  34557. loc, _ := time.LoadLocation("Local")
  34558. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  34559. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  34560. var orders []*models.HisOrder
  34561. if clr_org == "421300" {
  34562. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34563. } else if clr_org == "420902" {
  34564. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34565. } else {
  34566. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34567. }
  34568. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  34569. //fixmedins_setl_cnt := int64(len(orders))
  34570. var medfee_sumamt float64
  34571. var acct_pay float64
  34572. var fund_pay_sumamt float64
  34573. for _, item := range orders {
  34574. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34575. acct_pay = acct_pay + item.AcctPay
  34576. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34577. }
  34578. //var medfee_sumamt_two float64
  34579. //var acct_pay_two float64
  34580. //var fund_pay_sumamt_two float64
  34581. //for _, item := range orders_two {
  34582. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  34583. // acct_pay_two = acct_pay_two + item.AcctPay
  34584. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  34585. //}
  34586. //var user_name string
  34587. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34588. //if role.ID == 0 {
  34589. // user_name = "xxx"
  34590. //} else {
  34591. // user_name = role.UserName
  34592. //}
  34593. var res ResultSix
  34594. if config.IsOpen == 1 {
  34595. var bps []*models.BusinessParamsTwo
  34596. var bp models.BusinessParamsTwo
  34597. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  34598. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  34599. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  34600. bp.MedfeeSumamt = medfee_sumamt_str
  34601. bp.AcctPay = acct_pay_str
  34602. bp.FundPaySumamt = fund_pay_sumamt_str
  34603. bp.Insutype = ""
  34604. bp.StmtBegndate = start_time
  34605. bp.ClrType = clr_type
  34606. bp.SetlOptins = clr_org
  34607. bp.StmtEnddate = end_time
  34608. bps = append(bps, &bp)
  34609. data := make(map[string]interface{})
  34610. data["bps"] = bps
  34611. data["org_name"] = miConfig.OrgName
  34612. data["doctor"] = role.UserName
  34613. data["fixmedins_code"] = miConfig.Code
  34614. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34615. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34616. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  34617. if miConfig.MdtrtareaAdmvs == "421300" {
  34618. client := &http.Client{}
  34619. bytesData, _ := json.Marshal(data)
  34620. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  34621. resp, _ := client.Do(req)
  34622. defer resp.Body.Close()
  34623. body, ioErr := ioutil.ReadAll(resp.Body)
  34624. if ioErr != nil {
  34625. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34627. return
  34628. }
  34629. var respJSON map[string]interface{}
  34630. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34633. return
  34634. }
  34635. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34636. userJSONBytes, _ := json.Marshal(respJSON)
  34637. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34638. utils.ErrorLog("解析失败:%v", err)
  34639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34640. return
  34641. }
  34642. }
  34643. if miConfig.MdtrtareaAdmvs == "420200" {
  34644. client := &http.Client{}
  34645. bytesData, _ := json.Marshal(data)
  34646. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  34647. resp, _ := client.Do(req)
  34648. defer resp.Body.Close()
  34649. body, ioErr := ioutil.ReadAll(resp.Body)
  34650. if ioErr != nil {
  34651. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34653. return
  34654. }
  34655. var respJSON map[string]interface{}
  34656. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34659. return
  34660. }
  34661. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34662. userJSONBytes, _ := json.Marshal(respJSON)
  34663. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34664. utils.ErrorLog("解析失败:%v", err)
  34665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34666. return
  34667. }
  34668. }
  34669. if miConfig.MdtrtareaAdmvs == "421182" {
  34670. client := &http.Client{}
  34671. bytesData, _ := json.Marshal(data)
  34672. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  34673. resp, _ := client.Do(req)
  34674. defer resp.Body.Close()
  34675. body, ioErr := ioutil.ReadAll(resp.Body)
  34676. if ioErr != nil {
  34677. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34679. return
  34680. }
  34681. var respJSON map[string]interface{}
  34682. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34683. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34685. return
  34686. }
  34687. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34688. userJSONBytes, _ := json.Marshal(respJSON)
  34689. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34690. utils.ErrorLog("解析失败:%v", err)
  34691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34692. return
  34693. }
  34694. }
  34695. if miConfig.MdtrtareaAdmvs == "420902" {
  34696. client := &http.Client{}
  34697. bytesData, _ := json.Marshal(data)
  34698. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  34699. resp, _ := client.Do(req)
  34700. defer resp.Body.Close()
  34701. body, ioErr := ioutil.ReadAll(resp.Body)
  34702. if ioErr != nil {
  34703. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34705. return
  34706. }
  34707. var respJSON map[string]interface{}
  34708. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34709. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34711. return
  34712. }
  34713. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34714. userJSONBytes, _ := json.Marshal(respJSON)
  34715. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34716. utils.ErrorLog("解析失败:%v", err)
  34717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34718. return
  34719. }
  34720. }
  34721. if res.Infcode == 0 {
  34722. c.ServeSuccessJSON(map[string]interface{}{
  34723. "msg": "发起成功",
  34724. })
  34725. } else {
  34726. c.ServeSuccessJSON(map[string]interface{}{
  34727. "failed_code": -10,
  34728. "msg": res.ErrMsg,
  34729. })
  34730. }
  34731. }
  34732. }
  34733. func (c *HisApiController) Post3204a() {
  34734. start_time := c.GetString("start_time")
  34735. end_time := c.GetString("end_time")
  34736. //insutype := c.GetString("insutype")
  34737. clr_type := c.GetString("clr_type")
  34738. clr_org := c.GetString("clr_optins")
  34739. admin_user_id, _ := c.GetInt64("admin_user_id")
  34740. adminUser := c.GetAdminUserInfo()
  34741. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34742. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34743. if len(clr_org) == 0 {
  34744. clr_org = miConfig.MdtrtareaAdmvs
  34745. }
  34746. timeLayout := "2006-01-02"
  34747. loc, _ := time.LoadLocation("Local")
  34748. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  34749. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  34750. var orders []*models.HisOrder
  34751. if clr_org == "421300" {
  34752. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34753. } else if clr_org == "420902" {
  34754. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34755. } else {
  34756. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34757. }
  34758. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  34759. //fixmedins_setl_cnt := int64(len(orders))
  34760. var medfee_sumamt float64
  34761. var acct_pay float64
  34762. var fund_pay_sumamt float64
  34763. for _, item := range orders {
  34764. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34765. acct_pay = acct_pay + item.AcctPay
  34766. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34767. }
  34768. //var medfee_sumamt_two float64
  34769. //var acct_pay_two float64
  34770. //var fund_pay_sumamt_two float64
  34771. //for _, item := range orders_two {
  34772. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  34773. // acct_pay_two = acct_pay_two + item.AcctPay
  34774. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  34775. //}
  34776. //var user_name string
  34777. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34778. //if role.ID == 0 {
  34779. // user_name = "xxx"
  34780. //} else {
  34781. // user_name = role.UserName
  34782. //}
  34783. var res ResultSix
  34784. if config.IsOpen == 1 {
  34785. var bps []*models.BusinessParamsTwo
  34786. var bp models.BusinessParamsTwo
  34787. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  34788. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  34789. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  34790. bp.MedfeeSumamt = medfee_sumamt_str
  34791. bp.AcctPay = acct_pay_str
  34792. bp.FundPaySumamt = fund_pay_sumamt_str
  34793. bp.Insutype = ""
  34794. bp.StmtBegndate = start_time
  34795. bp.ClrType = clr_type
  34796. bp.SetlOptins = clr_org
  34797. bp.StmtEnddate = end_time
  34798. bps = append(bps, &bp)
  34799. data := make(map[string]interface{})
  34800. data["bps"] = bps
  34801. data["org_name"] = miConfig.OrgName
  34802. data["doctor"] = role.UserName
  34803. data["fixmedins_code"] = miConfig.Code
  34804. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34805. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34806. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  34807. if miConfig.MdtrtareaAdmvs == "421300" {
  34808. client := &http.Client{}
  34809. bytesData, _ := json.Marshal(data)
  34810. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  34811. resp, _ := client.Do(req)
  34812. defer resp.Body.Close()
  34813. body, ioErr := ioutil.ReadAll(resp.Body)
  34814. if ioErr != nil {
  34815. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34817. return
  34818. }
  34819. var respJSON map[string]interface{}
  34820. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34823. return
  34824. }
  34825. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34826. userJSONBytes, _ := json.Marshal(respJSON)
  34827. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34828. utils.ErrorLog("解析失败:%v", err)
  34829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34830. return
  34831. }
  34832. }
  34833. if miConfig.MdtrtareaAdmvs == "420200" {
  34834. client := &http.Client{}
  34835. bytesData, _ := json.Marshal(data)
  34836. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  34837. resp, _ := client.Do(req)
  34838. defer resp.Body.Close()
  34839. body, ioErr := ioutil.ReadAll(resp.Body)
  34840. if ioErr != nil {
  34841. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34843. return
  34844. }
  34845. var respJSON map[string]interface{}
  34846. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34847. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34849. return
  34850. }
  34851. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34852. userJSONBytes, _ := json.Marshal(respJSON)
  34853. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34854. utils.ErrorLog("解析失败:%v", err)
  34855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34856. return
  34857. }
  34858. }
  34859. if miConfig.MdtrtareaAdmvs == "421182" {
  34860. client := &http.Client{}
  34861. bytesData, _ := json.Marshal(data)
  34862. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  34863. resp, _ := client.Do(req)
  34864. defer resp.Body.Close()
  34865. body, ioErr := ioutil.ReadAll(resp.Body)
  34866. if ioErr != nil {
  34867. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34869. return
  34870. }
  34871. var respJSON map[string]interface{}
  34872. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34873. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34875. return
  34876. }
  34877. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34878. userJSONBytes, _ := json.Marshal(respJSON)
  34879. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34880. utils.ErrorLog("解析失败:%v", err)
  34881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34882. return
  34883. }
  34884. }
  34885. if miConfig.MdtrtareaAdmvs == "420902" {
  34886. client := &http.Client{}
  34887. bytesData, _ := json.Marshal(data)
  34888. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  34889. resp, _ := client.Do(req)
  34890. defer resp.Body.Close()
  34891. body, ioErr := ioutil.ReadAll(resp.Body)
  34892. if ioErr != nil {
  34893. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34895. return
  34896. }
  34897. var respJSON map[string]interface{}
  34898. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34899. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34901. return
  34902. }
  34903. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34904. userJSONBytes, _ := json.Marshal(respJSON)
  34905. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34906. utils.ErrorLog("解析失败:%v", err)
  34907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34908. return
  34909. }
  34910. }
  34911. if res.Infcode == 0 {
  34912. c.ServeSuccessJSON(map[string]interface{}{
  34913. "msg": "撤销成功",
  34914. })
  34915. } else {
  34916. c.ServeSuccessJSON(map[string]interface{}{
  34917. "failed_code": -10,
  34918. "msg": res.ErrMsg,
  34919. })
  34920. }
  34921. }
  34922. }
  34923. func (c *HisApiController) Post3204() {
  34924. admin_user_id, _ := c.GetInt64("admin_user_id")
  34925. id := c.GetString("id")
  34926. adminUser := c.GetAdminUserInfo()
  34927. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34928. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34929. //clr_org := miConfig.MdtrtareaAdmvs
  34930. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34931. var res ResultSix
  34932. if config.IsOpen == 1 {
  34933. data := make(map[string]interface{})
  34934. data["id"] = id
  34935. data["org_name"] = miConfig.OrgName
  34936. data["doctor"] = role.UserName
  34937. data["fixmedins_code"] = miConfig.Code
  34938. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34939. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  34940. client := &http.Client{}
  34941. bytesData, _ := json.Marshal(data)
  34942. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  34943. resp, _ := client.Do(req)
  34944. defer resp.Body.Close()
  34945. body, ioErr := ioutil.ReadAll(resp.Body)
  34946. if ioErr != nil {
  34947. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34949. return
  34950. }
  34951. var respJSON map[string]interface{}
  34952. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34953. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34955. return
  34956. }
  34957. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34958. userJSONBytes, _ := json.Marshal(respJSON)
  34959. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34960. utils.ErrorLog("解析失败:%v", err)
  34961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34962. return
  34963. }
  34964. if res.Infcode == 0 {
  34965. c.ServeSuccessJSON(map[string]interface{}{
  34966. "msg": "发起成功",
  34967. })
  34968. } else {
  34969. c.ServeSuccessJSON(map[string]interface{}{
  34970. "failed_code": -10,
  34971. "msg": res.ErrMsg,
  34972. })
  34973. }
  34974. }
  34975. }
  34976. func (c *HisApiController) Post8404() {
  34977. admin_user_id, _ := c.GetInt64("admin_user_id")
  34978. month := c.GetString("month")
  34979. adminUser := c.GetAdminUserInfo()
  34980. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34981. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34982. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34983. var res ResultSix
  34984. if config.IsOpen == 1 {
  34985. data := make(map[string]interface{})
  34986. data["month"] = month
  34987. data["org_name"] = miConfig.OrgName
  34988. data["doctor"] = role.UserName
  34989. data["fixmedins_code"] = miConfig.Code
  34990. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34991. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  34992. client := &http.Client{}
  34993. bytesData, _ := json.Marshal(data)
  34994. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  34995. resp, _ := client.Do(req)
  34996. defer resp.Body.Close()
  34997. body, ioErr := ioutil.ReadAll(resp.Body)
  34998. if ioErr != nil {
  34999. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35001. return
  35002. }
  35003. var respJSON map[string]interface{}
  35004. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35005. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35007. return
  35008. }
  35009. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35010. userJSONBytes, _ := json.Marshal(respJSON)
  35011. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35012. utils.ErrorLog("解析失败:%v", err)
  35013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35014. return
  35015. }
  35016. if res.Infcode == 0 {
  35017. c.ServeSuccessJSON(map[string]interface{}{
  35018. "msg": "查询成功",
  35019. })
  35020. } else {
  35021. c.ServeSuccessJSON(map[string]interface{}{
  35022. "failed_code": -10,
  35023. "msg": res.ErrMsg,
  35024. })
  35025. }
  35026. }
  35027. }
  35028. func (c *HisApiController) Post3202b() {
  35029. start_time := c.GetString("start_time")
  35030. end_time := c.GetString("end_time")
  35031. //insutype := c.GetString("insutype")
  35032. clr_type := c.GetString("clr_type")
  35033. clr_org := c.GetString("clr_optins")
  35034. admin_user_id, _ := c.GetInt64("admin_user_id")
  35035. adminUser := c.GetAdminUserInfo()
  35036. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35037. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35038. if len(clr_org) == 0 {
  35039. clr_org = miConfig.MdtrtareaAdmvs
  35040. }
  35041. timeLayout := "2006-01-02"
  35042. loc, _ := time.LoadLocation("Local")
  35043. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  35044. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  35045. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  35046. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  35047. //fixmedins_setl_cnt := int64(len(orders))
  35048. var medfee_sumamt float64
  35049. var acct_pay float64
  35050. var fund_pay_sumamt float64
  35051. for _, item := range orders {
  35052. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35053. acct_pay = acct_pay + item.AcctPay
  35054. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35055. }
  35056. //var medfee_sumamt_two float64
  35057. //var acct_pay_two float64
  35058. //var fund_pay_sumamt_two float64
  35059. //for _, item := range orders_two {
  35060. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  35061. // acct_pay_two = acct_pay_two + item.AcctPay
  35062. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  35063. //}
  35064. //var user_name string
  35065. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35066. //if role.ID == 0 {
  35067. // user_name = "xxx"
  35068. //} else {
  35069. // user_name = role.UserName
  35070. //}
  35071. var res ResultSix
  35072. if config.IsOpen == 1 {
  35073. var bps []*models.BusinessParamsTwo
  35074. var bp models.BusinessParamsTwo
  35075. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  35076. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  35077. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  35078. bp.MedfeeSumamt = medfee_sumamt_str
  35079. bp.AcctPay = acct_pay_str
  35080. bp.FundPaySumamt = fund_pay_sumamt_str
  35081. bp.Insutype = "390"
  35082. bp.StmtBegndate = start_time
  35083. bp.ClrType = clr_type
  35084. bp.SetlOptins = clr_org
  35085. bp.StmtEnddate = end_time
  35086. bps = append(bps, &bp)
  35087. data := make(map[string]interface{})
  35088. data["bps"] = bps
  35089. data["org_name"] = miConfig.OrgName
  35090. data["doctor"] = role.UserName
  35091. data["fixmedins_code"] = miConfig.Code
  35092. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35093. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35094. if miConfig.MdtrtareaAdmvs == "421300" {
  35095. client := &http.Client{}
  35096. bytesData, _ := json.Marshal(data)
  35097. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  35098. resp, _ := client.Do(req)
  35099. defer resp.Body.Close()
  35100. body, ioErr := ioutil.ReadAll(resp.Body)
  35101. if ioErr != nil {
  35102. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35104. return
  35105. }
  35106. var respJSON map[string]interface{}
  35107. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35108. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35110. return
  35111. }
  35112. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35113. userJSONBytes, _ := json.Marshal(respJSON)
  35114. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35115. utils.ErrorLog("解析失败:%v", err)
  35116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35117. return
  35118. }
  35119. }
  35120. if miConfig.MdtrtareaAdmvs == "420200" {
  35121. client := &http.Client{}
  35122. bytesData, _ := json.Marshal(data)
  35123. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  35124. resp, _ := client.Do(req)
  35125. defer resp.Body.Close()
  35126. body, ioErr := ioutil.ReadAll(resp.Body)
  35127. if ioErr != nil {
  35128. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35130. return
  35131. }
  35132. var respJSON map[string]interface{}
  35133. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35134. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35136. return
  35137. }
  35138. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35139. userJSONBytes, _ := json.Marshal(respJSON)
  35140. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35141. utils.ErrorLog("解析失败:%v", err)
  35142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35143. return
  35144. }
  35145. }
  35146. if miConfig.MdtrtareaAdmvs == "421182" {
  35147. client := &http.Client{}
  35148. bytesData, _ := json.Marshal(data)
  35149. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  35150. resp, _ := client.Do(req)
  35151. defer resp.Body.Close()
  35152. body, ioErr := ioutil.ReadAll(resp.Body)
  35153. if ioErr != nil {
  35154. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35156. return
  35157. }
  35158. var respJSON map[string]interface{}
  35159. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35160. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35162. return
  35163. }
  35164. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35165. userJSONBytes, _ := json.Marshal(respJSON)
  35166. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35167. utils.ErrorLog("解析失败:%v", err)
  35168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35169. return
  35170. }
  35171. }
  35172. if res.Infcode == 0 {
  35173. c.ServeSuccessJSON(map[string]interface{}{
  35174. "msg": "发起成功",
  35175. })
  35176. } else {
  35177. c.ServeSuccessJSON(map[string]interface{}{
  35178. "failed_code": -10,
  35179. "msg": res.ErrMsg,
  35180. })
  35181. }
  35182. }
  35183. }
  35184. func (c *HisApiController) Post1608() {
  35185. start_time := c.GetString("start_time")
  35186. end_time := c.GetString("end_time")
  35187. admin_user_id, _ := c.GetInt64("admin_user_id")
  35188. adminUser := c.GetAdminUserInfo()
  35189. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35190. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35191. timeLayout := "2006-01-02"
  35192. loc, _ := time.LoadLocation("Local")
  35193. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  35194. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  35195. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  35196. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  35197. fixmedins_setl_cnt := int64(len(orders))
  35198. var medfee_sumamt float64
  35199. var func_smamt float64
  35200. for _, item := range orders {
  35201. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35202. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  35203. }
  35204. times := strings.Split(start_time, "-")
  35205. time_tows := strings.Split(end_time, "-")
  35206. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35207. var res ResultSix
  35208. if config.IsOpen == 1 {
  35209. //var bps []*models.BusinessParamsTwo
  35210. //var bp models.BusinessParamsTwo
  35211. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  35212. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  35213. data := make(map[string]interface{})
  35214. data["org_name"] = miConfig.OrgName
  35215. data["doctor"] = role.UserName
  35216. data["func_smamt"] = func_smamt_str
  35217. data["fixmedins_code"] = miConfig.Code
  35218. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35219. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35220. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  35221. data["medfee_sumamt"] = medfee_sumamt_str
  35222. data["start_time"] = times[0] + times[1] + times[2]
  35223. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  35224. if miConfig.MdtrtareaAdmvs == "421300" {
  35225. client := &http.Client{}
  35226. bytesData, _ := json.Marshal(data)
  35227. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  35228. resp, _ := client.Do(req)
  35229. defer resp.Body.Close()
  35230. body, ioErr := ioutil.ReadAll(resp.Body)
  35231. if ioErr != nil {
  35232. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35234. return
  35235. }
  35236. var respJSON map[string]interface{}
  35237. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35238. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35240. return
  35241. }
  35242. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35243. userJSONBytes, _ := json.Marshal(respJSON)
  35244. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35245. utils.ErrorLog("解析失败:%v", err)
  35246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35247. return
  35248. }
  35249. }
  35250. if miConfig.MdtrtareaAdmvs == "420200" {
  35251. client := &http.Client{}
  35252. bytesData, _ := json.Marshal(data)
  35253. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  35254. resp, _ := client.Do(req)
  35255. defer resp.Body.Close()
  35256. body, ioErr := ioutil.ReadAll(resp.Body)
  35257. if ioErr != nil {
  35258. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35260. return
  35261. }
  35262. var respJSON map[string]interface{}
  35263. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35264. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35266. return
  35267. }
  35268. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35269. userJSONBytes, _ := json.Marshal(respJSON)
  35270. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35271. utils.ErrorLog("解析失败:%v", err)
  35272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35273. return
  35274. }
  35275. }
  35276. if miConfig.MdtrtareaAdmvs == "421182" {
  35277. client := &http.Client{}
  35278. bytesData, _ := json.Marshal(data)
  35279. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  35280. resp, _ := client.Do(req)
  35281. defer resp.Body.Close()
  35282. body, ioErr := ioutil.ReadAll(resp.Body)
  35283. if ioErr != nil {
  35284. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35286. return
  35287. }
  35288. var respJSON map[string]interface{}
  35289. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35290. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35292. return
  35293. }
  35294. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35295. userJSONBytes, _ := json.Marshal(respJSON)
  35296. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35297. utils.ErrorLog("解析失败:%v", err)
  35298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35299. return
  35300. }
  35301. }
  35302. if res.Infcode == 0 {
  35303. c.ServeSuccessJSON(map[string]interface{}{
  35304. "msg": "发起成功",
  35305. })
  35306. } else {
  35307. c.ServeSuccessJSON(map[string]interface{}{
  35308. "failed_code": -10,
  35309. "msg": res.ErrMsg,
  35310. })
  35311. }
  35312. }
  35313. }
  35314. // 5.11.1.1【5262】结算信息按时间段查询
  35315. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  35316. admin_user_id, _ := c.GetInt64("admin_user_id")
  35317. adminUser := c.GetAdminUserInfo()
  35318. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35319. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35320. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35321. var res Result5262
  35322. if config.IsOpen == 1 {
  35323. if miConfig.MdtrtareaAdmvs == "421300" {
  35324. data := make(map[string]interface{})
  35325. data["bps"] = bp
  35326. data["org_name"] = miConfig.OrgName
  35327. data["doctor"] = role.UserName
  35328. data["fixmedins_code"] = miConfig.Code
  35329. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35330. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35331. data["page"] = strconv.FormatInt(page, 10)
  35332. data["limit"] = strconv.FormatInt(limit, 10)
  35333. fmt.Println(data)
  35334. client := &http.Client{}
  35335. bytesData, _ := json.Marshal(data)
  35336. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  35337. resp, _ := client.Do(req)
  35338. defer resp.Body.Close()
  35339. body, ioErr := ioutil.ReadAll(resp.Body)
  35340. if ioErr != nil {
  35341. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35343. return
  35344. }
  35345. var respJSON map[string]interface{}
  35346. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35347. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35349. return
  35350. }
  35351. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35352. userJSONBytes, _ := json.Marshal(respJSON)
  35353. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35354. utils.ErrorLog("解析失败:%v", err)
  35355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35356. return
  35357. }
  35358. }
  35359. if miConfig.MdtrtareaAdmvs == "420200" {
  35360. data := make(map[string]interface{})
  35361. data["bps"] = bp
  35362. data["org_name"] = miConfig.OrgName
  35363. data["doctor"] = role.UserName
  35364. data["fixmedins_code"] = miConfig.Code
  35365. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35366. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35367. data["page"] = strconv.FormatInt(page, 10)
  35368. data["limit"] = strconv.FormatInt(limit, 10)
  35369. fmt.Println(data)
  35370. client := &http.Client{}
  35371. bytesData, _ := json.Marshal(data)
  35372. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  35373. resp, _ := client.Do(req)
  35374. defer resp.Body.Close()
  35375. body, ioErr := ioutil.ReadAll(resp.Body)
  35376. if ioErr != nil {
  35377. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35379. return
  35380. }
  35381. var respJSON map[string]interface{}
  35382. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35383. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35385. return
  35386. }
  35387. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35388. userJSONBytes, _ := json.Marshal(respJSON)
  35389. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35390. utils.ErrorLog("解析失败:%v", err)
  35391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35392. return
  35393. }
  35394. }
  35395. if miConfig.MdtrtareaAdmvs == "421182" {
  35396. data := make(map[string]interface{})
  35397. data["bps"] = bp
  35398. data["org_name"] = miConfig.OrgName
  35399. data["doctor"] = role.UserName
  35400. data["fixmedins_code"] = miConfig.Code
  35401. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35402. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35403. data["page"] = strconv.FormatInt(page, 10)
  35404. data["limit"] = strconv.FormatInt(limit, 10)
  35405. fmt.Println(data)
  35406. client := &http.Client{}
  35407. bytesData, _ := json.Marshal(data)
  35408. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  35409. resp, _ := client.Do(req)
  35410. defer resp.Body.Close()
  35411. body, ioErr := ioutil.ReadAll(resp.Body)
  35412. if ioErr != nil {
  35413. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35415. return
  35416. }
  35417. var respJSON map[string]interface{}
  35418. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35419. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35421. return
  35422. }
  35423. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35424. userJSONBytes, _ := json.Marshal(respJSON)
  35425. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35426. utils.ErrorLog("解析失败:%v", err)
  35427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35428. return
  35429. }
  35430. }
  35431. if miConfig.MdtrtareaAdmvs == "420902" {
  35432. data := make(map[string]interface{})
  35433. data["bps"] = bp
  35434. data["org_name"] = miConfig.OrgName
  35435. data["doctor"] = role.UserName
  35436. data["fixmedins_code"] = miConfig.Code
  35437. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35438. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35439. data["page"] = strconv.FormatInt(page, 10)
  35440. data["limit"] = strconv.FormatInt(limit, 10)
  35441. fmt.Println(data)
  35442. client := &http.Client{}
  35443. bytesData, _ := json.Marshal(data)
  35444. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  35445. resp, _ := client.Do(req)
  35446. defer resp.Body.Close()
  35447. body, ioErr := ioutil.ReadAll(resp.Body)
  35448. if ioErr != nil {
  35449. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35451. return
  35452. }
  35453. var respJSON map[string]interface{}
  35454. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35455. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35457. return
  35458. }
  35459. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35460. userJSONBytes, _ := json.Marshal(respJSON)
  35461. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35462. utils.ErrorLog("解析失败:%v", err)
  35463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35464. return
  35465. }
  35466. }
  35467. if res.Infcode == 0 {
  35468. c.ServeSuccessJSON(map[string]interface{}{
  35469. "order": res.Output.Result,
  35470. "total": res.Output.PageInfo.RecordCounts,
  35471. })
  35472. } else {
  35473. c.ServeSuccessJSON(map[string]interface{}{
  35474. "failed_code": -10,
  35475. "msg": res.ErrMsg,
  35476. })
  35477. }
  35478. }
  35479. }
  35480. // 5.11.1.2【5267】异地结算信息时间段查询
  35481. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  35482. admin_user_id, _ := c.GetInt64("admin_user_id")
  35483. adminUser := c.GetAdminUserInfo()
  35484. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35485. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35486. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35487. var res Result5267
  35488. if config.IsOpen == 1 {
  35489. if miConfig.MdtrtareaAdmvs == "421300" {
  35490. data := make(map[string]interface{})
  35491. data["bps"] = bp
  35492. data["org_name"] = miConfig.OrgName
  35493. data["doctor"] = role.UserName
  35494. data["fixmedins_code"] = miConfig.Code
  35495. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35496. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35497. data["page"] = page
  35498. data["limit"] = limit
  35499. fmt.Println(data)
  35500. client := &http.Client{}
  35501. bytesData, _ := json.Marshal(data)
  35502. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  35503. resp, _ := client.Do(req)
  35504. defer resp.Body.Close()
  35505. body, ioErr := ioutil.ReadAll(resp.Body)
  35506. if ioErr != nil {
  35507. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35509. return
  35510. }
  35511. var respJSON map[string]interface{}
  35512. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35513. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35515. return
  35516. }
  35517. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35518. userJSONBytes, _ := json.Marshal(respJSON)
  35519. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35520. utils.ErrorLog("解析失败:%v", err)
  35521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35522. return
  35523. }
  35524. }
  35525. if miConfig.MdtrtareaAdmvs == "420200" {
  35526. data := make(map[string]interface{})
  35527. data["bps"] = bp
  35528. data["org_name"] = miConfig.OrgName
  35529. data["doctor"] = role.UserName
  35530. data["fixmedins_code"] = miConfig.Code
  35531. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35532. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35533. data["page"] = page
  35534. data["limit"] = limit
  35535. fmt.Println(data)
  35536. client := &http.Client{}
  35537. bytesData, _ := json.Marshal(data)
  35538. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  35539. resp, _ := client.Do(req)
  35540. defer resp.Body.Close()
  35541. body, ioErr := ioutil.ReadAll(resp.Body)
  35542. if ioErr != nil {
  35543. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35545. return
  35546. }
  35547. var respJSON map[string]interface{}
  35548. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35549. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35551. return
  35552. }
  35553. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35554. userJSONBytes, _ := json.Marshal(respJSON)
  35555. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35556. utils.ErrorLog("解析失败:%v", err)
  35557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35558. return
  35559. }
  35560. }
  35561. if miConfig.MdtrtareaAdmvs == "421182" {
  35562. data := make(map[string]interface{})
  35563. data["bps"] = bp
  35564. data["org_name"] = miConfig.OrgName
  35565. data["doctor"] = role.UserName
  35566. data["fixmedins_code"] = miConfig.Code
  35567. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35568. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35569. data["page"] = page
  35570. data["limit"] = limit
  35571. fmt.Println(data)
  35572. client := &http.Client{}
  35573. bytesData, _ := json.Marshal(data)
  35574. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  35575. resp, _ := client.Do(req)
  35576. defer resp.Body.Close()
  35577. body, ioErr := ioutil.ReadAll(resp.Body)
  35578. if ioErr != nil {
  35579. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35581. return
  35582. }
  35583. var respJSON map[string]interface{}
  35584. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35587. return
  35588. }
  35589. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35590. userJSONBytes, _ := json.Marshal(respJSON)
  35591. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35592. utils.ErrorLog("解析失败:%v", err)
  35593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35594. return
  35595. }
  35596. }
  35597. if res.Infcode == 0 {
  35598. c.ServeSuccessJSON(map[string]interface{}{
  35599. "order": res.Output.Result,
  35600. "total": res.Output.PageInfo.RecordCounts,
  35601. })
  35602. } else {
  35603. c.ServeSuccessJSON(map[string]interface{}{
  35604. "failed_code": -10,
  35605. "msg": res.ErrMsg,
  35606. })
  35607. }
  35608. }
  35609. }
  35610. func (c *HisApiController) Post3501() {
  35611. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35612. data := make(map[string]interface{})
  35613. var struct3501s []models.Struct3501
  35614. var struct3501 models.Struct3501
  35615. struct3501.OrgName = miConfig.OrgName
  35616. struct3501.AccessKey = miConfig.AccessKey
  35617. struct3501.RequestUrl = miConfig.Url
  35618. struct3501.SecretKey = miConfig.SecretKey
  35619. struct3501.ManuDate = "2022-08-17"
  35620. struct3501.FixmedinsBchno = ""
  35621. struct3501.ManuLotnum = ""
  35622. struct3501.RxFlag = "0"
  35623. struct3501.ExpyEnd = "2022-08-17"
  35624. struct3501.Invdate = "2022-08-17"
  35625. struct3501.InvCnt = "20.25"
  35626. struct3501.Memo = ""
  35627. struct3501.MedListCodg = "XB01ABD056B002020200517"
  35628. struct3501.FixmedinsHilistId = miConfig.Code
  35629. struct3501.FixmedinsHilistName = miConfig.OrgName
  35630. struct3501s = append(struct3501s, struct3501)
  35631. data["struct_3501s"] = struct3501s
  35632. client := &http.Client{}
  35633. bytesData, _ := json.Marshal(data)
  35634. var req *http.Request
  35635. if miConfig.MdtrtareaAdmvs == "320921" {
  35636. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35637. } else {
  35638. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35639. }
  35640. resp, _ := client.Do(req)
  35641. defer resp.Body.Close()
  35642. body, ioErr := ioutil.ReadAll(resp.Body)
  35643. if ioErr != nil {
  35644. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35646. return
  35647. }
  35648. var respJSON map[string]interface{}
  35649. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35650. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35652. return
  35653. }
  35654. var res ResultSix
  35655. var resSix10265 ResultSix10265 //1101结果
  35656. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  35657. result, _ := json.Marshal(respJSON)
  35658. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  35659. utils.ErrorLog("解析失败:%v", err)
  35660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35661. return
  35662. }
  35663. res.InfRefmsgid = resSix10265.InfRefmsgid
  35664. res.Output = resSix10265.Output
  35665. res.ErrMsg = resSix10265.ErrMsg
  35666. res.Cainfo = resSix10265.Cainfo
  35667. res.WarnMsg = resSix10265.WarnMsg
  35668. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35669. res.Infcode = infocode
  35670. if infocode == 0 {
  35671. c.ServeSuccessJSON(map[string]interface{}{
  35672. "msg": "上传成功",
  35673. })
  35674. return
  35675. } else {
  35676. c.ServeSuccessJSON(map[string]interface{}{
  35677. "failed_code": -10,
  35678. "msg": res.ErrMsg,
  35679. })
  35680. return
  35681. }
  35682. }
  35683. func (c *HisApiController) Post3502() {
  35684. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35685. data := make(map[string]interface{})
  35686. var struct3502s []models.Struct3502
  35687. var struct3502 models.Struct3502
  35688. struct3502.OrgName = miConfig.OrgName
  35689. struct3502.AccessKey = miConfig.AccessKey
  35690. struct3502.RequestUrl = miConfig.Url
  35691. struct3502.SecretKey = miConfig.SecretKey
  35692. struct3502.ManuDate = "2022-08-15"
  35693. struct3502.FixmedinsBchno = ""
  35694. struct3502.ManuLotnum = ""
  35695. struct3502.RxFlag = "0"
  35696. struct3502.ExpyEnd = "2022-08-15"
  35697. struct3502.Invdate = "2022-08-15"
  35698. struct3502.InvCnt = "20.25"
  35699. struct3502.Memo = ""
  35700. struct3502.MedListCodg = "XB01ABD056B002020200517"
  35701. struct3502.FixmedinsHilistId = miConfig.Code
  35702. struct3502.FixmedinsHilistName = miConfig.OrgName
  35703. struct3502s = append(struct3502s, struct3502)
  35704. data["struct_3502s"] = struct3502s
  35705. client := &http.Client{}
  35706. bytesData, _ := json.Marshal(data)
  35707. var req *http.Request
  35708. if miConfig.MdtrtareaAdmvs == "320921" {
  35709. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35710. } else {
  35711. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35712. }
  35713. resp, _ := client.Do(req)
  35714. defer resp.Body.Close()
  35715. body, ioErr := ioutil.ReadAll(resp.Body)
  35716. if ioErr != nil {
  35717. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35719. return
  35720. }
  35721. var respJSON map[string]interface{}
  35722. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35723. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35725. return
  35726. }
  35727. var res ResultSix
  35728. var resSix10265 ResultSix10265 //1101结果
  35729. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  35730. result, _ := json.Marshal(respJSON)
  35731. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  35732. utils.ErrorLog("解析失败:%v", err)
  35733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35734. return
  35735. }
  35736. res.InfRefmsgid = resSix10265.InfRefmsgid
  35737. res.Output = resSix10265.Output
  35738. res.ErrMsg = resSix10265.ErrMsg
  35739. res.Cainfo = resSix10265.Cainfo
  35740. res.WarnMsg = resSix10265.WarnMsg
  35741. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35742. res.Infcode = infocode
  35743. if infocode == 0 {
  35744. c.ServeSuccessJSON(map[string]interface{}{
  35745. "msg": "上传成功",
  35746. })
  35747. return
  35748. } else {
  35749. c.ServeSuccessJSON(map[string]interface{}{
  35750. "failed_code": -10,
  35751. "msg": res.ErrMsg,
  35752. })
  35753. return
  35754. }
  35755. }
  35756. func (c *HisApiController) Post3503() {
  35757. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35758. data := make(map[string]interface{})
  35759. var struct3501s []models.Struct3501
  35760. var struct3501 models.Struct3501
  35761. struct3501.OrgName = miConfig.OrgName
  35762. struct3501.AccessKey = miConfig.AccessKey
  35763. struct3501.RequestUrl = miConfig.Url
  35764. struct3501.SecretKey = miConfig.SecretKey
  35765. struct3501.ManuDate = "2022-08-15"
  35766. struct3501.FixmedinsBchno = ""
  35767. struct3501.ManuLotnum = ""
  35768. struct3501.RxFlag = "0"
  35769. struct3501.ExpyEnd = "2022-08-15"
  35770. struct3501.Invdate = "2022-08-15"
  35771. struct3501.InvCnt = "20.25"
  35772. struct3501.Memo = ""
  35773. struct3501.MedListCodg = "XB01ABD056B002020200517"
  35774. struct3501.FixmedinsHilistId = miConfig.Code
  35775. struct3501.FixmedinsHilistName = miConfig.OrgName
  35776. struct3501s = append(struct3501s, struct3501)
  35777. data["struct_3501s"] = struct3501s
  35778. client := &http.Client{}
  35779. bytesData, _ := json.Marshal(data)
  35780. var req *http.Request
  35781. if miConfig.MdtrtareaAdmvs == "320921" {
  35782. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35783. } else {
  35784. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35785. }
  35786. resp, _ := client.Do(req)
  35787. defer resp.Body.Close()
  35788. body, ioErr := ioutil.ReadAll(resp.Body)
  35789. if ioErr != nil {
  35790. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35792. return
  35793. }
  35794. var respJSON map[string]interface{}
  35795. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35798. return
  35799. }
  35800. var res ResultSix
  35801. var resSix10265 ResultSix10265 //1101结果
  35802. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  35803. result, _ := json.Marshal(respJSON)
  35804. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  35805. utils.ErrorLog("解析失败:%v", err)
  35806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35807. return
  35808. }
  35809. res.InfRefmsgid = resSix10265.InfRefmsgid
  35810. res.Output = resSix10265.Output
  35811. res.ErrMsg = resSix10265.ErrMsg
  35812. res.Cainfo = resSix10265.Cainfo
  35813. res.WarnMsg = resSix10265.WarnMsg
  35814. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35815. res.Infcode = infocode
  35816. if infocode == 0 {
  35817. c.ServeSuccessJSON(map[string]interface{}{
  35818. "msg": "上传成功",
  35819. })
  35820. return
  35821. } else {
  35822. c.ServeSuccessJSON(map[string]interface{}{
  35823. "failed_code": -10,
  35824. "msg": res.ErrMsg,
  35825. })
  35826. return
  35827. }
  35828. }
  35829. func (c *HisApiController) Post3504() {
  35830. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35831. data := make(map[string]interface{})
  35832. var struct3501s []models.Struct3501
  35833. var struct3501 models.Struct3501
  35834. struct3501.OrgName = miConfig.OrgName
  35835. struct3501.AccessKey = miConfig.AccessKey
  35836. struct3501.RequestUrl = miConfig.Url
  35837. struct3501.SecretKey = miConfig.SecretKey
  35838. struct3501.ManuDate = "2022-08-15"
  35839. struct3501.FixmedinsBchno = ""
  35840. struct3501.ManuLotnum = ""
  35841. struct3501.RxFlag = "0"
  35842. struct3501.ExpyEnd = "2022-08-15"
  35843. struct3501.Invdate = "2022-08-15"
  35844. struct3501.InvCnt = "20.25"
  35845. struct3501.Memo = ""
  35846. struct3501.MedListCodg = "XB01ABD056B002020200517"
  35847. struct3501.FixmedinsHilistId = miConfig.Code
  35848. struct3501.FixmedinsHilistName = miConfig.OrgName
  35849. struct3501s = append(struct3501s, struct3501)
  35850. data["struct_3501s"] = struct3501s
  35851. client := &http.Client{}
  35852. bytesData, _ := json.Marshal(data)
  35853. var req *http.Request
  35854. if miConfig.MdtrtareaAdmvs == "320921" {
  35855. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35856. } else {
  35857. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35858. }
  35859. resp, _ := client.Do(req)
  35860. defer resp.Body.Close()
  35861. body, ioErr := ioutil.ReadAll(resp.Body)
  35862. if ioErr != nil {
  35863. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35865. return
  35866. }
  35867. var respJSON map[string]interface{}
  35868. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35869. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35871. return
  35872. }
  35873. var res ResultSix
  35874. var resSix10265 ResultSix10265 //1101结果
  35875. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  35876. result, _ := json.Marshal(respJSON)
  35877. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  35878. utils.ErrorLog("解析失败:%v", err)
  35879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35880. return
  35881. }
  35882. res.InfRefmsgid = resSix10265.InfRefmsgid
  35883. res.Output = resSix10265.Output
  35884. res.ErrMsg = resSix10265.ErrMsg
  35885. res.Cainfo = resSix10265.Cainfo
  35886. res.WarnMsg = resSix10265.WarnMsg
  35887. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35888. res.Infcode = infocode
  35889. if infocode == 0 {
  35890. c.ServeSuccessJSON(map[string]interface{}{
  35891. "msg": "上传成功",
  35892. })
  35893. return
  35894. } else {
  35895. c.ServeSuccessJSON(map[string]interface{}{
  35896. "failed_code": -10,
  35897. "msg": res.ErrMsg,
  35898. })
  35899. return
  35900. }
  35901. }
  35902. func (c *HisApiController) Post3505() {
  35903. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35904. data := make(map[string]interface{})
  35905. var struct3501s []models.Struct3501
  35906. var struct3501 models.Struct3501
  35907. struct3501.OrgName = miConfig.OrgName
  35908. struct3501.AccessKey = miConfig.AccessKey
  35909. struct3501.RequestUrl = miConfig.Url
  35910. struct3501.SecretKey = miConfig.SecretKey
  35911. struct3501.ManuDate = "2022-08-15"
  35912. struct3501.FixmedinsBchno = ""
  35913. struct3501.ManuLotnum = ""
  35914. struct3501.RxFlag = "0"
  35915. struct3501.ExpyEnd = "2022-08-15"
  35916. struct3501.Invdate = "2022-08-15"
  35917. struct3501.InvCnt = "20.25"
  35918. struct3501.Memo = ""
  35919. struct3501.MedListCodg = "XB01ABD056B002020200517"
  35920. struct3501.FixmedinsHilistId = miConfig.Code
  35921. struct3501.FixmedinsHilistName = miConfig.OrgName
  35922. struct3501s = append(struct3501s, struct3501)
  35923. data["struct_3501s"] = struct3501s
  35924. client := &http.Client{}
  35925. bytesData, _ := json.Marshal(data)
  35926. var req *http.Request
  35927. if miConfig.MdtrtareaAdmvs == "320921" {
  35928. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35929. } else {
  35930. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35931. }
  35932. resp, _ := client.Do(req)
  35933. defer resp.Body.Close()
  35934. body, ioErr := ioutil.ReadAll(resp.Body)
  35935. if ioErr != nil {
  35936. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35938. return
  35939. }
  35940. var respJSON map[string]interface{}
  35941. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35942. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35944. return
  35945. }
  35946. var res ResultSix
  35947. var resSix10265 ResultSix10265 //1101结果
  35948. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  35949. result, _ := json.Marshal(respJSON)
  35950. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  35951. utils.ErrorLog("解析失败:%v", err)
  35952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35953. return
  35954. }
  35955. res.InfRefmsgid = resSix10265.InfRefmsgid
  35956. res.Output = resSix10265.Output
  35957. res.ErrMsg = resSix10265.ErrMsg
  35958. res.Cainfo = resSix10265.Cainfo
  35959. res.WarnMsg = resSix10265.WarnMsg
  35960. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35961. res.Infcode = infocode
  35962. if infocode == 0 {
  35963. c.ServeSuccessJSON(map[string]interface{}{
  35964. "msg": "上传成功",
  35965. })
  35966. return
  35967. } else {
  35968. c.ServeSuccessJSON(map[string]interface{}{
  35969. "failed_code": -10,
  35970. "msg": res.ErrMsg,
  35971. })
  35972. return
  35973. }
  35974. }
  35975. func (c *HisApiController) Post3506() {
  35976. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35977. data := make(map[string]interface{})
  35978. var struct3501s []models.Struct3501
  35979. var struct3501 models.Struct3501
  35980. struct3501.OrgName = miConfig.OrgName
  35981. struct3501.AccessKey = miConfig.AccessKey
  35982. struct3501.RequestUrl = miConfig.Url
  35983. struct3501.SecretKey = miConfig.SecretKey
  35984. struct3501.ManuDate = "2022-08-15"
  35985. struct3501.FixmedinsBchno = ""
  35986. struct3501.ManuLotnum = ""
  35987. struct3501.RxFlag = "0"
  35988. struct3501.ExpyEnd = "2022-08-15"
  35989. struct3501.Invdate = "2022-08-15"
  35990. struct3501.InvCnt = "20.25"
  35991. struct3501.Memo = ""
  35992. struct3501.MedListCodg = "XB01ABD056B002020200517"
  35993. struct3501.FixmedinsHilistId = miConfig.Code
  35994. struct3501.FixmedinsHilistName = miConfig.OrgName
  35995. struct3501s = append(struct3501s, struct3501)
  35996. data["struct_3501s"] = struct3501s
  35997. client := &http.Client{}
  35998. bytesData, _ := json.Marshal(data)
  35999. var req *http.Request
  36000. if miConfig.MdtrtareaAdmvs == "320921" {
  36001. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  36002. } else {
  36003. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  36004. }
  36005. resp, _ := client.Do(req)
  36006. defer resp.Body.Close()
  36007. body, ioErr := ioutil.ReadAll(resp.Body)
  36008. if ioErr != nil {
  36009. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36011. return
  36012. }
  36013. var respJSON map[string]interface{}
  36014. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  36015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36017. return
  36018. }
  36019. var res ResultSix
  36020. var resSix10265 ResultSix10265 //1101结果
  36021. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  36022. result, _ := json.Marshal(respJSON)
  36023. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  36024. utils.ErrorLog("解析失败:%v", err)
  36025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36026. return
  36027. }
  36028. res.InfRefmsgid = resSix10265.InfRefmsgid
  36029. res.Output = resSix10265.Output
  36030. res.ErrMsg = resSix10265.ErrMsg
  36031. res.Cainfo = resSix10265.Cainfo
  36032. res.WarnMsg = resSix10265.WarnMsg
  36033. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  36034. res.Infcode = infocode
  36035. if infocode == 0 {
  36036. c.ServeSuccessJSON(map[string]interface{}{
  36037. "msg": "上传成功",
  36038. })
  36039. return
  36040. } else {
  36041. c.ServeSuccessJSON(map[string]interface{}{
  36042. "failed_code": -10,
  36043. "msg": res.ErrMsg,
  36044. })
  36045. return
  36046. }
  36047. }
  36048. func (c *HisApiController) Post3507() {
  36049. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  36050. data := make(map[string]interface{})
  36051. var struct3501s []models.Struct3501
  36052. var struct3501 models.Struct3501
  36053. struct3501.OrgName = miConfig.OrgName
  36054. struct3501.AccessKey = miConfig.AccessKey
  36055. struct3501.RequestUrl = miConfig.Url
  36056. struct3501.SecretKey = miConfig.SecretKey
  36057. struct3501.ManuDate = "2022-08-15"
  36058. struct3501.FixmedinsBchno = ""
  36059. struct3501.ManuLotnum = ""
  36060. struct3501.RxFlag = "0"
  36061. struct3501.ExpyEnd = "2022-08-15"
  36062. struct3501.Invdate = "2022-08-15"
  36063. struct3501.InvCnt = "20.25"
  36064. struct3501.Memo = ""
  36065. struct3501.MedListCodg = "XB01ABD056B002020200517"
  36066. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  36067. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  36068. struct3501s = append(struct3501s, struct3501)
  36069. data["struct_3501s"] = struct3501s
  36070. client := &http.Client{}
  36071. bytesData, _ := json.Marshal(data)
  36072. var req *http.Request
  36073. if miConfig.MdtrtareaAdmvs == "320921" {
  36074. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  36075. } else {
  36076. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  36077. }
  36078. resp, _ := client.Do(req)
  36079. defer resp.Body.Close()
  36080. body, ioErr := ioutil.ReadAll(resp.Body)
  36081. if ioErr != nil {
  36082. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36084. return
  36085. }
  36086. var respJSON map[string]interface{}
  36087. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  36088. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36090. return
  36091. }
  36092. var res ResultSix
  36093. var resSix10265 ResultSix10265 //1101结果
  36094. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  36095. result, _ := json.Marshal(respJSON)
  36096. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  36097. utils.ErrorLog("解析失败:%v", err)
  36098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36099. return
  36100. }
  36101. res.InfRefmsgid = resSix10265.InfRefmsgid
  36102. res.Output = resSix10265.Output
  36103. res.ErrMsg = resSix10265.ErrMsg
  36104. res.Cainfo = resSix10265.Cainfo
  36105. res.WarnMsg = resSix10265.WarnMsg
  36106. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  36107. res.Infcode = infocode
  36108. if infocode == 0 {
  36109. c.ServeSuccessJSON(map[string]interface{}{
  36110. "msg": "上传成功",
  36111. })
  36112. return
  36113. } else {
  36114. c.ServeSuccessJSON(map[string]interface{}{
  36115. "failed_code": -10,
  36116. "msg": res.ErrMsg,
  36117. })
  36118. return
  36119. }
  36120. }
  36121. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  36122. // WebSocket服务器地址
  36123. serverURL := "ws://127.0.0.1:8899"
  36124. // 解析WebSocket服务器地址
  36125. u, err := url.Parse(serverURL)
  36126. if err != nil {
  36127. }
  36128. // 建立WebSocket连接
  36129. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  36130. if err != nil {
  36131. }
  36132. defer conn.Close()
  36133. input2 := make(map[string]interface{})
  36134. input := make(map[string]interface{})
  36135. inputData := make(map[string]interface{})
  36136. inputData["orgId"] = code
  36137. inputData["businessType"] = "01101"
  36138. inputData["operatorId"] = operator_id
  36139. inputData["operatorName"] = operator_name
  36140. inputData["officeId"] = "001"
  36141. inputData["officeName"] = "血透室"
  36142. inputData["deviceType"] = ""
  36143. input["data"] = inputData
  36144. input["orgId"] = code
  36145. input["transType"] = "ec.query"
  36146. //if md == ""
  36147. if md[:4] == "4403" {
  36148. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  36149. } else if md[:4] == "4401" {
  36150. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  36151. } else {
  36152. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  36153. }
  36154. input2["indata"] = input
  36155. fmt.Println(input2)
  36156. bytesData, _ := json.Marshal(input2)
  36157. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  36158. if err != nil {
  36159. fmt.Println(err)
  36160. }
  36161. // 接收消息
  36162. _, receivedMessage, err := conn.ReadMessage()
  36163. if err != nil {
  36164. fmt.Println(err)
  36165. }
  36166. return "", string(receivedMessage)
  36167. }
  36168. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  36169. // WebSocket服务器地址
  36170. serverURL := "ws://127.0.0.1:8899"
  36171. // 解析WebSocket服务器地址
  36172. u, err := url.Parse(serverURL)
  36173. if err != nil {
  36174. }
  36175. // 建立WebSocket连接
  36176. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  36177. if err != nil {
  36178. }
  36179. defer conn.Close()
  36180. input2 := make(map[string]interface{})
  36181. input := make(map[string]interface{})
  36182. inputData := make(map[string]interface{})
  36183. inputData["orgId"] = code
  36184. inputData["businessType"] = "01101"
  36185. inputData["operatorId"] = operator_id
  36186. inputData["operatorName"] = operator_name
  36187. inputData["officeId"] = "001"
  36188. inputData["officeName"] = "血透室"
  36189. inputData["deviceType"] = ""
  36190. input["data"] = inputData
  36191. input["orgId"] = code
  36192. input["transType"] = "ec.query"
  36193. //if md == ""
  36194. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  36195. input2["indata"] = input
  36196. fmt.Println(input2)
  36197. bytesData, _ := json.Marshal(input2)
  36198. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  36199. if err != nil {
  36200. fmt.Println(err)
  36201. }
  36202. // 接收消息
  36203. _, receivedMessage, err := conn.ReadMessage()
  36204. if err != nil {
  36205. fmt.Println(err)
  36206. }
  36207. return "", string(receivedMessage)
  36208. }
  36209. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  36210. // WebSocket服务器地址
  36211. serverURL := "ws://127.0.0.1:8899"
  36212. // 解析WebSocket服务器地址
  36213. u, err := url.Parse(serverURL)
  36214. if err != nil {
  36215. }
  36216. // 建立WebSocket连接
  36217. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  36218. if err != nil {
  36219. }
  36220. defer conn.Close()
  36221. input2 := make(map[string]interface{})
  36222. input := make(map[string]interface{})
  36223. inputData := make(map[string]interface{})
  36224. inputData["orgId"] = code
  36225. inputData["businessType"] = "01301"
  36226. inputData["operatorId"] = operator_id
  36227. inputData["operatorName"] = operator_name
  36228. inputData["officeId"] = "001"
  36229. inputData["officeName"] = "血透室"
  36230. inputData["deviceType"] = ""
  36231. input["data"] = inputData
  36232. input["orgId"] = code
  36233. input["transType"] = "ec.query"
  36234. //if md == ""
  36235. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  36236. input2["indata"] = input
  36237. fmt.Println(input2)
  36238. bytesData, _ := json.Marshal(input2)
  36239. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  36240. if err != nil {
  36241. fmt.Println(err)
  36242. }
  36243. // 接收消息
  36244. _, receivedMessage, err := conn.ReadMessage()
  36245. if err != nil {
  36246. fmt.Println(err)
  36247. }
  36248. return "", string(receivedMessage)
  36249. }
  36250. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  36251. // WebSocket服务器地址
  36252. serverURL := "ws://127.0.0.1:8899"
  36253. // 解析WebSocket服务器地址
  36254. u, err := url.Parse(serverURL)
  36255. if err != nil {
  36256. }
  36257. // 建立WebSocket连接
  36258. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  36259. if err != nil {
  36260. }
  36261. defer conn.Close()
  36262. input2 := make(map[string]interface{})
  36263. input := make(map[string]interface{})
  36264. inputData := make(map[string]interface{})
  36265. inputData["orgId"] = code
  36266. inputData["businessType"] = "01103"
  36267. inputData["operatorId"] = operator_id
  36268. inputData["operatorName"] = operator_name
  36269. inputData["officeId"] = "001"
  36270. inputData["officeName"] = "血透室"
  36271. inputData["deviceType"] = ""
  36272. input["data"] = inputData
  36273. input["orgId"] = code
  36274. input["transType"] = "ec.query"
  36275. //if md ==
  36276. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  36277. input2["indata"] = input
  36278. fmt.Println(input2)
  36279. bytesData, _ := json.Marshal(input2)
  36280. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  36281. if err != nil {
  36282. fmt.Println(err)
  36283. }
  36284. // 接收消息
  36285. _, receivedMessage, err := conn.ReadMessage()
  36286. if err != nil {
  36287. fmt.Println(err)
  36288. }
  36289. return "", string(receivedMessage)
  36290. }
  36291. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  36292. // WebSocket服务器地址
  36293. serverURL := "ws://127.0.0.1:8899"
  36294. // 解析WebSocket服务器地址
  36295. u, err := url.Parse(serverURL)
  36296. if err != nil {
  36297. }
  36298. // 建立WebSocket连接
  36299. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  36300. if err != nil {
  36301. }
  36302. defer conn.Close()
  36303. input2 := make(map[string]interface{})
  36304. input := make(map[string]interface{})
  36305. inputData := make(map[string]interface{})
  36306. inputData["orgId"] = code
  36307. inputData["businessType"] = "01101"
  36308. inputData["operatorId"] = operator_id
  36309. inputData["operatorName"] = operator_name
  36310. inputData["officeId"] = "001"
  36311. inputData["officeName"] = "血透室"
  36312. inputData["deviceType"] = ""
  36313. input["data"] = inputData
  36314. input["orgId"] = code
  36315. input["transType"] = "ec.query"
  36316. //if md == ""
  36317. if md[:4] == "4403" {
  36318. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  36319. } else if md[:4] == "4401" {
  36320. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  36321. } else {
  36322. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  36323. }
  36324. input2["indata"] = input
  36325. fmt.Println(input2)
  36326. bytesData, _ := json.Marshal(input2)
  36327. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  36328. if err != nil {
  36329. fmt.Println(err)
  36330. }
  36331. // 接收消息
  36332. _, receivedMessage, err := conn.ReadMessage()
  36333. if err != nil {
  36334. fmt.Println(err)
  36335. }
  36336. return "", string(receivedMessage)
  36337. }
  36338. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  36339. // WebSocket服务器地址
  36340. serverURL := "ws://127.0.0.1:8899"
  36341. // 解析WebSocket服务器地址
  36342. u, err := url.Parse(serverURL)
  36343. if err != nil {
  36344. }
  36345. // 建立WebSocket连接
  36346. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  36347. if err != nil {
  36348. }
  36349. defer conn.Close()
  36350. input2 := make(map[string]interface{})
  36351. input := make(map[string]interface{})
  36352. inputData := make(map[string]interface{})
  36353. inputData["orgId"] = code
  36354. inputData["businessType"] = "01301"
  36355. inputData["operatorId"] = operator_id
  36356. inputData["operatorName"] = operator_name
  36357. inputData["officeId"] = "001"
  36358. inputData["officeName"] = "血透室"
  36359. inputData["deviceType"] = ""
  36360. input["data"] = inputData
  36361. input["orgId"] = code
  36362. input["transType"] = "ec.query"
  36363. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  36364. input2["indata"] = input
  36365. bytesData, _ := json.Marshal(input2)
  36366. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  36367. if err != nil {
  36368. fmt.Println(err)
  36369. }
  36370. // 接收消息
  36371. _, receivedMessage, err := conn.ReadMessage()
  36372. if err != nil {
  36373. fmt.Println(err)
  36374. }
  36375. return "", string(receivedMessage)
  36376. }
  36377. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  36378. newArr = make([]string, 0)
  36379. for i := 0; i < len(arr); i++ {
  36380. repeat := false
  36381. for j := i + 1; j < len(arr); j++ {
  36382. if arr[i] == arr[j] {
  36383. repeat = true
  36384. break
  36385. }
  36386. }
  36387. if !repeat {
  36388. newArr = append(newArr, arr[i])
  36389. }
  36390. }
  36391. return
  36392. }
  36393. func getBirthdateAndAge(idNumber string) (string, int, error) {
  36394. if len(idNumber) != 18 {
  36395. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  36396. }
  36397. // 提取出生日期
  36398. year, err := strconv.Atoi(idNumber[6:10])
  36399. if err != nil {
  36400. return "", 0, err
  36401. }
  36402. month, err := strconv.Atoi(idNumber[10:12])
  36403. if err != nil {
  36404. return "", 0, err
  36405. }
  36406. day, err := strconv.Atoi(idNumber[12:14])
  36407. if err != nil {
  36408. return "", 0, err
  36409. }
  36410. // 格式化生日字符串
  36411. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  36412. birthdateFormatted := birthdate.Format("2006-01-02")
  36413. // 计算年龄
  36414. today := time.Now()
  36415. age := today.Year() - birthdate.Year()
  36416. if today.YearDay() < birthdate.YearDay() {
  36417. age--
  36418. }
  36419. return birthdateFormatted, age, nil
  36420. }
  36421. // 从身份证号码中提取出生年月日
  36422. func getBirthDateFromIDCard(idCard string) (string, error) {
  36423. // 身份证号码长度应为18位
  36424. if len(idCard) != 18 {
  36425. return "", fmt.Errorf("身份证号码长度应为18位")
  36426. }
  36427. // 提取出生日期部分 (YYYYMMDD)
  36428. birthDateStr := idCard[6:14]
  36429. // 解析出生日期
  36430. birthDate, err := time.Parse("20060102", birthDateStr)
  36431. if err != nil {
  36432. return "", fmt.Errorf("解析出生日期失败: %v", err)
  36433. }
  36434. // 格式化出生日期为 YYYY-MM-DD
  36435. formattedDate := birthDate.Format("2006-01-02")
  36436. return formattedDate, nil
  36437. }