his_api_controller.go 1.5MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115
  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) ChangeDrug() {
  2995. ids := c.GetString("ids")
  2996. id_arr := strings.Split(ids, ",")
  2997. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2998. admin_user_id, _ := c.GetInt64("admin_user_id")
  2999. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3000. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3001. var err []string
  3002. for _, item := range flows {
  3003. var res3 ResultSix
  3004. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3005. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3006. if prescription.OrderStatus == 2 {
  3007. //已经结算
  3008. //判断是否已经销售
  3009. if item.IsSale == 1 { //是否已经销售,1是 0否
  3010. //是否已经变更 1是 0否
  3011. if item.IsChange == 0 { //没变更,进行变更操作
  3012. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3013. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3014. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3015. var respJSON3 map[string]interface{}
  3016. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3017. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3019. return
  3020. }
  3021. userJSONBytes3, _ := json.Marshal(respJSON3)
  3022. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3023. utils.ErrorLog("解析失败:%v", err)
  3024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3025. return
  3026. }
  3027. if res3.Infcode == 0 {
  3028. item.IsChange = 1
  3029. item.BgBchno = bg_number
  3030. service.SaveDF2(item)
  3031. } else {
  3032. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3033. }
  3034. }
  3035. } else { //没销售,
  3036. var res FJ3507Result
  3037. var res3507for10188 FJ3507ResultFor10188
  3038. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3039. //进行商品销售接口
  3040. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3041. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3042. var respJSON3 map[string]interface{}
  3043. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3046. return
  3047. }
  3048. userJSONBytes3, _ := json.Marshal(respJSON3)
  3049. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3050. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3051. utils.ErrorLog("解析失败:%v", err)
  3052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3053. return
  3054. }
  3055. //if res3507for10188.Infcode
  3056. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3057. //res.Output = resSix10265.Output
  3058. res.ErrMsg = res3507for10188.ErrMsg
  3059. res.Cainfo = res3507for10188.Cainfo
  3060. res.WarnMsg = res3507for10188.WarnMsg
  3061. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3062. res.Infcode = infocode
  3063. } else {
  3064. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3065. utils.ErrorLog("解析失败:%v", err)
  3066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3067. return
  3068. }
  3069. }
  3070. if res.Infcode == 0 {
  3071. item.IsSale = 1
  3072. item.Bchno = number
  3073. item.SaleDate = time.Now().Format("2006-01-02")
  3074. err5 := service.SaveDF(item)
  3075. if err5 == nil {
  3076. if item.IsChange == 0 { //没变更,进行变更操作
  3077. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3078. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3079. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3080. var respJSON3 map[string]interface{}
  3081. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3082. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3084. return
  3085. }
  3086. userJSONBytes3, _ := json.Marshal(respJSON3)
  3087. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3088. utils.ErrorLog("解析失败:%v", err)
  3089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3090. return
  3091. }
  3092. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3093. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3094. utils.ErrorLog("解析失败:%v", err)
  3095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3096. return
  3097. }
  3098. //if res3507for10188.Infcode
  3099. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3100. //res.Output = resSix10265.Output
  3101. res3.ErrMsg = res3507for10188.ErrMsg
  3102. res3.Cainfo = res3507for10188.Cainfo
  3103. res3.WarnMsg = res3507for10188.WarnMsg
  3104. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3105. res3.Infcode = infocode
  3106. } else {
  3107. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3108. utils.ErrorLog("解析失败:%v", err)
  3109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3110. return
  3111. }
  3112. }
  3113. if res3.Infcode == 0 {
  3114. item.IsChange = 1
  3115. item.BgBchno = bg_number
  3116. service.SaveDF2(item)
  3117. } else {
  3118. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3119. }
  3120. }
  3121. }
  3122. } else {
  3123. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3124. }
  3125. }
  3126. } else { //还没结算
  3127. var res3507for10188 FJ3507ResultFor10188
  3128. if item.IsChange == 0 { //没变更,进行变更操作
  3129. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3130. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3131. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3132. var respJSON3 map[string]interface{}
  3133. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3134. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3136. return
  3137. }
  3138. userJSONBytes3, _ := json.Marshal(respJSON3)
  3139. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3140. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3141. utils.ErrorLog("解析失败:%v", err)
  3142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3143. return
  3144. }
  3145. //if res3507for10188.Infcode
  3146. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3147. //res.Output = resSix10265.Output
  3148. res3.ErrMsg = res3507for10188.ErrMsg
  3149. res3.Cainfo = res3507for10188.Cainfo
  3150. res3.WarnMsg = res3507for10188.WarnMsg
  3151. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3152. res3.Infcode = infocode
  3153. } else {
  3154. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3155. utils.ErrorLog("解析失败:%v", err)
  3156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3157. return
  3158. }
  3159. }
  3160. if res3.Infcode == 0 {
  3161. item.IsChange = 1
  3162. item.BgBchno = bg_number
  3163. service.SaveDF2(item)
  3164. } else {
  3165. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3166. }
  3167. }
  3168. }
  3169. } else if item.ConsumableType == 7 {
  3170. var res3507for10188 FJ3507ResultFor10188
  3171. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3172. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3173. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3174. //判断是否已经销售
  3175. if item.IsSale == 2 { //是否已经销售,1是 0否
  3176. //是否已经变更 1是 0否
  3177. if item.IsChange == 0 { //没变更,进行变更操作
  3178. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3179. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3180. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3181. var respJSON3 map[string]interface{}
  3182. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3183. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3185. return
  3186. }
  3187. userJSONBytes3, _ := json.Marshal(respJSON3)
  3188. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3189. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3190. utils.ErrorLog("解析失败:%v", err)
  3191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3192. return
  3193. }
  3194. //if res3507for10188.Infcode
  3195. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3196. //res.Output = resSix10265.Output
  3197. res3.ErrMsg = res3507for10188.ErrMsg
  3198. res3.Cainfo = res3507for10188.Cainfo
  3199. res3.WarnMsg = res3507for10188.WarnMsg
  3200. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3201. res3.Infcode = infocode
  3202. } else {
  3203. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3204. utils.ErrorLog("解析失败:%v", err)
  3205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3206. return
  3207. }
  3208. }
  3209. if res3.Infcode == 0 {
  3210. item.IsChange = 1
  3211. item.BgBchno = bg_number
  3212. service.SaveDF2(item)
  3213. } else {
  3214. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3215. }
  3216. }
  3217. } else { //没销售,
  3218. //进行商品销售退货接口
  3219. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3220. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3221. saveLog(result111, result222, "3506", "销售退货")
  3222. var res7 FJ3507Result
  3223. //进行商品销售接口
  3224. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3225. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3226. var respJSON3 map[string]interface{}
  3227. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3228. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3230. return
  3231. }
  3232. userJSONBytes3, _ := json.Marshal(respJSON3)
  3233. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3234. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3235. utils.ErrorLog("解析失败:%v", err)
  3236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3237. return
  3238. }
  3239. //if res3507for10188.Infcode
  3240. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3241. //res.Output = resSix10265.Output
  3242. res7.ErrMsg = res3507for10188.ErrMsg
  3243. res7.Cainfo = res3507for10188.Cainfo
  3244. res7.WarnMsg = res3507for10188.WarnMsg
  3245. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3246. res7.Infcode = infocode
  3247. } else {
  3248. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3249. utils.ErrorLog("解析失败:%v", err)
  3250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3251. return
  3252. }
  3253. }
  3254. if res7.Infcode == 0 {
  3255. item.IsSale = 2
  3256. item.SaleDate = item.SaleDate
  3257. item.Bchno = number
  3258. service.SaveDF(item)
  3259. if item.IsChange == 0 { //没变更,进行变更操作
  3260. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3261. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3262. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3263. var respJSON3 map[string]interface{}
  3264. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3265. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3267. return
  3268. }
  3269. userJSONBytes3, _ := json.Marshal(respJSON3)
  3270. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3271. // utils.ErrorLog("解析失败:%v", err)
  3272. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3273. // return
  3274. //}
  3275. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3276. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3277. utils.ErrorLog("解析失败:%v", err)
  3278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3279. return
  3280. }
  3281. //if res3507for10188.Infcode
  3282. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3283. //res.Output = resSix10265.Output
  3284. res3.ErrMsg = res3507for10188.ErrMsg
  3285. res3.Cainfo = res3507for10188.Cainfo
  3286. res3.WarnMsg = res3507for10188.WarnMsg
  3287. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3288. res3.Infcode = infocode
  3289. } else {
  3290. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3291. utils.ErrorLog("解析失败:%v", err)
  3292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3293. return
  3294. }
  3295. }
  3296. if res3.Infcode == 0 {
  3297. item.IsChange = 1
  3298. item.BgBchno = bg_number
  3299. service.SaveDF2(item)
  3300. } else {
  3301. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3302. }
  3303. }
  3304. } else {
  3305. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3306. }
  3307. }
  3308. } else { //还没结算
  3309. if item.IsChange == 0 { //没变更,进行变更操作
  3310. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3311. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3312. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3313. var respJSON3 map[string]interface{}
  3314. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3315. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3317. return
  3318. }
  3319. userJSONBytes3, _ := json.Marshal(respJSON3)
  3320. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3321. // utils.ErrorLog("解析失败:%v", err)
  3322. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3323. // return
  3324. //}
  3325. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3326. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3327. utils.ErrorLog("解析失败:%v", err)
  3328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3329. return
  3330. }
  3331. //if res3507for10188.Infcode
  3332. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3333. //res.Output = resSix10265.Output
  3334. res3.ErrMsg = res3507for10188.ErrMsg
  3335. res3.Cainfo = res3507for10188.Cainfo
  3336. res3.WarnMsg = res3507for10188.WarnMsg
  3337. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3338. res3.Infcode = infocode
  3339. } else {
  3340. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3341. utils.ErrorLog("解析失败:%v", err)
  3342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3343. return
  3344. }
  3345. }
  3346. if res3.Infcode == 0 {
  3347. item.IsChange = 1
  3348. item.BgBchno = bg_number
  3349. service.SaveDF2(item)
  3350. } else {
  3351. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3352. }
  3353. }
  3354. }
  3355. }
  3356. }
  3357. if len(err) == 0 {
  3358. c.ServeSuccessJSON(map[string]interface{}{
  3359. "msg": "销售变更成功",
  3360. })
  3361. } else {
  3362. c.ServeSuccessJSON(map[string]interface{}{
  3363. "failed_code": -10,
  3364. "msg": err,
  3365. })
  3366. }
  3367. }
  3368. func (c *HisApiController) ChangeDrugtwo() {
  3369. //ids := c.GetString("ids")
  3370. //id_arr := strings.Split(ids, ",")
  3371. flows, _ := service.GetNewDrugFlowInfotwo()
  3372. admin_user_id, _ := c.GetInt64("admin_user_id")
  3373. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3374. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3375. var err []string
  3376. for _, item := range flows {
  3377. var res3 ResultSix
  3378. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3379. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3380. if prescription.OrderStatus == 2 {
  3381. //已经结算
  3382. //判断是否已经销售
  3383. if item.IsSale == 1 { //是否已经销售,1是 0否
  3384. //是否已经变更 1是 0否
  3385. if item.IsChange == 0 { //没变更,进行变更操作
  3386. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3387. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3388. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3389. var respJSON3 map[string]interface{}
  3390. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3391. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3393. return
  3394. }
  3395. userJSONBytes3, _ := json.Marshal(respJSON3)
  3396. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3397. utils.ErrorLog("解析失败:%v", err)
  3398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3399. return
  3400. }
  3401. if res3.Infcode == 0 {
  3402. item.IsChange = 1
  3403. item.BgBchno = bg_number
  3404. service.SaveDF2(item)
  3405. } else {
  3406. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3407. }
  3408. }
  3409. } else { //没销售,
  3410. var res FJ3507Result
  3411. var res3507for10188 FJ3507ResultFor10188
  3412. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3413. //进行商品销售接口
  3414. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3415. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3416. var respJSON3 map[string]interface{}
  3417. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3418. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3420. return
  3421. }
  3422. userJSONBytes3, _ := json.Marshal(respJSON3)
  3423. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3424. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3425. utils.ErrorLog("解析失败:%v", err)
  3426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3427. return
  3428. }
  3429. //if res3507for10188.Infcode
  3430. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3431. //res.Output = resSix10265.Output
  3432. res.ErrMsg = res3507for10188.ErrMsg
  3433. res.Cainfo = res3507for10188.Cainfo
  3434. res.WarnMsg = res3507for10188.WarnMsg
  3435. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3436. res.Infcode = infocode
  3437. } else {
  3438. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3439. utils.ErrorLog("解析失败:%v", err)
  3440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3441. return
  3442. }
  3443. }
  3444. if res.Infcode == 0 {
  3445. item.IsSale = 1
  3446. item.Bchno = number
  3447. item.SaleDate = time.Now().Format("2006-01-02")
  3448. err5 := service.SaveDF(item)
  3449. if err5 == nil {
  3450. if item.IsChange == 0 { //没变更,进行变更操作
  3451. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3452. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3453. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3454. var respJSON3 map[string]interface{}
  3455. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3456. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3458. return
  3459. }
  3460. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3461. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3462. utils.ErrorLog("解析失败:%v", err)
  3463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3464. return
  3465. }
  3466. //if res3507for10188.Infcode
  3467. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3468. //res.Output = resSix10265.Output
  3469. res3.ErrMsg = res3507for10188.ErrMsg
  3470. res3.Cainfo = res3507for10188.Cainfo
  3471. res3.WarnMsg = res3507for10188.WarnMsg
  3472. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3473. res3.Infcode = infocode
  3474. } else {
  3475. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3476. utils.ErrorLog("解析失败:%v", err)
  3477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3478. return
  3479. }
  3480. }
  3481. if res3.Infcode == 0 {
  3482. item.IsChange = 1
  3483. item.BgBchno = bg_number
  3484. service.SaveDF2(item)
  3485. } else {
  3486. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3487. }
  3488. }
  3489. }
  3490. } else {
  3491. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3492. }
  3493. }
  3494. } else { //还没结算
  3495. var res3507for10188 FJ3507ResultFor10188
  3496. if item.IsChange == 0 { //没变更,进行变更操作
  3497. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3498. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3499. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3500. var respJSON3 map[string]interface{}
  3501. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3502. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3504. return
  3505. }
  3506. userJSONBytes3, _ := json.Marshal(respJSON3)
  3507. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3508. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3509. utils.ErrorLog("解析失败:%v", err)
  3510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3511. return
  3512. }
  3513. //if res3507for10188.Infcode
  3514. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3515. //res.Output = resSix10265.Output
  3516. res3.ErrMsg = res3507for10188.ErrMsg
  3517. res3.Cainfo = res3507for10188.Cainfo
  3518. res3.WarnMsg = res3507for10188.WarnMsg
  3519. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3520. res3.Infcode = infocode
  3521. } else {
  3522. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3523. utils.ErrorLog("解析失败:%v", err)
  3524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3525. return
  3526. }
  3527. }
  3528. if res3.Infcode == 0 {
  3529. item.IsChange = 1
  3530. item.BgBchno = bg_number
  3531. service.SaveDF2(item)
  3532. } else {
  3533. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3534. }
  3535. }
  3536. }
  3537. } else if item.ConsumableType == 7 {
  3538. var res3507for10188 FJ3507ResultFor10188
  3539. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3540. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3541. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3542. //判断是否已经销售
  3543. if item.IsSale == 2 { //是否已经销售,1是 0否
  3544. //是否已经变更 1是 0否
  3545. if item.IsChange == 0 { //没变更,进行变更操作
  3546. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3547. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3548. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3549. var respJSON3 map[string]interface{}
  3550. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3551. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3553. return
  3554. }
  3555. userJSONBytes3, _ := json.Marshal(respJSON3)
  3556. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3557. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3558. utils.ErrorLog("解析失败:%v", err)
  3559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3560. return
  3561. }
  3562. //if res3507for10188.Infcode
  3563. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3564. //res.Output = resSix10265.Output
  3565. res3.ErrMsg = res3507for10188.ErrMsg
  3566. res3.Cainfo = res3507for10188.Cainfo
  3567. res3.WarnMsg = res3507for10188.WarnMsg
  3568. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3569. res3.Infcode = infocode
  3570. } else {
  3571. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3572. utils.ErrorLog("解析失败:%v", err)
  3573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3574. return
  3575. }
  3576. }
  3577. if res3.Infcode == 0 {
  3578. item.IsChange = 1
  3579. item.BgBchno = bg_number
  3580. service.SaveDF2(item)
  3581. } else {
  3582. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3583. }
  3584. }
  3585. } else { //没销售,
  3586. //进行商品销售退货接口
  3587. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3588. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3589. saveLog(result111, result222, "3506", "销售退货")
  3590. var res7 FJ3507Result
  3591. //进行商品销售接口
  3592. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3593. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3594. var respJSON3 map[string]interface{}
  3595. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3596. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3598. return
  3599. }
  3600. userJSONBytes3, _ := json.Marshal(respJSON3)
  3601. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3602. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3603. utils.ErrorLog("解析失败:%v", err)
  3604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3605. return
  3606. }
  3607. //if res3507for10188.Infcode
  3608. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3609. //res.Output = resSix10265.Output
  3610. res7.ErrMsg = res3507for10188.ErrMsg
  3611. res7.Cainfo = res3507for10188.Cainfo
  3612. res7.WarnMsg = res3507for10188.WarnMsg
  3613. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3614. res7.Infcode = infocode
  3615. } else {
  3616. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3617. utils.ErrorLog("解析失败:%v", err)
  3618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3619. return
  3620. }
  3621. }
  3622. if res7.Infcode == 0 {
  3623. item.IsSale = 2
  3624. item.SaleDate = item.SaleDate
  3625. item.Bchno = number
  3626. service.SaveDF(item)
  3627. if item.IsChange == 0 { //没变更,进行变更操作
  3628. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3629. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3630. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3631. var respJSON3 map[string]interface{}
  3632. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3633. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3635. return
  3636. }
  3637. userJSONBytes3, _ := json.Marshal(respJSON3)
  3638. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3639. // utils.ErrorLog("解析失败:%v", err)
  3640. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3641. // return
  3642. //}
  3643. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3644. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3645. utils.ErrorLog("解析失败:%v", err)
  3646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3647. return
  3648. }
  3649. //if res3507for10188.Infcode
  3650. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3651. //res.Output = resSix10265.Output
  3652. res3.ErrMsg = res3507for10188.ErrMsg
  3653. res3.Cainfo = res3507for10188.Cainfo
  3654. res3.WarnMsg = res3507for10188.WarnMsg
  3655. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3656. res3.Infcode = infocode
  3657. } else {
  3658. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3659. utils.ErrorLog("解析失败:%v", err)
  3660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3661. return
  3662. }
  3663. }
  3664. if res3.Infcode == 0 {
  3665. item.IsChange = 1
  3666. item.BgBchno = bg_number
  3667. service.SaveDF2(item)
  3668. } else {
  3669. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3670. }
  3671. }
  3672. } else {
  3673. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3674. }
  3675. }
  3676. } else { //还没结算
  3677. if item.IsChange == 0 { //没变更,进行变更操作
  3678. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3679. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3680. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3681. var respJSON3 map[string]interface{}
  3682. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3683. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3685. return
  3686. }
  3687. userJSONBytes3, _ := json.Marshal(respJSON3)
  3688. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3689. // utils.ErrorLog("解析失败:%v", err)
  3690. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3691. // return
  3692. //}
  3693. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3694. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3695. utils.ErrorLog("解析失败:%v", err)
  3696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3697. return
  3698. }
  3699. //if res3507for10188.Infcode
  3700. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3701. //res.Output = resSix10265.Output
  3702. res3.ErrMsg = res3507for10188.ErrMsg
  3703. res3.Cainfo = res3507for10188.Cainfo
  3704. res3.WarnMsg = res3507for10188.WarnMsg
  3705. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3706. res3.Infcode = infocode
  3707. } else {
  3708. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3709. utils.ErrorLog("解析失败:%v", err)
  3710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3711. return
  3712. }
  3713. }
  3714. if res3.Infcode == 0 {
  3715. item.IsChange = 1
  3716. item.BgBchno = bg_number
  3717. service.SaveDF2(item)
  3718. } else {
  3719. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3720. }
  3721. }
  3722. }
  3723. }
  3724. }
  3725. if len(err) == 0 {
  3726. c.ServeSuccessJSON(map[string]interface{}{
  3727. "msg": "销售变更成功",
  3728. })
  3729. } else {
  3730. c.ServeSuccessJSON(map[string]interface{}{
  3731. "failed_code": -10,
  3732. "msg": err,
  3733. })
  3734. }
  3735. }
  3736. func (c *HisApiController) ChangeDrugthree() {
  3737. //ids := c.GetString("ids")
  3738. //id_arr := strings.Split(ids, ",")
  3739. flows, _ := service.GetNewDrugFlowInfothree()
  3740. admin_user_id, _ := c.GetInt64("admin_user_id")
  3741. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3742. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3743. var err []string
  3744. for _, item := range flows {
  3745. var res3 ResultSix
  3746. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3747. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3748. if prescription.OrderStatus == 2 {
  3749. //已经结算
  3750. //判断是否已经销售
  3751. if item.IsSale == 1 { //是否已经销售,1是 0否
  3752. //是否已经变更 1是 0否
  3753. if item.IsChange == 0 { //没变更,进行变更操作
  3754. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3755. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3756. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3757. var respJSON3 map[string]interface{}
  3758. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3761. return
  3762. }
  3763. userJSONBytes3, _ := json.Marshal(respJSON3)
  3764. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3765. utils.ErrorLog("解析失败:%v", err)
  3766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3767. return
  3768. }
  3769. if res3.Infcode == 0 {
  3770. item.IsChange = 1
  3771. item.BgBchno = bg_number
  3772. service.SaveDF2(item)
  3773. } else {
  3774. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3775. }
  3776. }
  3777. } else { //没销售,
  3778. var res FJ3507Result
  3779. var res3507for10188 FJ3507ResultFor10188
  3780. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3781. //进行商品销售接口
  3782. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3783. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3784. var respJSON3 map[string]interface{}
  3785. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3786. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3788. return
  3789. }
  3790. userJSONBytes3, _ := json.Marshal(respJSON3)
  3791. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3792. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3793. utils.ErrorLog("解析失败:%v", err)
  3794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3795. return
  3796. }
  3797. //if res3507for10188.Infcode
  3798. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3799. //res.Output = resSix10265.Output
  3800. res.ErrMsg = res3507for10188.ErrMsg
  3801. res.Cainfo = res3507for10188.Cainfo
  3802. res.WarnMsg = res3507for10188.WarnMsg
  3803. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3804. res.Infcode = infocode
  3805. } else {
  3806. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3807. utils.ErrorLog("解析失败:%v", err)
  3808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3809. return
  3810. }
  3811. }
  3812. if res.Infcode == 0 {
  3813. item.IsSale = 1
  3814. item.Bchno = number
  3815. item.SaleDate = time.Now().Format("2006-01-02")
  3816. err5 := service.SaveDF(item)
  3817. if err5 == nil {
  3818. if item.IsChange == 0 { //没变更,进行变更操作
  3819. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3820. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3821. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3822. var respJSON3 map[string]interface{}
  3823. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3826. return
  3827. }
  3828. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  3829. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3830. utils.ErrorLog("解析失败:%v", err)
  3831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3832. return
  3833. }
  3834. //if res3507for10188.Infcode
  3835. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3836. //res.Output = resSix10265.Output
  3837. res3.ErrMsg = res3507for10188.ErrMsg
  3838. res3.Cainfo = res3507for10188.Cainfo
  3839. res3.WarnMsg = res3507for10188.WarnMsg
  3840. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3841. res3.Infcode = infocode
  3842. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3843. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3844. utils.ErrorLog("解析失败:%v", err)
  3845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3846. return
  3847. }
  3848. //if res3507for10188.Infcode
  3849. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3850. //res.Output = resSix10265.Output
  3851. res3.ErrMsg = res3507for10188.ErrMsg
  3852. res3.Cainfo = res3507for10188.Cainfo
  3853. res3.WarnMsg = res3507for10188.WarnMsg
  3854. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3855. res3.Infcode = infocode
  3856. } else {
  3857. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3858. utils.ErrorLog("解析失败:%v", err)
  3859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3860. return
  3861. }
  3862. }
  3863. if res3.Infcode == 0 {
  3864. item.IsChange = 1
  3865. item.BgBchno = bg_number
  3866. service.SaveDF2(item)
  3867. } else {
  3868. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3869. }
  3870. }
  3871. }
  3872. } else {
  3873. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3874. }
  3875. }
  3876. } else { //还没结算
  3877. var res3507for10188 FJ3507ResultFor10188
  3878. if item.IsChange == 0 { //没变更,进行变更操作
  3879. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3880. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3881. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3882. var respJSON3 map[string]interface{}
  3883. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3884. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3886. return
  3887. }
  3888. userJSONBytes3, _ := json.Marshal(respJSON3)
  3889. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  3890. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3891. utils.ErrorLog("解析失败:%v", err)
  3892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3893. return
  3894. }
  3895. //if res3507for10188.Infcode
  3896. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3897. //res.Output = resSix10265.Output
  3898. res3.ErrMsg = res3507for10188.ErrMsg
  3899. res3.Cainfo = res3507for10188.Cainfo
  3900. res3.WarnMsg = res3507for10188.WarnMsg
  3901. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3902. res3.Infcode = infocode
  3903. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3904. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3905. utils.ErrorLog("解析失败:%v", err)
  3906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3907. return
  3908. }
  3909. //if res3507for10188.Infcode
  3910. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3911. //res.Output = resSix10265.Output
  3912. res3.ErrMsg = res3507for10188.ErrMsg
  3913. res3.Cainfo = res3507for10188.Cainfo
  3914. res3.WarnMsg = res3507for10188.WarnMsg
  3915. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3916. res3.Infcode = infocode
  3917. } else {
  3918. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3919. utils.ErrorLog("解析失败:%v", err)
  3920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3921. return
  3922. }
  3923. }
  3924. if res3.Infcode == 0 {
  3925. item.IsChange = 1
  3926. item.BgBchno = bg_number
  3927. service.SaveDF2(item)
  3928. } else {
  3929. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3930. }
  3931. }
  3932. }
  3933. } else if item.ConsumableType == 7 {
  3934. var res3507for10188 FJ3507ResultFor10188
  3935. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3936. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3937. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3938. //判断是否已经销售
  3939. if item.IsSale == 2 { //是否已经销售,1是 0否
  3940. //是否已经变更 1是 0否
  3941. if item.IsChange == 0 { //没变更,进行变更操作
  3942. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3943. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3944. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3945. var respJSON3 map[string]interface{}
  3946. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3947. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3949. return
  3950. }
  3951. userJSONBytes3, _ := json.Marshal(respJSON3)
  3952. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3953. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3954. utils.ErrorLog("解析失败:%v", err)
  3955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3956. return
  3957. }
  3958. //if res3507for10188.Infcode
  3959. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3960. //res.Output = resSix10265.Output
  3961. res3.ErrMsg = res3507for10188.ErrMsg
  3962. res3.Cainfo = res3507for10188.Cainfo
  3963. res3.WarnMsg = res3507for10188.WarnMsg
  3964. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3965. res3.Infcode = infocode
  3966. } else {
  3967. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3968. utils.ErrorLog("解析失败:%v", err)
  3969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3970. return
  3971. }
  3972. }
  3973. if res3.Infcode == 0 {
  3974. item.IsChange = 1
  3975. item.BgBchno = bg_number
  3976. service.SaveDF2(item)
  3977. } else {
  3978. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3979. }
  3980. }
  3981. } else { //没销售,
  3982. //进行商品销售退货接口
  3983. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3984. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3985. saveLog(result111, result222, "3506", "销售退货")
  3986. var res7 FJ3507Result
  3987. //进行商品销售接口
  3988. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3989. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3990. var respJSON3 map[string]interface{}
  3991. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3992. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3994. return
  3995. }
  3996. userJSONBytes3, _ := json.Marshal(respJSON3)
  3997. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  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. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4005. //res.Output = resSix10265.Output
  4006. res7.ErrMsg = res3507for10188.ErrMsg
  4007. res7.Cainfo = res3507for10188.Cainfo
  4008. res7.WarnMsg = res3507for10188.WarnMsg
  4009. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4010. res7.Infcode = infocode
  4011. } else {
  4012. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4013. utils.ErrorLog("解析失败:%v", err)
  4014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4015. return
  4016. }
  4017. }
  4018. if res7.Infcode == 0 {
  4019. item.IsSale = 2
  4020. item.SaleDate = item.SaleDate
  4021. item.Bchno = number
  4022. service.SaveDF(item)
  4023. if item.IsChange == 0 { //没变更,进行变更操作
  4024. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4025. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4026. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4027. var respJSON3 map[string]interface{}
  4028. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4029. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4031. return
  4032. }
  4033. userJSONBytes3, _ := json.Marshal(respJSON3)
  4034. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4035. // utils.ErrorLog("解析失败:%v", err)
  4036. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4037. // return
  4038. //}
  4039. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4040. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4041. utils.ErrorLog("解析失败:%v", err)
  4042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4043. return
  4044. }
  4045. //if res3507for10188.Infcode
  4046. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4047. //res.Output = resSix10265.Output
  4048. res3.ErrMsg = res3507for10188.ErrMsg
  4049. res3.Cainfo = res3507for10188.Cainfo
  4050. res3.WarnMsg = res3507for10188.WarnMsg
  4051. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4052. res3.Infcode = infocode
  4053. } else {
  4054. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4055. utils.ErrorLog("解析失败:%v", err)
  4056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4057. return
  4058. }
  4059. }
  4060. if res3.Infcode == 0 {
  4061. item.IsChange = 1
  4062. item.BgBchno = bg_number
  4063. service.SaveDF2(item)
  4064. } else {
  4065. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4066. }
  4067. }
  4068. } else {
  4069. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4070. }
  4071. }
  4072. } else { //还没结算
  4073. if item.IsChange == 0 { //没变更,进行变更操作
  4074. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4075. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4076. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4077. var respJSON3 map[string]interface{}
  4078. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4079. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4081. return
  4082. }
  4083. userJSONBytes3, _ := json.Marshal(respJSON3)
  4084. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4085. // utils.ErrorLog("解析失败:%v", err)
  4086. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4087. // return
  4088. //}
  4089. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4090. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4091. utils.ErrorLog("解析失败:%v", err)
  4092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4093. return
  4094. }
  4095. //if res3507for10188.Infcode
  4096. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4097. //res.Output = resSix10265.Output
  4098. res3.ErrMsg = res3507for10188.ErrMsg
  4099. res3.Cainfo = res3507for10188.Cainfo
  4100. res3.WarnMsg = res3507for10188.WarnMsg
  4101. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4102. res3.Infcode = infocode
  4103. } else {
  4104. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4105. utils.ErrorLog("解析失败:%v", err)
  4106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4107. return
  4108. }
  4109. }
  4110. if res3.Infcode == 0 {
  4111. item.IsChange = 1
  4112. item.BgBchno = bg_number
  4113. service.SaveDF2(item)
  4114. } else {
  4115. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4116. }
  4117. }
  4118. }
  4119. }
  4120. }
  4121. if len(err) == 0 {
  4122. c.ServeSuccessJSON(map[string]interface{}{
  4123. "msg": "销售变更成功",
  4124. })
  4125. } else {
  4126. c.ServeSuccessJSON(map[string]interface{}{
  4127. "failed_code": -10,
  4128. "msg": err,
  4129. })
  4130. }
  4131. }
  4132. func (c *HisApiController) ChangeDrugTen() {
  4133. //ids := c.GetString("ids")
  4134. //id_arr := strings.Split(ids, ",")
  4135. flows, _ := service.GetNewDrugFlowInforTen()
  4136. admin_user_id, _ := c.GetInt64("admin_user_id")
  4137. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4138. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4139. var err []string
  4140. for _, item := range flows {
  4141. var res3 ResultSix
  4142. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4143. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4144. if prescription.OrderStatus == 2 {
  4145. //已经结算
  4146. //判断是否已经销售
  4147. if item.IsSale == 1 { //是否已经销售,1是 0否
  4148. //是否已经变更 1是 0否
  4149. if item.IsChange == 0 { //没变更,进行变更操作
  4150. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4151. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4152. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4153. var respJSON3 map[string]interface{}
  4154. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4155. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4157. return
  4158. }
  4159. userJSONBytes3, _ := json.Marshal(respJSON3)
  4160. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4161. utils.ErrorLog("解析失败:%v", err)
  4162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4163. return
  4164. }
  4165. if res3.Infcode == 0 {
  4166. item.IsChange = 1
  4167. item.BgBchno = bg_number
  4168. service.SaveDF2(item)
  4169. } else {
  4170. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4171. }
  4172. }
  4173. } else { //没销售,
  4174. var res FJ3507Result
  4175. var res3507for10188 FJ3507ResultFor10188
  4176. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4177. //进行商品销售接口
  4178. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4179. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4180. var respJSON3 map[string]interface{}
  4181. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4184. return
  4185. }
  4186. userJSONBytes3, _ := json.Marshal(respJSON3)
  4187. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4188. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4189. utils.ErrorLog("解析失败:%v", err)
  4190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4191. return
  4192. }
  4193. //if res3507for10188.Infcode
  4194. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4195. //res.Output = resSix10265.Output
  4196. res.ErrMsg = res3507for10188.ErrMsg
  4197. res.Cainfo = res3507for10188.Cainfo
  4198. res.WarnMsg = res3507for10188.WarnMsg
  4199. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4200. res.Infcode = infocode
  4201. } else {
  4202. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4203. utils.ErrorLog("解析失败:%v", err)
  4204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4205. return
  4206. }
  4207. }
  4208. if res.Infcode == 0 {
  4209. item.IsSale = 1
  4210. item.Bchno = number
  4211. item.SaleDate = time.Now().Format("2006-01-02")
  4212. err5 := service.SaveDF(item)
  4213. if err5 == nil {
  4214. if item.IsChange == 0 { //没变更,进行变更操作
  4215. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4216. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4217. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4218. var respJSON3 map[string]interface{}
  4219. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4220. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4222. return
  4223. }
  4224. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4225. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4226. utils.ErrorLog("解析失败:%v", err)
  4227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4228. return
  4229. }
  4230. //if res3507for10188.Infcode
  4231. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4232. //res.Output = resSix10265.Output
  4233. res3.ErrMsg = res3507for10188.ErrMsg
  4234. res3.Cainfo = res3507for10188.Cainfo
  4235. res3.WarnMsg = res3507for10188.WarnMsg
  4236. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4237. res3.Infcode = infocode
  4238. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4239. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4240. utils.ErrorLog("解析失败:%v", err)
  4241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4242. return
  4243. }
  4244. //if res3507for10188.Infcode
  4245. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4246. //res.Output = resSix10265.Output
  4247. res3.ErrMsg = res3507for10188.ErrMsg
  4248. res3.Cainfo = res3507for10188.Cainfo
  4249. res3.WarnMsg = res3507for10188.WarnMsg
  4250. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4251. res3.Infcode = infocode
  4252. } else {
  4253. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4254. utils.ErrorLog("解析失败:%v", err)
  4255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4256. return
  4257. }
  4258. }
  4259. if res3.Infcode == 0 {
  4260. item.IsChange = 1
  4261. item.BgBchno = bg_number
  4262. service.SaveDF2(item)
  4263. } else {
  4264. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4265. }
  4266. }
  4267. }
  4268. } else {
  4269. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4270. }
  4271. }
  4272. } else { //还没结算
  4273. var res3507for10188 FJ3507ResultFor10188
  4274. if item.IsChange == 0 { //没变更,进行变更操作
  4275. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4276. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4277. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4278. var respJSON3 map[string]interface{}
  4279. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4280. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4282. return
  4283. }
  4284. userJSONBytes3, _ := json.Marshal(respJSON3)
  4285. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4286. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4287. utils.ErrorLog("解析失败:%v", err)
  4288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4289. return
  4290. }
  4291. //if res3507for10188.Infcode
  4292. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4293. //res.Output = resSix10265.Output
  4294. res3.ErrMsg = res3507for10188.ErrMsg
  4295. res3.Cainfo = res3507for10188.Cainfo
  4296. res3.WarnMsg = res3507for10188.WarnMsg
  4297. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4298. res3.Infcode = infocode
  4299. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4300. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4301. utils.ErrorLog("解析失败:%v", err)
  4302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4303. return
  4304. }
  4305. //if res3507for10188.Infcode
  4306. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4307. //res.Output = resSix10265.Output
  4308. res3.ErrMsg = res3507for10188.ErrMsg
  4309. res3.Cainfo = res3507for10188.Cainfo
  4310. res3.WarnMsg = res3507for10188.WarnMsg
  4311. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4312. res3.Infcode = infocode
  4313. } else {
  4314. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4315. utils.ErrorLog("解析失败:%v", err)
  4316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4317. return
  4318. }
  4319. }
  4320. if res3.Infcode == 0 {
  4321. item.IsChange = 1
  4322. item.BgBchno = bg_number
  4323. service.SaveDF2(item)
  4324. } else {
  4325. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4326. }
  4327. }
  4328. }
  4329. } else if item.ConsumableType == 7 {
  4330. var res3507for10188 FJ3507ResultFor10188
  4331. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4332. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4333. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4334. //判断是否已经销售
  4335. if item.IsSale == 2 { //是否已经销售,1是 0否
  4336. //是否已经变更 1是 0否
  4337. if item.IsChange == 0 { //没变更,进行变更操作
  4338. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4339. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4340. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4341. var respJSON3 map[string]interface{}
  4342. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4343. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4345. return
  4346. }
  4347. userJSONBytes3, _ := json.Marshal(respJSON3)
  4348. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4349. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4350. utils.ErrorLog("解析失败:%v", err)
  4351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4352. return
  4353. }
  4354. //if res3507for10188.Infcode
  4355. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4356. //res.Output = resSix10265.Output
  4357. res3.ErrMsg = res3507for10188.ErrMsg
  4358. res3.Cainfo = res3507for10188.Cainfo
  4359. res3.WarnMsg = res3507for10188.WarnMsg
  4360. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4361. res3.Infcode = infocode
  4362. } else {
  4363. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4364. utils.ErrorLog("解析失败:%v", err)
  4365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4366. return
  4367. }
  4368. }
  4369. if res3.Infcode == 0 {
  4370. item.IsChange = 1
  4371. item.BgBchno = bg_number
  4372. service.SaveDF2(item)
  4373. } else {
  4374. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4375. }
  4376. }
  4377. } else { //没销售,
  4378. //进行商品销售退货接口
  4379. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4380. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4381. saveLog(result111, result222, "3506", "销售退货")
  4382. var res7 FJ3507Result
  4383. //进行商品销售接口
  4384. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4385. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4386. var respJSON3 map[string]interface{}
  4387. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4388. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4390. return
  4391. }
  4392. userJSONBytes3, _ := json.Marshal(respJSON3)
  4393. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4394. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4395. utils.ErrorLog("解析失败:%v", err)
  4396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4397. return
  4398. }
  4399. //if res3507for10188.Infcode
  4400. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4401. //res.Output = resSix10265.Output
  4402. res7.ErrMsg = res3507for10188.ErrMsg
  4403. res7.Cainfo = res3507for10188.Cainfo
  4404. res7.WarnMsg = res3507for10188.WarnMsg
  4405. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4406. res7.Infcode = infocode
  4407. } else {
  4408. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4409. utils.ErrorLog("解析失败:%v", err)
  4410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4411. return
  4412. }
  4413. }
  4414. if res7.Infcode == 0 {
  4415. item.IsSale = 2
  4416. item.SaleDate = item.SaleDate
  4417. item.Bchno = number
  4418. service.SaveDF(item)
  4419. if item.IsChange == 0 { //没变更,进行变更操作
  4420. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4421. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4422. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4423. var respJSON3 map[string]interface{}
  4424. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4425. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4427. return
  4428. }
  4429. userJSONBytes3, _ := json.Marshal(respJSON3)
  4430. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4431. // utils.ErrorLog("解析失败:%v", err)
  4432. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4433. // return
  4434. //}
  4435. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4436. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4437. utils.ErrorLog("解析失败:%v", err)
  4438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4439. return
  4440. }
  4441. //if res3507for10188.Infcode
  4442. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4443. //res.Output = resSix10265.Output
  4444. res3.ErrMsg = res3507for10188.ErrMsg
  4445. res3.Cainfo = res3507for10188.Cainfo
  4446. res3.WarnMsg = res3507for10188.WarnMsg
  4447. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4448. res3.Infcode = infocode
  4449. } else {
  4450. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4451. utils.ErrorLog("解析失败:%v", err)
  4452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4453. return
  4454. }
  4455. }
  4456. if res3.Infcode == 0 {
  4457. item.IsChange = 1
  4458. item.BgBchno = bg_number
  4459. service.SaveDF2(item)
  4460. } else {
  4461. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4462. }
  4463. }
  4464. } else {
  4465. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4466. }
  4467. }
  4468. } else { //还没结算
  4469. if item.IsChange == 0 { //没变更,进行变更操作
  4470. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4471. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4472. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4473. var respJSON3 map[string]interface{}
  4474. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4475. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4477. return
  4478. }
  4479. userJSONBytes3, _ := json.Marshal(respJSON3)
  4480. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4481. // utils.ErrorLog("解析失败:%v", err)
  4482. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4483. // return
  4484. //}
  4485. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4486. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4487. utils.ErrorLog("解析失败:%v", err)
  4488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4489. return
  4490. }
  4491. //if res3507for10188.Infcode
  4492. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4493. //res.Output = resSix10265.Output
  4494. res3.ErrMsg = res3507for10188.ErrMsg
  4495. res3.Cainfo = res3507for10188.Cainfo
  4496. res3.WarnMsg = res3507for10188.WarnMsg
  4497. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4498. res3.Infcode = infocode
  4499. } else {
  4500. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4501. utils.ErrorLog("解析失败:%v", err)
  4502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4503. return
  4504. }
  4505. }
  4506. if res3.Infcode == 0 {
  4507. item.IsChange = 1
  4508. item.BgBchno = bg_number
  4509. service.SaveDF2(item)
  4510. } else {
  4511. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4512. }
  4513. }
  4514. }
  4515. }
  4516. }
  4517. if len(err) == 0 {
  4518. c.ServeSuccessJSON(map[string]interface{}{
  4519. "msg": "销售变更成功",
  4520. })
  4521. } else {
  4522. c.ServeSuccessJSON(map[string]interface{}{
  4523. "failed_code": -10,
  4524. "msg": err,
  4525. })
  4526. }
  4527. }
  4528. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4529. var struct3502 models.Struct3502
  4530. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4531. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4532. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4533. struct3502.FixmedinsCode = miConfig.Code
  4534. struct3502.Code = miConfig.Code
  4535. struct3502.Opter = role.UserName
  4536. struct3502.RxFlag = "0"
  4537. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  4538. struct3502.OrgName = miConfig.OrgName
  4539. struct3502.AccessKey = miConfig.AccessKey
  4540. struct3502.RequestUrl = miConfig.Url
  4541. struct3502.SecretKey = miConfig.SecretKey
  4542. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4543. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4544. struct3502.Url = miConfig.Url
  4545. struct3502.AppId = miConfig.Cainfo
  4546. struct3502.AppSecret = miConfig.AppSecret
  4547. struct3502.Enckey = miConfig.EncKey
  4548. struct3502.SignKey = miConfig.SignKey
  4549. struct3502.SecretKey = miConfig.SecretKey
  4550. struct3502.InvChgType = chgType
  4551. struct3502.FixmedinsBchno = number
  4552. struct3502.Cnt = strconv.FormatInt(count, 10)
  4553. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  4554. //result1, result2, _ := service.FJyb3502(struct3502)
  4555. if miConfig.MdtrtareaAdmvs == "350500" {
  4556. result1, result2, _ := service.FJyb3502(struct3502)
  4557. //saveLog(result1, result2, "3502", "3502")
  4558. return result1, result2
  4559. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4560. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  4561. return result1, result2
  4562. } else {
  4563. data := make(map[string]interface{})
  4564. data["struct_3502s"] = struct3502
  4565. client := &http.Client{}
  4566. bytesData, _ := json.Marshal(data)
  4567. var req *http.Request
  4568. if miConfig.MdtrtareaAdmvs == "320921" {
  4569. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4570. } else {
  4571. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  4572. }
  4573. resp, _ := client.Do(req)
  4574. defer resp.Body.Close()
  4575. body, ioErr := ioutil.ReadAll(resp.Body)
  4576. if ioErr != nil {
  4577. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4578. }
  4579. var respJSON map[string]interface{}
  4580. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4581. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4582. }
  4583. //var resSix10265 ResultSix10265 //1101结果
  4584. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4585. result, _ := json.Marshal(respJSON)
  4586. return string(result), ""
  4587. }
  4588. }
  4589. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4590. var struct3505 models.Struct3505
  4591. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4592. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4593. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4594. struct3505.FixmedinsBchno = number
  4595. struct3505.Opter = role.UserName
  4596. struct3505.FixmedinsCode = miConfig.Code
  4597. struct3505.Code = miConfig.Code
  4598. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  4599. struct3505.PrscDrName = roles.UserName
  4600. if org_id == 10191 {
  4601. struct3505.PharName = "刘水山"
  4602. struct3505.PharPracCertNo = "2015026350260000002611351127"
  4603. }
  4604. if org_id == 10188 {
  4605. struct3505.PharName = "李汉清"
  4606. struct3505.PharPracCertNo = "30220200932022010034"
  4607. }
  4608. if org_id == 10217 {
  4609. struct3505.PharName = "张敏"
  4610. struct3505.PharPracCertNo = "30220230432090100108"
  4611. }
  4612. if org_id == 10318 {
  4613. struct3505.PharName = "张敏"
  4614. struct3505.PharPracCertNo = "30220230432090100108"
  4615. }
  4616. order := service.GetHisOrderByNumber(pre.BatchNumber)
  4617. struct3505.SetlId = order.SetlId
  4618. struct3505.MdtrtSn = order.MdtrtId
  4619. struct3505.ManuLotnum = drug.Number
  4620. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  4621. struct3505.ExpyEnd = ""
  4622. struct3505.RxFlag = "0"
  4623. struct3505.TrdnFlag = "1"
  4624. struct3505.RtalDocno = order.Number
  4625. struct3505.Url = miConfig.Url
  4626. struct3505.AppId = miConfig.Cainfo
  4627. struct3505.AppSecret = miConfig.AppSecret
  4628. struct3505.Enckey = miConfig.EncKey
  4629. struct3505.SignKey = miConfig.SignKey
  4630. struct3505.SecretKey = miConfig.SecretKey
  4631. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  4632. struct3505.SelRetnCnt = strValue
  4633. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4634. struct3505.SelRetnOpterName = role.UserName
  4635. if order.IsMedicineInsurance == 1 {
  4636. struct3505.MdtrtSetlType = "1"
  4637. } else {
  4638. struct3505.MdtrtSetlType = "2"
  4639. }
  4640. struct3505.OrgName = miConfig.OrgName
  4641. struct3505.AccessKey = miConfig.AccessKey
  4642. struct3505.RequestUrl = miConfig.Url
  4643. struct3505.SecretKey = miConfig.SecretKey
  4644. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4645. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4646. struct3505.DrugTracCodg = drug.DrugCode
  4647. if miConfig.MdtrtareaAdmvs == "350500" {
  4648. result1, result2, _ := service.FJyb3505(struct3505)
  4649. return result1, result2
  4650. } else if miConfig.MdtrtareaAdmvs == "440100" {
  4651. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  4652. return result1, result2
  4653. } else {
  4654. data := make(map[string]interface{})
  4655. data["struct_3505s"] = struct3505
  4656. client := &http.Client{}
  4657. bytesData, _ := json.Marshal(data)
  4658. var req *http.Request
  4659. if miConfig.MdtrtareaAdmvs == "320921" {
  4660. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  4661. } else {
  4662. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  4663. }
  4664. resp, _ := client.Do(req)
  4665. defer resp.Body.Close()
  4666. body, ioErr := ioutil.ReadAll(resp.Body)
  4667. if ioErr != nil {
  4668. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4669. }
  4670. var respJSON map[string]interface{}
  4671. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4673. }
  4674. //var resSix10265 ResultSix10265 //1101结果
  4675. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4676. result, _ := json.Marshal(respJSON)
  4677. return string(result), ""
  4678. }
  4679. }
  4680. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  4681. var struct3506 models.Struct3506
  4682. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4683. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4684. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4685. struct3506.FixmedinsCode = miConfig.Code
  4686. struct3506.Code = miConfig.Code
  4687. struct3506.FixmedinsBchno = number
  4688. struct3506.Opter = role.UserName
  4689. order := service.GetHisOrderByNumber(pre.BatchNumber)
  4690. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  4691. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  4692. struct3506.MdtrtSn = order.MdtrtId
  4693. struct3506.ExpyEnd = ""
  4694. struct3506.RxFlag = "0"
  4695. struct3506.TrdnFlag = "1"
  4696. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  4697. struct3506.SelRetnCnt = strValue
  4698. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4699. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  4700. struct3506.SelRetnOpterName = role.UserName
  4701. struct3506.OrgName = miConfig.OrgName
  4702. struct3506.AccessKey = miConfig.AccessKey
  4703. struct3506.RequestUrl = miConfig.Url
  4704. struct3506.SecretKey = miConfig.SecretKey
  4705. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4706. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4707. struct3506.Url = miConfig.Url
  4708. struct3506.AppId = miConfig.Cainfo
  4709. struct3506.AppSecret = miConfig.AppSecret
  4710. struct3506.Enckey = miConfig.EncKey
  4711. struct3506.SignKey = miConfig.SignKey
  4712. struct3506.SecretKey = miConfig.SecretKey
  4713. struct3506.DrugTracCodg = drug.DrugCode
  4714. if miConfig.MdtrtareaAdmvs == "350500" {
  4715. result1, result2, _ := service.FJyb3506(struct3506)
  4716. return result1, result2
  4717. } else {
  4718. data := make(map[string]interface{})
  4719. data["struct_3506s"] = struct3506
  4720. client := &http.Client{}
  4721. bytesData, _ := json.Marshal(data)
  4722. var req *http.Request
  4723. if miConfig.MdtrtareaAdmvs == "320921" {
  4724. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  4725. } else {
  4726. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  4727. }
  4728. resp, _ := client.Do(req)
  4729. defer resp.Body.Close()
  4730. body, ioErr := ioutil.ReadAll(resp.Body)
  4731. if ioErr != nil {
  4732. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4733. }
  4734. var respJSON map[string]interface{}
  4735. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4737. }
  4738. //var resSix10265 ResultSix10265 //1101结果
  4739. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4740. result, _ := json.Marshal(respJSON)
  4741. return string(result), ""
  4742. }
  4743. }
  4744. func (c *HisApiController) Get1318() {
  4745. adminUser := c.GetAdminUserInfo()
  4746. admin_user_id, _ := c.GetInt64("admin_user_id")
  4747. code := c.GetString("code")
  4748. code = ""
  4749. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4750. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4751. api := ""
  4752. if miConfig.MdtrtareaAdmvs == "320921" {
  4753. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  4754. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  4755. } else {
  4756. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  4757. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  4758. }
  4759. resp, requestErr := http.Get(api)
  4760. if requestErr != nil {
  4761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4762. return
  4763. }
  4764. body, ioErr := ioutil.ReadAll(resp.Body)
  4765. if ioErr != nil {
  4766. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4768. return
  4769. }
  4770. var respJSON map[string]interface{}
  4771. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4772. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4774. return
  4775. }
  4776. //var res Result2406
  4777. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4778. result, _ := json.Marshal(respJSON)
  4779. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4780. utils.ErrorLog("解析失败:%v", err)
  4781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4782. return
  4783. }
  4784. if res.Infcode == "0" {
  4785. c.ServeSuccessJSON(map[string]interface{}{
  4786. "result": "",
  4787. })
  4788. } else {
  4789. c.ServeSuccessJSON(map[string]interface{}{
  4790. "failed_code": -10,
  4791. "msg": res.ErrMsg,
  4792. })
  4793. */return
  4794. //}
  4795. }
  4796. func (c *HisApiController) Get2503() {
  4797. adminUser := c.GetAdminUserInfo()
  4798. admin_user_id, _ := c.GetInt64("admin_user_id")
  4799. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4800. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4801. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  4802. }
  4803. func (c *HisApiController) Get2406() {
  4804. id, _ := c.GetInt64("id")
  4805. record_time := c.GetString("record_time")
  4806. his_patient_id, _ := c.GetInt64("his_patient_id")
  4807. admin_user_id, _ := c.GetInt64("admin_user_id")
  4808. diagnosis_id := c.GetString("diagnosis")
  4809. timeLayout := "2006-01-02"
  4810. loc, _ := time.LoadLocation("Local")
  4811. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4812. if err != nil {
  4813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4814. return
  4815. }
  4816. recordDateTime := theTime.Unix()
  4817. adminUser := c.GetAdminUserInfo()
  4818. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4819. var config []*models.HisXtDiagnoseConfig
  4820. for _, item := range diagnosis_ids {
  4821. id, _ := strconv.ParseInt(item, 10, 64)
  4822. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4823. config = append(config, &diagnosisConfig)
  4824. }
  4825. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4826. fmt.Println(his_patient_id)
  4827. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4828. //timestamp := time.Now().Unix()
  4829. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4830. var patientPrescription models.HisPrescriptionInfo
  4831. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4832. if patientPrescription.ID == 0 {
  4833. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4834. }
  4835. var res2 Result2406
  4836. if miConfig.MdtrtareaAdmvs == "341203" {
  4837. data := make(map[string]interface{})
  4838. client := &http.Client{}
  4839. data["psn_no"] = his.PsnNo
  4840. data["mdtrt_id"] = his.Number
  4841. data["operator"] = roles.UserName
  4842. data["cert_no"] = his.IdCardNo
  4843. data["org_name"] = miConfig.OrgName
  4844. data["psn_name"] = his.Name
  4845. data["ipt_otp_no"] = his.IptOtpNo
  4846. data["ipt_psn_sp_flag_type"] = "0901"
  4847. data["ipt_psn_sp_flag"] = "1"
  4848. data["fixmedins_code"] = miConfig.Code
  4849. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4850. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4851. data["url"] = miConfig.Url
  4852. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  4853. bytesData, _ := json.Marshal(data)
  4854. var req *http.Request
  4855. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  4856. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  4857. resp, _ := client.Do(req)
  4858. defer resp.Body.Close()
  4859. body, ioErr := ioutil.ReadAll(resp.Body)
  4860. if ioErr != nil {
  4861. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4863. return
  4864. }
  4865. var respJSON map[string]interface{}
  4866. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4867. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4869. return
  4870. }
  4871. status := respJSON["data"].(map[string]interface{})["status"].(string)
  4872. if status == "0" {
  4873. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  4874. c.ServeSuccessJSON(map[string]interface{}{
  4875. "failed_code": -10,
  4876. "msg": err_msg,
  4877. })
  4878. return
  4879. }
  4880. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4881. userJSONBytes, _ := json.Marshal(respJSON)
  4882. fmt.Println("log")
  4883. fmt.Println(string(userJSONBytes))
  4884. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4885. utils.ErrorLog("解析失败:%v", err)
  4886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4887. return
  4888. }
  4889. }
  4890. if res2.Infcode != 0 {
  4891. adminUser := c.GetAdminUserInfo()
  4892. errlog := &models.HisOrderError{
  4893. UserOrgId: adminUser.CurrentOrgId,
  4894. Ctime: time.Now().Unix(),
  4895. Mtime: time.Now().Unix(),
  4896. ErrMsg: res2.ErrMsg,
  4897. Status: 1,
  4898. PatientId: id,
  4899. RecordTime: recordDateTime,
  4900. Stage: 3,
  4901. }
  4902. service.CreateErrMsgLog(errlog)
  4903. c.ServeSuccessJSON(map[string]interface{}{
  4904. "failed_code": -10,
  4905. "msg": res2.ErrMsg,
  4906. })
  4907. return
  4908. } else {
  4909. c.ServeSuccessJSON(map[string]interface{}{
  4910. "msg": "上传成功",
  4911. })
  4912. return
  4913. }
  4914. }
  4915. func (c *HisApiController) Get4105() {
  4916. }
  4917. func (c *HisApiController) Post5302() {
  4918. patient_id, _ := c.GetInt64("id")
  4919. admin_user_id, _ := c.GetInt64("admin_user_id")
  4920. p, _ := service.GetHisPatientById(patient_id)
  4921. adminUser := c.GetAdminUserInfo()
  4922. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4923. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4924. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  4925. }
  4926. func (c *HisApiController) Get4104() {
  4927. }
  4928. type Output struct {
  4929. CertNo string `json:"certno"`
  4930. PsnName string `json:"psn_name"`
  4931. CardNo string `json:"card_no"`
  4932. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  4933. CardSN string `json:"card_sn"`
  4934. PsnCertType string `json:"psn_cert_type"`
  4935. MdtrtCertNo string `json:"mdtrt_cert_no"`
  4936. MdtrtCertType string `json:"mdtrt_cert_type"`
  4937. QRCode string `json:"qrCode"`
  4938. EcToken string `json:"ecToken"`
  4939. }
  4940. type AHResponse struct {
  4941. Body AHBody `json:"body"`
  4942. Code int `json:"code"`
  4943. CSBCode int `json:"csbCode"`
  4944. Message string `json:"message"`
  4945. RequestID string `json:"requestId"`
  4946. State struct{} `json:"state"`
  4947. }
  4948. type AHBody struct {
  4949. ErrMsg string `json:"err_msg"`
  4950. InfRefMsgID string `json:"inf_refmsgid"`
  4951. InfCode int `json:"infcode"`
  4952. Output struct {
  4953. Result []struct {
  4954. BasMednFlag string `json:"bas_medn_flag"`
  4955. ChldMedcFlag string `json:"chld_medc_flag"`
  4956. ChrgitmLv string `json:"chrgitm_lv"`
  4957. Cnt float64 `json:"cnt"`
  4958. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  4959. DrtReimFlag string `json:"drt_reim_flag"`
  4960. FeedetlSn string `json:"feedetl_sn"`
  4961. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4962. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  4963. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4964. ListSpItemFlag string `json:"list_sp_item_flag"`
  4965. LmtUsedFlag string `json:"lmt_used_flag"`
  4966. MedChrgitmType string `json:"med_chrgitm_type"`
  4967. Memo string `json:"memo"`
  4968. OverlmtAmt float64 `json:"overlmt_amt"`
  4969. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4970. Pric float64 `json:"pric"`
  4971. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  4972. SelfpayProp float64 `json:"selfpay_prop"`
  4973. } `json:"result"`
  4974. } `json:"output"`
  4975. }
  4976. type Response struct {
  4977. Output Output `json:"output"`
  4978. Infcode int `json:"infcode"`
  4979. InfRefMsgID string `json:"inf_refmsgid"`
  4980. RefMsgTime string `json:"refmsg_time"`
  4981. RespondTime string `json:"respond_time"`
  4982. ErrMsg string `json:"err_msg"`
  4983. WarnMsg string `json:"warn_msg"`
  4984. SignType string `json:"signtype"`
  4985. CAInfo string `json:"cainfo"`
  4986. }
  4987. func (c *HisApiController) Getquerydata() {
  4988. query_type, _ := c.GetInt64("type")
  4989. refd_setl_flag := c.GetString("refd_setl_flag")
  4990. med_type := c.GetString("med_type")
  4991. //admin_user_id,_ := c.GetInt64("admin_user_id")
  4992. cert_no := c.GetString("cert_no")
  4993. psn_no := c.GetString("psn_no")
  4994. start_time := c.GetString("start_time")
  4995. end_time := c.GetString("end_time")
  4996. page, _ := c.GetInt64("page")
  4997. limit, _ := c.GetInt64("limit")
  4998. var bp models.BusinessParams5262
  4999. bp.RefdSetlFlag = refd_setl_flag
  5000. bp.MedType = med_type
  5001. bp.Certno = cert_no
  5002. bp.Psnno = psn_no
  5003. bp.QBegntime = start_time
  5004. bp.QEndtime = end_time
  5005. if query_type == 1 { //本地
  5006. Post5262(c, bp, page, limit)
  5007. } else { //异地
  5008. Post5267(c, bp, page, limit)
  5009. }
  5010. }
  5011. func (c *HisApiController) Drugscheck() {
  5012. admin_user_id, _ := c.GetInt64("admin_user_id")
  5013. adminUser := c.GetAdminUserInfo()
  5014. var queryResult []QueryResult
  5015. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  5016. for _, item := range drugs {
  5017. result := QueryResult{
  5018. ID: item.ID,
  5019. Name: item.DrugName,
  5020. Code: item.MedicalInsuranceNumber,
  5021. List_type_code: "101",
  5022. }
  5023. queryResult = append(queryResult, result)
  5024. }
  5025. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5026. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5027. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5028. for _, item := range queryResult {
  5029. 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)
  5030. }
  5031. }
  5032. func (c *HisApiController) Goodcheck() {
  5033. admin_user_id, _ := c.GetInt64("admin_user_id")
  5034. adminUser := c.GetAdminUserInfo()
  5035. var queryResult []QueryResult
  5036. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  5037. for _, item := range goods {
  5038. result := QueryResult{
  5039. ID: item.ID,
  5040. Name: item.GoodName,
  5041. Code: item.SocialSecurityDirectoryCode,
  5042. List_type_code: "301",
  5043. }
  5044. queryResult = append(queryResult, result)
  5045. }
  5046. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5047. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5048. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5049. for _, item := range queryResult {
  5050. 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)
  5051. //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)
  5052. }
  5053. }
  5054. func (c *HisApiController) Projectcheck() {
  5055. admin_user_id, _ := c.GetInt64("admin_user_id")
  5056. adminUser := c.GetAdminUserInfo()
  5057. var queryResult []QueryResult
  5058. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  5059. for _, item := range projects {
  5060. result := QueryResult{
  5061. ID: item.ID,
  5062. Name: item.ProjectName,
  5063. Code: item.MedicalCode,
  5064. List_type_code: "201",
  5065. }
  5066. queryResult = append(queryResult, result)
  5067. }
  5068. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5069. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5070. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5071. for _, item := range queryResult {
  5072. 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)
  5073. }
  5074. }
  5075. //func (c *HisApiController)CancleDia(){
  5076. //
  5077. // id, _ := c.GetInt64("id")
  5078. // record_time := c.GetString("record_time")
  5079. // his_patient_id, _ := c.GetInt64("his_patient_id")
  5080. //
  5081. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5082. //
  5083. // diagnosis_id := c.GetString("diagnosis")
  5084. // sick_type, _ := c.GetInt64("sick_type")
  5085. // reg_type, _ := c.GetInt64("p_type")
  5086. // begin_time := c.GetString("begin_time")
  5087. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  5088. //
  5089. //
  5090. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  5091. //
  5092. // fmt.Println(acct_used_flag)
  5093. //
  5094. //
  5095. // timeLayout := "2006-01-02"
  5096. // loc, _ := time.LoadLocation("Local")
  5097. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5098. // if err != nil {
  5099. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5100. // return
  5101. // }
  5102. // recordDateTime := theTime.Unix()
  5103. // adminUser := c.GetAdminUserInfo()
  5104. //
  5105. //
  5106. //
  5107. //
  5108. //
  5109. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5110. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5111. // var patientPrescription models.HisPrescriptionInfo
  5112. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5113. // if patientPrescription.ID == 0 {
  5114. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5115. // }
  5116. // //if patientPrescription.Do
  5117. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5118. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5119. //
  5120. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5121. //
  5122. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  5123. //
  5124. // var config []*models.HisXtDiagnoseConfig
  5125. // for _, item := range diagnosis_ids {
  5126. // id, _ := strconv.ParseInt(item, 10, 64)
  5127. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  5128. // config = append(config, &diagnosisConfig)
  5129. // }
  5130. //
  5131. // sickConfig, _ := service.FindSickById(sick_type)
  5132. //
  5133. //
  5134. // data := make(map[string]interface{})
  5135. // client := &http.Client{}
  5136. // data["psn_no"] = his.PsnNo
  5137. // data["mdtrt_id"] = his.Number
  5138. // data["doctor"] = roles.UserName
  5139. // data["department"] = department.Name
  5140. // data["org_name"] = miConfig.OrgName
  5141. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  5142. // data["doctor_id"] = doctor_info.DoctorNumber
  5143. // data["new_doctor_name"] = doctor_info.UserName
  5144. // data["fixmedins_code"] = miConfig.Code
  5145. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5146. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5147. // data["secret_key"] = miConfig.SecretKey
  5148. // data["sick_code"] = sickConfig.CountryCode
  5149. // data["sick_name"] = sickConfig.ClassName
  5150. // data["url"] = miConfig.Url
  5151. // data["ak"] = miConfig.AccessKey
  5152. // data["begin_time"] = begin_time
  5153. // data["cainfo"] = miConfig.Cainfo
  5154. // data["is_vaild"] = "0"
  5155. //
  5156. // data["dept"] = strconv.FormatInt(department.ID, 10)
  5157. // data["config"] = config
  5158. // bytesData, _ := json.Marshal(data)
  5159. //
  5160. // var req *http.Request
  5161. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  5162. // resp, _ := client.Do(req)
  5163. // defer resp.Body.Close()
  5164. // body, ioErr := ioutil.ReadAll(resp.Body)
  5165. // if ioErr != nil {
  5166. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5167. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5168. // return
  5169. // }
  5170. // var respJSON map[string]interface{}
  5171. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5172. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5173. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5174. // return
  5175. // }
  5176. //
  5177. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5178. // userJSONBytes, _ := json.Marshal(respJSON)
  5179. // fmt.Println("log")
  5180. // fmt.Println(string(userJSONBytes))
  5181. //
  5182. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5183. // utils.ErrorLog("解析失败:%v", err)
  5184. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5185. // return
  5186. // }
  5187. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  5188. // res2.Output = ressix10265.Output
  5189. // res2.ErrMsg = ressix10265.ErrMsg
  5190. // res2.Cainfo = ressix10265.Cainfo
  5191. // res2.WarnMsg = ressix10265.WarnMsg
  5192. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5193. // res2.Infcode = infocode
  5194. //
  5195. //}
  5196. func (c *HisApiController) Get4102() {
  5197. order_id, _ := c.GetInt64("order_id")
  5198. admin_user_id, _ := c.GetInt64("admin_user_id")
  5199. stas_type := c.GetString("stas_type")
  5200. order, _ := service.GetHisOrderByIDTwo(order_id)
  5201. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5202. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5203. var pp models.PublicParams
  5204. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5205. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5206. pp.FixmedinsName = miConfig.OrgName
  5207. pp.FixmedinsCode = miConfig.Code
  5208. pp.RequestUrl = miConfig.Url
  5209. pp.Cainfo = miConfig.Cainfo
  5210. pp.SecretKey = miConfig.SecretKey
  5211. pp.AccessKey = miConfig.AccessKey
  5212. pp.OpterName = curRoles.UserName
  5213. if miConfig.MdtrtareaAdmvs == "350500" {
  5214. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5215. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  5216. saveLog(result, request, "4102", "清单确认")
  5217. var dat map[string]interface{}
  5218. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5219. fmt.Println(dat)
  5220. } else {
  5221. fmt.Println(err)
  5222. }
  5223. var empty ResultFourteen
  5224. userJSONBytes, _ := json.Marshal(dat)
  5225. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5226. utils.ErrorLog("解析失败:%v", err)
  5227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5228. return
  5229. }
  5230. if empty.Infcode == 0 {
  5231. c.ServeSuccessJSON(map[string]interface{}{
  5232. "msg": "确认成功",
  5233. })
  5234. return
  5235. }
  5236. } else {
  5237. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  5238. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  5239. result3, request3 := service.Jxyb4105(pp)
  5240. saveLog(result, request, "4102", "清单确认")
  5241. saveLog(result2, request2, "4103", "清单确认")
  5242. saveLog(result3, request3, "4105", "清单统计")
  5243. var dat map[string]interface{}
  5244. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5245. fmt.Println(dat)
  5246. } else {
  5247. fmt.Println(err)
  5248. }
  5249. var empty ResultFourteen
  5250. userJSONBytes, _ := json.Marshal(dat)
  5251. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  5252. utils.ErrorLog("解析失败:%v", err)
  5253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5254. return
  5255. }
  5256. if empty.Infcode == 0 {
  5257. c.ServeSuccessJSON(map[string]interface{}{
  5258. "msg": "确认成功",
  5259. })
  5260. return
  5261. }
  5262. }
  5263. }
  5264. // 对账权限查询
  5265. func (c *HisApiController) Get3260() {
  5266. admin_user_id, _ := c.GetInt64("admin_user_id")
  5267. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5268. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5269. var api string
  5270. var res models.JSResult3260
  5271. if miConfig.MdtrtareaAdmvs == "320921" {
  5272. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5273. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5274. } else {
  5275. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5276. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5277. }
  5278. resp, requestErr := http.Get(api)
  5279. if requestErr != nil {
  5280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5281. return
  5282. }
  5283. body, ioErr := ioutil.ReadAll(resp.Body)
  5284. if ioErr != nil {
  5285. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5287. return
  5288. }
  5289. var respJSON map[string]interface{}
  5290. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5291. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5293. return
  5294. }
  5295. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5296. result, _ := json.Marshal(respJSON)
  5297. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5298. utils.ErrorLog("解析失败:%v", err)
  5299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5300. return
  5301. }
  5302. if res.Infcode == "0" {
  5303. c.ServeSuccessJSON(map[string]interface{}{
  5304. "result": res.Output.Data,
  5305. })
  5306. } else {
  5307. c.ServeSuccessJSON(map[string]interface{}{
  5308. "failed_code": -10,
  5309. "msg": res.ErrMsg,
  5310. })
  5311. return
  5312. }
  5313. }
  5314. func (c *HisApiController) Get3261() {
  5315. admin_user_id, _ := c.GetInt64("admin_user_id")
  5316. //month := c.GetString("month")
  5317. startTime := c.GetString("start_time")
  5318. //endTime, _ := c.GetString("end_time")
  5319. times := strings.Split(startTime, "-")
  5320. stmt_mon := times[0] + times[1]
  5321. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5322. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5323. var api string
  5324. var res models.JSResult3261
  5325. //var res10265 Result5301For10265
  5326. if miConfig.MdtrtareaAdmvs == "320921" {
  5327. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5328. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  5329. } else {
  5330. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5331. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  5332. }
  5333. resp, requestErr := http.Get(api)
  5334. if requestErr != nil {
  5335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5336. return
  5337. }
  5338. body, ioErr := ioutil.ReadAll(resp.Body)
  5339. if ioErr != nil {
  5340. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5342. return
  5343. }
  5344. var respJSON map[string]interface{}
  5345. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5346. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5348. return
  5349. }
  5350. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5351. result, _ := json.Marshal(respJSON)
  5352. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5353. utils.ErrorLog("解析失败:%v", err)
  5354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5355. return
  5356. }
  5357. if res.Infcode == "0" {
  5358. c.ServeSuccessJSON(map[string]interface{}{
  5359. "result": res.Output,
  5360. })
  5361. } else {
  5362. c.ServeSuccessJSON(map[string]interface{}{
  5363. "failed_code": -10,
  5364. "msg": res.ErrMsg,
  5365. })
  5366. return
  5367. }
  5368. }
  5369. type TempFun struct {
  5370. FundKey string
  5371. FundCode string
  5372. }
  5373. func (c *HisApiController) Get3262() {
  5374. admin_user_id, _ := c.GetInt64("admin_user_id")
  5375. startTime := c.GetString("start_time")
  5376. endTime := c.GetString("end_time")
  5377. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5378. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5379. //timeLayout := "2006-01-02"
  5380. //loc, _ := time.LoadLocation("Local")
  5381. //var theStartTIme int64
  5382. //if len(startTime) > 0 {
  5383. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  5384. // if err != nil {
  5385. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5386. // return
  5387. // }
  5388. // theStartTIme = theTime.Unix()
  5389. //}
  5390. //var theEndtTIme int64
  5391. //if len(endTime) > 0 {
  5392. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  5393. // if err != nil {
  5394. // utils.ErrorLog(err.Error())
  5395. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5396. // return
  5397. // }
  5398. // theEndtTIme = theTime.Unix()
  5399. //}
  5400. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  5401. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  5402. for _, team := range datas {
  5403. fmt.Println(team.PsnTime)
  5404. for _, team_two := range datas_two {
  5405. fmt.Println(team_two.PsnTime)
  5406. if team.FundKey == team_two.FundKey {
  5407. fmt.Println(team_two.PsnTime)
  5408. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  5409. fmt.Println(team.PsnTime)
  5410. }
  5411. }
  5412. }
  5413. fmt.Println("1111")
  5414. fmt.Println(datas)
  5415. fmt.Println("1111")
  5416. var twos []models.FixMonRecDetailFileInTwo
  5417. for _, team := range datas {
  5418. var two models.FixMonRecDetailFileInTwo
  5419. two.MedType = team.MedType
  5420. two.Insutype = team.Insutype
  5421. two.PsnType = team.PsnType
  5422. two.MedType = team.MedType
  5423. two.FixBlngAdmdvs = "999999"
  5424. two.InsuAdmdvs = "555555"
  5425. two.PsnTime = team.PsnTime
  5426. two.PsnCnt = team.PsnCnt
  5427. two.FundKey = team.FundKey
  5428. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  5429. fps, _ := strconv.ParseFloat(team.Fund, 64)
  5430. ia, _ := strconv.ParseFloat(team.Amt, 64)
  5431. two.MedfeeSumAmt = ms
  5432. two.InscpAmt = ia
  5433. two.FundPaySumAmt = fps
  5434. twos = append(twos, two)
  5435. }
  5436. //startTime := c.GetString("start_time")
  5437. //endTime, _ := c.GetString("end_time")
  5438. times := strings.Split(startTime, "-")
  5439. stmt_mon := times[0] + times[1]
  5440. var funs []models.FundDetail
  5441. for _, item := range datas {
  5442. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  5443. funs = append(funs, fun...)
  5444. }
  5445. var funInfos []models.Fund
  5446. //for _, item := range funs {
  5447. // var rf []models.FundInfo
  5448. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  5449. // for _, subitem := range rf {
  5450. // var fund models.Fund
  5451. // fund.FundCode = subitem.FundPayType
  5452. // fund.FundName = subitem.FundPayTypeName
  5453. // fund.FundAmt = subitem.FundPayAmt
  5454. // fund.FundKey = item.FundKey
  5455. // fund.InsuAdmdvs = "555555"
  5456. // fund.FixBlngAdmdvs = "999999"
  5457. // funInfos = append(funInfos, fund)
  5458. // }
  5459. //}
  5460. var tempFuns []TempFun
  5461. for _, funInfo := range funInfos {
  5462. var tempFun TempFun
  5463. tempFun.FundKey = funInfo.FundKey
  5464. tempFun.FundCode = funInfo.FundCode
  5465. tempFuns = append(tempFuns, tempFun)
  5466. }
  5467. tempFuns = RemoveRepeatedFunElement(tempFuns)
  5468. fmt.Println(tempFuns)
  5469. var funInfosTwo []models.Fund
  5470. decimal.DivisionPrecision = 2
  5471. for _, item := range tempFuns {
  5472. var fund models.Fund
  5473. for _, subItem := range funInfos {
  5474. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  5475. fund.FundKey = subItem.FundKey
  5476. fund.InsuAdmdvs = subItem.InsuAdmdvs
  5477. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  5478. fund.FundName = subItem.FundName
  5479. fund.FundCode = subItem.FundCode
  5480. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  5481. }
  5482. }
  5483. funInfosTwo = append(funInfosTwo, fund)
  5484. }
  5485. fmt.Println("funInfosTwo")
  5486. fmt.Println(funInfosTwo)
  5487. var upld_btch string
  5488. var empty models.JSResultEmpty
  5489. data := make(map[string]interface{})
  5490. data["org_name"] = miConfig.OrgName
  5491. data["doctor"] = curRoles.UserName
  5492. data["doctor_name"] = curRoles.UserName
  5493. data["fixmedins_code"] = miConfig.Code
  5494. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5495. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5496. data["secret_key"] = miConfig.SecretKey
  5497. data["url"] = miConfig.Url
  5498. data["ak"] = miConfig.AccessKey
  5499. data["cainfo"] = miConfig.Cainfo
  5500. data["datas"] = twos
  5501. data["fund"] = funInfosTwo
  5502. fmt.Println(twos)
  5503. month := time.Unix(1557042972, 0).Format("1")
  5504. year := time.Now().Format("2006")
  5505. month = time.Now().Format("01")
  5506. day := time.Now().Format("02")
  5507. hour := time.Now().Format("15")
  5508. min := time.Now().Format("04")
  5509. sec := time.Now().Format("05")
  5510. fix_fill_date := year + month + day + hour + min + sec
  5511. data["fix_fill_dept"] = miConfig.OrgName
  5512. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  5513. data["fix_fill_psn"] = curRoles.UserName
  5514. data["fix_fill_date"] = fix_fill_date
  5515. data["stmt_loc"] = "2"
  5516. data["setl_mon"] = stmt_mon
  5517. upld_btch = "0"
  5518. data["upld_btch"] = upld_btch
  5519. //fmt.Println(data)
  5520. client := &http.Client{}
  5521. bytesData, _ := json.Marshal(data)
  5522. var req *http.Request
  5523. if miConfig.MdtrtareaAdmvs == "320921" {
  5524. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  5525. } else {
  5526. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  5527. }
  5528. resp, _ := client.Do(req)
  5529. defer resp.Body.Close()
  5530. body, ioErr := ioutil.ReadAll(resp.Body)
  5531. if ioErr != nil {
  5532. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5534. }
  5535. var respJSON map[string]interface{}
  5536. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5537. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5539. }
  5540. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5541. //fmt.Println(respJSON)
  5542. result, _ := json.Marshal(respJSON)
  5543. //fmt.Println(result)
  5544. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  5545. utils.ErrorLog("解析失败:%v", err)
  5546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5547. }
  5548. if empty.Infcode != "0" {
  5549. c.ServeSuccessJSON(map[string]interface{}{
  5550. "failed_code": -10,
  5551. "msg": empty.ErrMsg,
  5552. })
  5553. return
  5554. } else {
  5555. c.ServeSuccessJSON(map[string]interface{}{
  5556. "msg": "上传成功",
  5557. })
  5558. return
  5559. }
  5560. }
  5561. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  5562. newArr = make([]TempFun, 0)
  5563. for i := 0; i < len(arr); i++ {
  5564. repeat := false
  5565. for j := i + 1; j < len(arr); j++ {
  5566. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  5567. repeat = true
  5568. break
  5569. }
  5570. }
  5571. if !repeat {
  5572. newArr = append(newArr, arr[i])
  5573. }
  5574. }
  5575. return
  5576. }
  5577. func (c *HisApiController) Get3263() {
  5578. admin_user_id, _ := c.GetInt64("admin_user_id")
  5579. startTime := c.GetString("start_time")
  5580. //endTime, _ := c.GetString("end_time")
  5581. times := strings.Split(startTime, "-")
  5582. setl_mon := times[0] + times[1]
  5583. upld_btch := "0"
  5584. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5585. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5586. var result3263 models.JSResult3263
  5587. data := make(map[string]interface{})
  5588. data["org_name"] = miConfig.OrgName
  5589. data["doctor"] = curRoles.UserName
  5590. data["doctor_name"] = curRoles.UserName
  5591. data["fixmedins_code"] = miConfig.Code
  5592. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5593. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5594. data["secret_key"] = miConfig.SecretKey
  5595. data["url"] = miConfig.Url
  5596. data["ak"] = miConfig.AccessKey
  5597. data["cainfo"] = miConfig.Cainfo
  5598. data["setl_mon"] = setl_mon
  5599. data["stmt_loc"] = "2"
  5600. data["upld_btch"] = upld_btch
  5601. client := &http.Client{}
  5602. bytesData, _ := json.Marshal(data)
  5603. var req *http.Request
  5604. if miConfig.MdtrtareaAdmvs == "320921" {
  5605. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  5606. } else {
  5607. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  5608. }
  5609. resp, _ := client.Do(req)
  5610. defer resp.Body.Close()
  5611. body, ioErr := ioutil.ReadAll(resp.Body)
  5612. if ioErr != nil {
  5613. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5615. }
  5616. var respJSON map[string]interface{}
  5617. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5620. }
  5621. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5622. fmt.Println(respJSON)
  5623. result, _ := json.Marshal(respJSON)
  5624. fmt.Println(result)
  5625. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  5626. utils.ErrorLog("解析失败:%v", err)
  5627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5628. }
  5629. if result3263.Infcode != "0" {
  5630. c.ServeSuccessJSON(map[string]interface{}{
  5631. "failed_code": -10,
  5632. "msg": result3263.ErrMsg,
  5633. })
  5634. return
  5635. } else {
  5636. c.ServeSuccessJSON(map[string]interface{}{
  5637. "list": result3263.Output,
  5638. })
  5639. return
  5640. }
  5641. }
  5642. func (c *HisApiController) Get3264() {
  5643. admin_user_id, _ := c.GetInt64("admin_user_id")
  5644. startTime := c.GetString("start_time")
  5645. //endTime, _ := c.GetString("end_time")
  5646. times := strings.Split(startTime, "-")
  5647. setl_mon := times[0] + times[1]
  5648. upld_btch := "0"
  5649. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5650. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5651. //solidify_id := []
  5652. var result3263 models.JSResult3263
  5653. data := make(map[string]interface{})
  5654. data["org_name"] = miConfig.OrgName
  5655. data["doctor"] = curRoles.UserName
  5656. data["doctor_name"] = curRoles.UserName
  5657. data["fixmedins_code"] = miConfig.Code
  5658. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5659. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5660. data["secret_key"] = miConfig.SecretKey
  5661. data["url"] = miConfig.Url
  5662. data["ak"] = miConfig.AccessKey
  5663. data["cainfo"] = miConfig.Cainfo
  5664. data["setl_mon"] = setl_mon
  5665. data["stmt_loc"] = "2"
  5666. data["upld_btch"] = upld_btch
  5667. client := &http.Client{}
  5668. bytesData, _ := json.Marshal(data)
  5669. var req3263 *http.Request
  5670. if miConfig.MdtrtareaAdmvs == "320921" {
  5671. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  5672. } else {
  5673. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  5674. }
  5675. resp, _ := client.Do(req3263)
  5676. defer resp.Body.Close()
  5677. body, ioErr := ioutil.ReadAll(resp.Body)
  5678. if ioErr != nil {
  5679. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5681. }
  5682. var respJSON3263 map[string]interface{}
  5683. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  5684. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5686. }
  5687. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5688. fmt.Println(respJSON3263)
  5689. result, _ := json.Marshal(respJSON3263)
  5690. fmt.Println(result)
  5691. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  5692. utils.ErrorLog("解析失败:%v", err)
  5693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5694. }
  5695. var ids []string
  5696. for _, item := range result3263.Output {
  5697. ids = append(ids, item.SolidifyID)
  5698. }
  5699. var empty models.JSResultEmpty
  5700. data2 := make(map[string]interface{})
  5701. data2["org_name"] = miConfig.OrgName
  5702. data2["doctor"] = curRoles.UserName
  5703. data2["doctor_name"] = curRoles.UserName
  5704. data2["fixmedins_code"] = miConfig.Code
  5705. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5706. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5707. data2["secret_key"] = miConfig.SecretKey
  5708. data2["url"] = miConfig.Url
  5709. data2["ak"] = miConfig.AccessKey
  5710. data2["cainfo"] = miConfig.Cainfo
  5711. data2["setl_mon"] = setl_mon
  5712. data2["stmt_loc"] = "2"
  5713. data2["upld_btch"] = upld_btch
  5714. data2["solidify_id"] = ids
  5715. client2 := &http.Client{}
  5716. bytesData2, _ := json.Marshal(data2)
  5717. var req *http.Request
  5718. if miConfig.MdtrtareaAdmvs == "320921" {
  5719. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  5720. } else {
  5721. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  5722. }
  5723. resp2, _ := client2.Do(req)
  5724. defer resp.Body.Close()
  5725. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  5726. if ioErr2 != nil {
  5727. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  5728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5729. }
  5730. var respJSON map[string]interface{}
  5731. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  5732. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5734. }
  5735. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5736. fmt.Println(respJSON)
  5737. result2, _ := json.Marshal(respJSON)
  5738. fmt.Println(result2)
  5739. if err := json.Unmarshal([]byte(result2), &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 (c *HisApiController) Get3265() {
  5757. admin_user_id, _ := c.GetInt64("admin_user_id")
  5758. startTime := c.GetString("start_time")
  5759. //endTime, _ := c.GetString("end_time")
  5760. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5761. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5762. times := strings.Split(startTime, "-")
  5763. setl_mon := times[0] + times[1]
  5764. var upld_btch string
  5765. upld_btch = "0"
  5766. //var empty models.JSResultEmpty
  5767. var result3265 models.JSResult3264
  5768. var result3263 models.JSResult3263
  5769. data2 := make(map[string]interface{})
  5770. data2["org_name"] = miConfig.OrgName
  5771. data2["doctor"] = curRoles.UserName
  5772. data2["doctor_name"] = curRoles.UserName
  5773. data2["fixmedins_code"] = miConfig.Code
  5774. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5775. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5776. data2["secret_key"] = miConfig.SecretKey
  5777. data2["url"] = miConfig.Url
  5778. data2["ak"] = miConfig.AccessKey
  5779. data2["cainfo"] = miConfig.Cainfo
  5780. data2["setl_mon"] = setl_mon
  5781. data2["stmt_loc"] = "2"
  5782. data2["upld_btch"] = upld_btch
  5783. client2 := &http.Client{}
  5784. bytesData2, _ := json.Marshal(data2)
  5785. var req3263 *http.Request
  5786. if miConfig.MdtrtareaAdmvs == "320921" {
  5787. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  5788. } else {
  5789. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  5790. }
  5791. resp2, _ := client2.Do(req3263)
  5792. defer resp2.Body.Close()
  5793. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  5794. if ioErr2 != nil {
  5795. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  5796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5797. }
  5798. var respJSON3263 map[string]interface{}
  5799. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  5800. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5802. }
  5803. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5804. fmt.Println(respJSON3263)
  5805. result2, _ := json.Marshal(respJSON3263)
  5806. fmt.Println(result2)
  5807. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  5808. utils.ErrorLog("解析失败:%v", err)
  5809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5810. }
  5811. var ids []string
  5812. for _, item := range result3263.Output {
  5813. ids = append(ids, item.SolidifyID)
  5814. }
  5815. data := make(map[string]interface{})
  5816. data["org_name"] = miConfig.OrgName
  5817. data["doctor"] = curRoles.UserName
  5818. data["doctor_name"] = curRoles.UserName
  5819. data["fixmedins_code"] = miConfig.Code
  5820. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5821. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5822. data["secret_key"] = miConfig.SecretKey
  5823. data["url"] = miConfig.Url
  5824. data["ak"] = miConfig.AccessKey
  5825. data["cainfo"] = miConfig.Cainfo
  5826. data["setl_mon"] = setl_mon
  5827. data["solidify_id"] = ids
  5828. month := time.Unix(1557042972, 0).Format("1")
  5829. year := time.Now().Format("2006")
  5830. month = time.Now().Format("01")
  5831. day := time.Now().Format("02")
  5832. hour := time.Now().Format("15")
  5833. min := time.Now().Format("04")
  5834. sec := time.Now().Format("05")
  5835. fix_fill_date := year + month + day + hour + min + sec
  5836. data["fix_fill_dept"] = miConfig.OrgName
  5837. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  5838. data["fix_fill_psn"] = curRoles.UserName
  5839. data["fix_fill_date"] = fix_fill_date
  5840. data["stmt_loc"] = "2"
  5841. data["upld_btch"] = upld_btch
  5842. client := &http.Client{}
  5843. bytesData, _ := json.Marshal(data)
  5844. var req *http.Request
  5845. if miConfig.MdtrtareaAdmvs == "320921" {
  5846. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  5847. } else {
  5848. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  5849. }
  5850. resp, _ := client.Do(req)
  5851. defer resp.Body.Close()
  5852. body, ioErr := ioutil.ReadAll(resp.Body)
  5853. if ioErr != nil {
  5854. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5856. }
  5857. var respJSON map[string]interface{}
  5858. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5859. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5861. }
  5862. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5863. fmt.Println(respJSON)
  5864. result, _ := json.Marshal(respJSON)
  5865. fmt.Println(result)
  5866. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  5867. utils.ErrorLog("解析失败:%v", err)
  5868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5869. }
  5870. if result3265.Infcode != "0" {
  5871. c.ServeSuccessJSON(map[string]interface{}{
  5872. "failed_code": -10,
  5873. "msg": result3265.ErrMsg,
  5874. })
  5875. return
  5876. } else {
  5877. c.ServeSuccessJSON(map[string]interface{}{
  5878. "info": result3265.Output,
  5879. })
  5880. return
  5881. }
  5882. }
  5883. func (c *HisApiController) Get3266() {
  5884. admin_user_id, _ := c.GetInt64("admin_user_id")
  5885. startTime := c.GetString("start_time")
  5886. //endTime, _ := c.GetString("end_time")
  5887. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5888. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5889. times := strings.Split(startTime, "-")
  5890. stmt_mon := times[0] + times[1]
  5891. var upld_btch string
  5892. //var empty models.JSResultEmpty
  5893. var result3265 models.JSResult3264
  5894. data := make(map[string]interface{})
  5895. data["org_name"] = miConfig.OrgName
  5896. data["doctor"] = curRoles.UserName
  5897. data["doctor_name"] = curRoles.UserName
  5898. data["fixmedins_code"] = miConfig.Code
  5899. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5900. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5901. data["secret_key"] = miConfig.SecretKey
  5902. data["url"] = miConfig.Url
  5903. data["ak"] = miConfig.AccessKey
  5904. data["cainfo"] = miConfig.Cainfo
  5905. data["setl_mon"] = stmt_mon
  5906. month := time.Unix(1557042972, 0).Format("1")
  5907. year := time.Now().Format("2006")
  5908. month = time.Now().Format("01")
  5909. day := time.Now().Format("02")
  5910. hour := time.Now().Format("15")
  5911. min := time.Now().Format("04")
  5912. sec := time.Now().Format("05")
  5913. fix_fill_date := year + month + day + hour + min + sec
  5914. data["fix_fill_dept"] = miConfig.OrgName
  5915. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  5916. data["fix_fill_psn"] = curRoles.UserName
  5917. data["fix_fill_date"] = fix_fill_date
  5918. data["stmt_loc"] = "2"
  5919. upld_btch = "0"
  5920. data["upld_btch"] = upld_btch
  5921. client := &http.Client{}
  5922. bytesData, _ := json.Marshal(data)
  5923. var req *http.Request
  5924. if miConfig.MdtrtareaAdmvs == "320921" {
  5925. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  5926. } else {
  5927. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  5928. }
  5929. resp, _ := client.Do(req)
  5930. defer resp.Body.Close()
  5931. body, ioErr := ioutil.ReadAll(resp.Body)
  5932. if ioErr != nil {
  5933. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5935. }
  5936. var respJSON map[string]interface{}
  5937. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5938. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5940. }
  5941. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5942. fmt.Println(respJSON)
  5943. result, _ := json.Marshal(respJSON)
  5944. fmt.Println(result)
  5945. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  5946. utils.ErrorLog("解析失败:%v", err)
  5947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5948. }
  5949. if result3265.Infcode != "0" {
  5950. c.ServeSuccessJSON(map[string]interface{}{
  5951. "failed_code": -10,
  5952. "msg": result3265.ErrMsg,
  5953. })
  5954. return
  5955. } else {
  5956. c.ServeSuccessJSON(map[string]interface{}{
  5957. "info": result3265.Output,
  5958. })
  5959. return
  5960. }
  5961. }
  5962. func (c *HisApiController) Get3267() {
  5963. admin_user_id, _ := c.GetInt64("admin_user_id")
  5964. startTime := c.GetString("start_time")
  5965. //endTime, _ := c.GetString("end_time")
  5966. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5967. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5968. times := strings.Split(startTime, "-")
  5969. setl_mon := times[0] + times[1]
  5970. var upld_btch string
  5971. //var empty models.JSResultEmpty
  5972. var result3265 models.JSResult3264
  5973. upld_btch = "0"
  5974. data := make(map[string]interface{})
  5975. data["org_name"] = miConfig.OrgName
  5976. data["doctor"] = curRoles.UserName
  5977. data["doctor_name"] = curRoles.UserName
  5978. data["fixmedins_code"] = miConfig.Code
  5979. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5980. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5981. data["secret_key"] = miConfig.SecretKey
  5982. data["url"] = miConfig.Url
  5983. data["ak"] = miConfig.AccessKey
  5984. data["cainfo"] = miConfig.Cainfo
  5985. data["setl_mon"] = setl_mon
  5986. data["stmt_loc"] = "2"
  5987. data["upld_btch"] = upld_btch
  5988. client := &http.Client{}
  5989. bytesData, _ := json.Marshal(data)
  5990. var req *http.Request
  5991. if miConfig.MdtrtareaAdmvs == "320921" {
  5992. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  5993. } else {
  5994. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  5995. }
  5996. resp, _ := client.Do(req)
  5997. defer resp.Body.Close()
  5998. body, ioErr := ioutil.ReadAll(resp.Body)
  5999. if ioErr != nil {
  6000. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6002. }
  6003. var respJSON map[string]interface{}
  6004. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6005. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6007. }
  6008. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6009. fmt.Println(respJSON)
  6010. result, _ := json.Marshal(respJSON)
  6011. fmt.Println(result)
  6012. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6013. utils.ErrorLog("解析失败:%v", err)
  6014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6015. }
  6016. if result3265.Infcode != "0" {
  6017. c.ServeSuccessJSON(map[string]interface{}{
  6018. "failed_code": -10,
  6019. "msg": result3265.ErrMsg,
  6020. })
  6021. return
  6022. } else {
  6023. c.ServeSuccessJSON(map[string]interface{}{
  6024. "info": result3265.Output.Data,
  6025. })
  6026. return
  6027. }
  6028. }
  6029. func (c *HisApiController) Get3268() {
  6030. admin_user_id, _ := c.GetInt64("admin_user_id")
  6031. startTime := c.GetString("start_time")
  6032. endTime := c.GetString("end_time")
  6033. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6034. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6035. times := strings.Split(startTime, "-")
  6036. setl_mon := times[0] + times[1]
  6037. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6038. var twos []models.FixMonRecDetailFileInTwo
  6039. var funs []models.FundDetail
  6040. for _, item := range datas {
  6041. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6042. funs = append(funs, fun...)
  6043. }
  6044. var funInfos []models.Fund
  6045. //for _, item := range funs {
  6046. // var rf []models.FundInfo
  6047. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6048. // for _, subitem := range rf {
  6049. // var fund models.Fund
  6050. // fund.FundCode = subitem.FundPayType
  6051. // fund.FundName = subitem.FundPayTypeName
  6052. // fund.FundAmt = subitem.FundPayAmt
  6053. // fund.FundKey = item.FundKey
  6054. // fund.InsuAdmdvs = "555555"
  6055. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  6056. // funInfos = append(funInfos, fund)
  6057. // }
  6058. //}
  6059. for _, team := range datas {
  6060. var two models.FixMonRecDetailFileInTwo
  6061. two.SetlDate = time.Now().Format("2006-01-02")
  6062. two.MedType = team.MedType
  6063. two.Insutype = team.Insutype
  6064. two.PsnType = team.PsnType
  6065. two.MedType = team.MedType
  6066. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  6067. two.InsuAdmdvs = team.InsuAdmdvs
  6068. two.PsnTime = team.PsnTime
  6069. two.PsnCnt = team.PsnCnt
  6070. two.FundKey = team.FundKey
  6071. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6072. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6073. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6074. two.MedfeeSumAmt = ms
  6075. two.InscpAmt = ia
  6076. two.FundPaySumAmt = fps
  6077. twos = append(twos, two)
  6078. }
  6079. var upld_btch string
  6080. upld_btch = "0"
  6081. var empty models.JSResultEmpty
  6082. data := make(map[string]interface{})
  6083. data["org_name"] = miConfig.OrgName
  6084. data["doctor"] = curRoles.UserName
  6085. data["doctor_name"] = curRoles.UserName
  6086. data["fixmedins_code"] = miConfig.Code
  6087. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6088. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6089. data["secret_key"] = miConfig.SecretKey
  6090. data["url"] = miConfig.Url
  6091. data["ak"] = miConfig.AccessKey
  6092. data["cainfo"] = miConfig.Cainfo
  6093. data["datas"] = twos
  6094. data["fund"] = funInfos
  6095. data["setl_mon"] = setl_mon
  6096. month := time.Unix(1557042972, 0).Format("1")
  6097. year := time.Now().Format("2006")
  6098. month = time.Now().Format("01")
  6099. day := time.Now().Format("02")
  6100. hour := time.Now().Format("15")
  6101. min := time.Now().Format("04")
  6102. sec := time.Now().Format("05")
  6103. fix_fill_date := year + month + day + hour + min + sec
  6104. data["fix_fill_dept"] = miConfig.OrgName
  6105. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6106. data["fix_fill_psn"] = curRoles.UserName
  6107. data["fix_fill_date"] = fix_fill_date
  6108. data["stmt_loc"] = "2"
  6109. data["upld_btch"] = upld_btch
  6110. client := &http.Client{}
  6111. bytesData, _ := json.Marshal(data)
  6112. var req *http.Request
  6113. if miConfig.MdtrtareaAdmvs == "320921" {
  6114. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6115. } else {
  6116. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  6117. }
  6118. resp, _ := client.Do(req)
  6119. defer resp.Body.Close()
  6120. body, ioErr := ioutil.ReadAll(resp.Body)
  6121. if ioErr != nil {
  6122. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6124. }
  6125. var respJSON map[string]interface{}
  6126. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6127. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6129. }
  6130. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6131. fmt.Println(respJSON)
  6132. result, _ := json.Marshal(respJSON)
  6133. fmt.Println(result)
  6134. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6135. utils.ErrorLog("解析失败:%v", err)
  6136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6137. }
  6138. if empty.Infcode != "0" {
  6139. c.ServeSuccessJSON(map[string]interface{}{
  6140. "failed_code": -10,
  6141. "msg": empty.ErrMsg,
  6142. })
  6143. return
  6144. } else {
  6145. c.ServeSuccessJSON(map[string]interface{}{
  6146. "msg": "上传成功",
  6147. })
  6148. return
  6149. }
  6150. }
  6151. func (c *HisApiController) Get3269() {
  6152. admin_user_id, _ := c.GetInt64("admin_user_id")
  6153. startTime := c.GetString("start_time")
  6154. //endTime, _ := c.GetString("end_time")
  6155. times := strings.Split(startTime, "-")
  6156. setl_mon := times[0] + times[1]
  6157. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6158. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6159. var result3263 models.JSResult3263
  6160. data := make(map[string]interface{})
  6161. data["org_name"] = miConfig.OrgName
  6162. data["doctor"] = curRoles.UserName
  6163. data["doctor_name"] = curRoles.UserName
  6164. data["fixmedins_code"] = miConfig.Code
  6165. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6166. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6167. data["secret_key"] = miConfig.SecretKey
  6168. data["url"] = miConfig.Url
  6169. data["ak"] = miConfig.AccessKey
  6170. data["cainfo"] = miConfig.Cainfo
  6171. data["setl_mon"] = setl_mon
  6172. data["stmt_loc"] = "2"
  6173. client := &http.Client{}
  6174. bytesData, _ := json.Marshal(data)
  6175. var req *http.Request
  6176. if miConfig.MdtrtareaAdmvs == "320921" {
  6177. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6178. } else {
  6179. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  6180. }
  6181. resp, _ := client.Do(req)
  6182. defer resp.Body.Close()
  6183. body, ioErr := ioutil.ReadAll(resp.Body)
  6184. if ioErr != nil {
  6185. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6187. }
  6188. var respJSON map[string]interface{}
  6189. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6190. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6192. }
  6193. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6194. fmt.Println(respJSON)
  6195. result, _ := json.Marshal(respJSON)
  6196. fmt.Println(result)
  6197. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6198. utils.ErrorLog("解析失败:%v", err)
  6199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6200. }
  6201. if result3263.Infcode != "0" {
  6202. c.ServeSuccessJSON(map[string]interface{}{
  6203. "failed_code": -10,
  6204. "msg": result3263.ErrMsg,
  6205. })
  6206. return
  6207. } else {
  6208. c.ServeSuccessJSON(map[string]interface{}{
  6209. "msg": "上传成功",
  6210. })
  6211. return
  6212. }
  6213. }
  6214. func (c *HisApiController) Get3270() {
  6215. admin_user_id, _ := c.GetInt64("admin_user_id")
  6216. startTime := c.GetString("start_time")
  6217. //endTime, _ := c.GetString("end_time")
  6218. times := strings.Split(startTime, "-")
  6219. setl_mon := times[0] + times[1]
  6220. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6221. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6222. var result3263 models.JSResult3263
  6223. data2 := make(map[string]interface{})
  6224. data2["org_name"] = miConfig.OrgName
  6225. data2["doctor"] = curRoles.UserName
  6226. data2["doctor_name"] = curRoles.UserName
  6227. data2["fixmedins_code"] = miConfig.Code
  6228. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6229. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6230. data2["secret_key"] = miConfig.SecretKey
  6231. data2["url"] = miConfig.Url
  6232. data2["ak"] = miConfig.AccessKey
  6233. data2["cainfo"] = miConfig.Cainfo
  6234. data2["setl_mon"] = setl_mon
  6235. data2["stmt_loc"] = "2"
  6236. client2 := &http.Client{}
  6237. bytesData2, _ := json.Marshal(data2)
  6238. var req3263 *http.Request
  6239. if miConfig.MdtrtareaAdmvs == "320921" {
  6240. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6241. } else {
  6242. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6243. }
  6244. resp2, _ := client2.Do(req3263)
  6245. defer resp2.Body.Close()
  6246. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6247. if ioErr2 != nil {
  6248. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6250. }
  6251. var respJSON3263 map[string]interface{}
  6252. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6255. }
  6256. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6257. fmt.Println(respJSON3263)
  6258. result2, _ := json.Marshal(respJSON3263)
  6259. fmt.Println(result2)
  6260. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6261. utils.ErrorLog("解析失败:%v", err)
  6262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6263. }
  6264. var ids []string
  6265. for _, item := range result3263.Output {
  6266. ids = append(ids, item.SolidifyID)
  6267. }
  6268. var result3264 models.JSResult3264
  6269. data := make(map[string]interface{})
  6270. data["org_name"] = miConfig.OrgName
  6271. data["doctor"] = curRoles.UserName
  6272. data["doctor_name"] = curRoles.UserName
  6273. data["fixmedins_code"] = miConfig.Code
  6274. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6275. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6276. data["secret_key"] = miConfig.SecretKey
  6277. data["url"] = miConfig.Url
  6278. data["ak"] = miConfig.AccessKey
  6279. data["cainfo"] = miConfig.Cainfo
  6280. data["setl_mon"] = setl_mon
  6281. data["stmt_loc"] = "2"
  6282. data["solidify_id"] = ids
  6283. client := &http.Client{}
  6284. bytesData, _ := json.Marshal(data)
  6285. var req *http.Request
  6286. if miConfig.MdtrtareaAdmvs == "320921" {
  6287. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  6288. } else {
  6289. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  6290. }
  6291. resp, _ := client.Do(req)
  6292. defer resp.Body.Close()
  6293. body, ioErr := ioutil.ReadAll(resp.Body)
  6294. if ioErr != nil {
  6295. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6297. }
  6298. var respJSON map[string]interface{}
  6299. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6300. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6302. }
  6303. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6304. fmt.Println(respJSON)
  6305. result, _ := json.Marshal(respJSON)
  6306. fmt.Println(result)
  6307. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  6308. utils.ErrorLog("解析失败:%v", err)
  6309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6310. }
  6311. if result3264.Infcode != "0" {
  6312. c.ServeSuccessJSON(map[string]interface{}{
  6313. "failed_code": -10,
  6314. "msg": result3264.ErrMsg,
  6315. })
  6316. return
  6317. } else {
  6318. c.ServeSuccessJSON(map[string]interface{}{
  6319. "info": result3264.Output,
  6320. })
  6321. return
  6322. }
  6323. }
  6324. func (c *HisApiController) Get3271() {
  6325. admin_user_id, _ := c.GetInt64("admin_user_id")
  6326. startTime := c.GetString("start_time")
  6327. //endTime, _ := c.GetString("end_time")
  6328. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6329. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6330. times := strings.Split(startTime, "-")
  6331. setl_mon := times[0] + times[1]
  6332. //var empty models.JSResultEmpty
  6333. var result3265 models.JSResult3264
  6334. var result3263 models.JSResult3263
  6335. data2 := make(map[string]interface{})
  6336. data2["org_name"] = miConfig.OrgName
  6337. data2["doctor"] = curRoles.UserName
  6338. data2["doctor_name"] = curRoles.UserName
  6339. data2["fixmedins_code"] = miConfig.Code
  6340. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6341. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6342. data2["secret_key"] = miConfig.SecretKey
  6343. data2["url"] = miConfig.Url
  6344. data2["ak"] = miConfig.AccessKey
  6345. data2["cainfo"] = miConfig.Cainfo
  6346. data2["setl_mon"] = setl_mon
  6347. data2["stmt_loc"] = "2"
  6348. client2 := &http.Client{}
  6349. bytesData2, _ := json.Marshal(data2)
  6350. var req3263 *http.Request
  6351. if miConfig.MdtrtareaAdmvs == "320921" {
  6352. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6353. } else {
  6354. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  6355. }
  6356. resp2, _ := client2.Do(req3263)
  6357. defer resp2.Body.Close()
  6358. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6359. if ioErr2 != nil {
  6360. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6362. }
  6363. var respJSON3263 map[string]interface{}
  6364. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6367. }
  6368. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6369. fmt.Println(respJSON3263)
  6370. result2, _ := json.Marshal(respJSON3263)
  6371. fmt.Println(result2)
  6372. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6373. utils.ErrorLog("解析失败:%v", err)
  6374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6375. }
  6376. var ids []string
  6377. for _, item := range result3263.Output {
  6378. ids = append(ids, item.SolidifyID)
  6379. }
  6380. data := make(map[string]interface{})
  6381. data["org_name"] = miConfig.OrgName
  6382. data["doctor"] = curRoles.UserName
  6383. data["doctor_name"] = curRoles.UserName
  6384. data["fixmedins_code"] = miConfig.Code
  6385. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6386. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6387. data["secret_key"] = miConfig.SecretKey
  6388. data["url"] = miConfig.Url
  6389. data["ak"] = miConfig.AccessKey
  6390. data["cainfo"] = miConfig.Cainfo
  6391. data["setl_mon"] = setl_mon
  6392. data["solidify_id"] = ids
  6393. month := time.Unix(1557042972, 0).Format("1")
  6394. year := time.Now().Format("2006")
  6395. month = time.Now().Format("01")
  6396. day := time.Now().Format("02")
  6397. hour := time.Now().Format("15")
  6398. min := time.Now().Format("04")
  6399. sec := time.Now().Format("05")
  6400. fix_fill_date := year + month + day + hour + min + sec
  6401. data["fix_fill_dept"] = miConfig.OrgName
  6402. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6403. data["fix_fill_psn"] = curRoles.UserName
  6404. data["fix_fill_date"] = fix_fill_date
  6405. data["stmt_loc"] = "2"
  6406. client := &http.Client{}
  6407. bytesData, _ := json.Marshal(data)
  6408. var req *http.Request
  6409. if miConfig.MdtrtareaAdmvs == "320921" {
  6410. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  6411. } else {
  6412. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  6413. }
  6414. resp, _ := client.Do(req)
  6415. defer resp.Body.Close()
  6416. body, ioErr := ioutil.ReadAll(resp.Body)
  6417. if ioErr != nil {
  6418. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6420. }
  6421. var respJSON map[string]interface{}
  6422. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6423. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6425. }
  6426. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6427. fmt.Println(respJSON)
  6428. result, _ := json.Marshal(respJSON)
  6429. fmt.Println(result)
  6430. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6431. utils.ErrorLog("解析失败:%v", err)
  6432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6433. }
  6434. if result3265.Infcode != "0" {
  6435. c.ServeSuccessJSON(map[string]interface{}{
  6436. "failed_code": -10,
  6437. "msg": result3265.ErrMsg,
  6438. })
  6439. return
  6440. } else {
  6441. c.ServeSuccessJSON(map[string]interface{}{
  6442. "info": result3265.Output.Data,
  6443. })
  6444. return
  6445. }
  6446. }
  6447. func (c *HisApiController) Get3272() {
  6448. admin_user_id, _ := c.GetInt64("admin_user_id")
  6449. startTime := c.GetString("start_time")
  6450. //endTime, _ := c.GetString("end_time")
  6451. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6452. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6453. times := strings.Split(startTime, "-")
  6454. setl_mon := times[0] + times[1]
  6455. var upld_btch string
  6456. //var empty models.JSResultEmpty
  6457. var result3265 models.JSResult3264
  6458. data := make(map[string]interface{})
  6459. data["org_name"] = miConfig.OrgName
  6460. data["doctor"] = curRoles.UserName
  6461. data["doctor_name"] = curRoles.UserName
  6462. data["fixmedins_code"] = miConfig.Code
  6463. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6464. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6465. data["secret_key"] = miConfig.SecretKey
  6466. data["url"] = miConfig.Url
  6467. data["ak"] = miConfig.AccessKey
  6468. data["cainfo"] = miConfig.Cainfo
  6469. data["setl_mon"] = setl_mon
  6470. month := time.Unix(1557042972, 0).Format("1")
  6471. year := time.Now().Format("2006")
  6472. month = time.Now().Format("01")
  6473. day := time.Now().Format("02")
  6474. hour := time.Now().Format("15")
  6475. min := time.Now().Format("04")
  6476. sec := time.Now().Format("05")
  6477. fix_fill_date := year + month + day + hour + min + sec
  6478. data["fix_fill_dept"] = miConfig.OrgName
  6479. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6480. data["fix_fill_psn"] = curRoles.UserName
  6481. data["fix_fill_date"] = fix_fill_date
  6482. data["stmt_loc"] = "2"
  6483. data["upld_btch"] = upld_btch
  6484. client := &http.Client{}
  6485. bytesData, _ := json.Marshal(data)
  6486. var req *http.Request
  6487. if miConfig.MdtrtareaAdmvs == "320921" {
  6488. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  6489. } else {
  6490. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  6491. }
  6492. resp, _ := client.Do(req)
  6493. defer resp.Body.Close()
  6494. body, ioErr := ioutil.ReadAll(resp.Body)
  6495. if ioErr != nil {
  6496. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6498. }
  6499. var respJSON map[string]interface{}
  6500. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6501. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6503. }
  6504. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6505. fmt.Println(respJSON)
  6506. result, _ := json.Marshal(respJSON)
  6507. fmt.Println(result)
  6508. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6509. utils.ErrorLog("解析失败:%v", err)
  6510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6511. }
  6512. if result3265.Infcode != "0" {
  6513. c.ServeSuccessJSON(map[string]interface{}{
  6514. "failed_code": -10,
  6515. "msg": result3265.ErrMsg,
  6516. })
  6517. return
  6518. } else {
  6519. c.ServeSuccessJSON(map[string]interface{}{
  6520. "info": result3265.Output,
  6521. })
  6522. return
  6523. }
  6524. }
  6525. func (c *HisApiController) Get3273() {
  6526. admin_user_id, _ := c.GetInt64("admin_user_id")
  6527. startTime := c.GetString("start_time")
  6528. //endTime, _ := c.GetString("end_time")
  6529. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6530. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6531. times := strings.Split(startTime, "-")
  6532. setl_mon := times[0] + times[1]
  6533. var result3265 models.JSResult3264
  6534. data := make(map[string]interface{})
  6535. data["org_name"] = miConfig.OrgName
  6536. data["doctor"] = curRoles.UserName
  6537. data["doctor_name"] = curRoles.UserName
  6538. data["fixmedins_code"] = miConfig.Code
  6539. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6540. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6541. data["secret_key"] = miConfig.SecretKey
  6542. data["url"] = miConfig.Url
  6543. data["ak"] = miConfig.AccessKey
  6544. data["cainfo"] = miConfig.Cainfo
  6545. data["setl_mon"] = setl_mon
  6546. data["stmt_loc"] = "2"
  6547. client := &http.Client{}
  6548. bytesData, _ := json.Marshal(data)
  6549. var req *http.Request
  6550. if miConfig.MdtrtareaAdmvs == "320921" {
  6551. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  6552. } else {
  6553. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  6554. }
  6555. resp, _ := client.Do(req)
  6556. defer resp.Body.Close()
  6557. body, ioErr := ioutil.ReadAll(resp.Body)
  6558. if ioErr != nil {
  6559. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6561. }
  6562. var respJSON map[string]interface{}
  6563. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6564. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6566. }
  6567. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6568. fmt.Println(respJSON)
  6569. result, _ := json.Marshal(respJSON)
  6570. fmt.Println(result)
  6571. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6572. utils.ErrorLog("解析失败:%v", err)
  6573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6574. }
  6575. if result3265.Infcode != "0" {
  6576. c.ServeSuccessJSON(map[string]interface{}{
  6577. "failed_code": -10,
  6578. "msg": result3265.ErrMsg,
  6579. })
  6580. return
  6581. } else {
  6582. c.ServeSuccessJSON(map[string]interface{}{
  6583. "info": result3265.Output.Data,
  6584. })
  6585. return
  6586. }
  6587. }
  6588. func (c *HisApiController) Get3274() {
  6589. //if miConfig.MdtrtareaAdmvs == "320921" {
  6590. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6591. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6592. // "&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
  6593. //
  6594. //} else {
  6595. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6596. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6597. // "&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
  6598. //
  6599. //}
  6600. }
  6601. func (c *HisApiController) Get3275() {
  6602. //if miConfig.MdtrtareaAdmvs == "320921" {
  6603. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6604. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6605. // "&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
  6606. //
  6607. //} else {
  6608. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6609. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6610. // "&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
  6611. //
  6612. //}
  6613. }
  6614. func (c *HisApiController) Get3276() {
  6615. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6616. //month := c.GetString("month")
  6617. //
  6618. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6619. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6620. //var api string
  6621. //var res Result5301
  6622. //
  6623. //if miConfig.MdtrtareaAdmvs == "320921" {
  6624. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6625. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  6626. //} else {
  6627. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6628. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  6629. //}
  6630. //
  6631. //resp, requestErr := http.Get(api)
  6632. //if requestErr != nil {
  6633. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6634. // return
  6635. //}
  6636. //
  6637. //body, ioErr := ioutil.ReadAll(resp.Body)
  6638. //if ioErr != nil {
  6639. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6640. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6641. // return
  6642. //}
  6643. //var respJSON map[string]interface{}
  6644. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6645. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6646. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6647. // return
  6648. //}
  6649. //
  6650. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6651. //result, _ := json.Marshal(respJSON)
  6652. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6653. // utils.ErrorLog("解析失败:%v", err)
  6654. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6655. // return
  6656. //}
  6657. }
  6658. func (c *HisApiController) Get3277() {
  6659. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6660. //month := c.GetString("month")
  6661. //
  6662. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6663. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6664. //var api string
  6665. //var res Result5301
  6666. //
  6667. //if miConfig.MdtrtareaAdmvs == "320921" {
  6668. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6669. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  6670. //} else {
  6671. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6672. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  6673. //}
  6674. //
  6675. //resp, requestErr := http.Get(api)
  6676. //if requestErr != nil {
  6677. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6678. // return
  6679. //}
  6680. //
  6681. //body, ioErr := ioutil.ReadAll(resp.Body)
  6682. //if ioErr != nil {
  6683. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6684. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6685. // return
  6686. //}
  6687. //var respJSON map[string]interface{}
  6688. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6689. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6690. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6691. // return
  6692. //}
  6693. //
  6694. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6695. //result, _ := json.Marshal(respJSON)
  6696. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6697. // utils.ErrorLog("解析失败:%v", err)
  6698. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6699. // return
  6700. //}
  6701. }
  6702. func (c *HisApiController) GetCFYLJG001() {
  6703. admin_user_id, _ := c.GetInt64("admin_user_id")
  6704. patient_id, _ := c.GetInt64("patient_id")
  6705. his_patient_id, _ := c.GetInt64("his_patient_id")
  6706. record_time := c.GetString("record_time")
  6707. admin_user_id = 3626
  6708. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6709. psn, _ := service.GetPsnByPatientId(patient_id)
  6710. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6711. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6712. var cFYLJG001 models.CFYLJG001
  6713. timeLayout := "2006-01-02"
  6714. loc, _ := time.LoadLocation("Local")
  6715. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6716. if err != nil {
  6717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6718. return
  6719. }
  6720. recordDateTime := theTime.Unix()
  6721. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  6722. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  6723. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  6724. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  6725. //dept, _ := service.GetDepartMentDetail(info.Departments)
  6726. for _, item := range prescriptions {
  6727. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  6728. if his.IdCardType == 1 {
  6729. bas := strings.Split(psn.CardInfo, "|")
  6730. basNumber := bas[1]
  6731. fmt.Println(basNumber)
  6732. card_sn := bas[3]
  6733. card_no := bas[2]
  6734. cFYLJG001.MdtrtCertType = "03"
  6735. cFYLJG001.CardSn = card_sn
  6736. cFYLJG001.MdtrtCertNo = card_no
  6737. cFYLJG001.EcToken = ""
  6738. cFYLJG001.AuthNo = ""
  6739. } else if his.IdCardType == 2 {
  6740. cFYLJG001.MdtrtCertType = "02"
  6741. cFYLJG001.CardSn = ""
  6742. cFYLJG001.MdtrtCertNo = his.IdCardNo
  6743. cFYLJG001.EcToken = ""
  6744. cFYLJG001.AuthNo = ""
  6745. } else if his.IdCardType == 4 {
  6746. cFYLJG001.MdtrtCertType = "01"
  6747. cFYLJG001.CardSn = ""
  6748. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  6749. cFYLJG001.EcToken = psn.VerifyNumber
  6750. cFYLJG001.AuthNo = ""
  6751. }
  6752. cFYLJG001.BizTypeCode = "01"
  6753. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  6754. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  6755. cFYLJG001.RxTypeCode = "1"
  6756. tempTime := time.Unix(item.PreTime, 0)
  6757. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  6758. cFYLJG001.PrscTime = timeFormatOne
  6759. var count float64
  6760. if item.Type == 1 {
  6761. for _, sumItem := range item.HisDoctorAdviceInfo {
  6762. count = count + sumItem.PrescribingNumber
  6763. }
  6764. }
  6765. cFYLJG001.RxDrugCnt = count
  6766. cFYLJG001.ValiDays = "5"
  6767. ts := time.Unix(item.PreTime, 0)
  6768. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  6769. tempTime3 := time.Unix(record_time2, 0)
  6770. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  6771. cFYLJG001.ValiEndTime = timeFormat3
  6772. cFYLJG001.RxCotnFlag = "0"
  6773. for _, subItem := range item.HisDoctorAdviceInfo {
  6774. var drug models.RxDrug
  6775. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  6776. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  6777. drug.RxItemTypeCode = "11"
  6778. drug.DrugDosform = "乳膏剂" //TODO
  6779. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  6780. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6781. }
  6782. drug.MedcWayDscr = subItem.DeliveryWay
  6783. tempTime2 := time.Unix(subItem.StartTime, 0)
  6784. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  6785. drug.MedcBegntime = timeFormatTwo
  6786. if subItem.Day > 0 {
  6787. ts := time.Unix(subItem.StartTime, 0)
  6788. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  6789. tempTime4 := time.Unix(record_time, 0)
  6790. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  6791. drug.MedcEndtime = timeFormat5
  6792. } else {
  6793. tempTime2 := time.Unix(subItem.StartTime, 0)
  6794. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  6795. drug.MedcEndtime = timeFormatTwo
  6796. }
  6797. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  6798. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  6799. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  6800. drug.DrugCnt = subItem.PrescribingNumber
  6801. drug.DrugDosunt = subItem.PrescribingNumberUnit
  6802. drug.DrugGenname = subItem.AdviceName
  6803. drug.MedcWayCodg = subItem.DeliveryWay
  6804. //drug.DrugTotlcnt = subItem.PrescribingNumber
  6805. drug.SinDoscnt = subItem.SingleDose
  6806. drug.SinDosunt = subItem.SingleDoseUnit
  6807. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  6808. drug.UsedFrquName = subItem.ExecutionFrequency
  6809. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6810. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  6811. drug.HospApprFlag = "1"
  6812. cFYLJG001.List = append(cFYLJG001.List, drug)
  6813. }
  6814. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  6815. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  6816. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  6817. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  6818. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  6819. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  6820. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  6821. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  6822. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  6823. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  6824. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  6825. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  6826. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  6827. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  6828. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  6829. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  6830. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  6831. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  6832. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  6833. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  6834. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  6835. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  6836. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  6837. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  6838. tempTime2 := time.Now().Unix()
  6839. tempTime6 := time.Unix(tempTime2, 0)
  6840. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  6841. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  6842. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  6843. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  6844. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  6845. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  6846. //memo := make(map[string]interface{})
  6847. //inputData := make(map[string]interface{}, 0)
  6848. //type MyData struct {
  6849. // Insutype string `json:"insutype"`
  6850. //}
  6851. //
  6852. // data := MyData{
  6853. // Insutype: his.Insutype,
  6854. //}
  6855. //
  6856. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  6857. var config []*models.HisXtDiagnoseConfig
  6858. for _, item := range diagnosis_ids {
  6859. id, _ := strconv.ParseInt(item, 10, 64)
  6860. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6861. config = append(config, &diagnosisConfig)
  6862. }
  6863. for index, subitem := range config {
  6864. if index == 0 {
  6865. var dia models.DiseInfo
  6866. dia.DiagType = "1"
  6867. dia.MaindiagFlag = "1"
  6868. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  6869. dia.DiagCode = subitem.CountryCode
  6870. dia.DiagName = subitem.ClassName
  6871. dia.DiagDept = "肾内科"
  6872. dia.DiagDrNo = doctor.DoctorNumber
  6873. dia.DiagDrName = doctor.UserName
  6874. tempTime3 := time.Unix(item.PreTime, 0)
  6875. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  6876. dia.DiagTime = timeFormatTwo
  6877. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  6878. } else {
  6879. var dia models.DiseInfo
  6880. dia.DiagType = "1"
  6881. dia.MaindiagFlag = "0"
  6882. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  6883. dia.DiagCode = subitem.CountryCode
  6884. dia.DiagName = subitem.ClassName
  6885. dia.DiagDept = "肾内科"
  6886. dia.DiagDrNo = doctor.DoctorNumber
  6887. dia.DiagDrName = doctor.UserName
  6888. tempTime3 := time.Unix(item.PreTime, 0)
  6889. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  6890. dia.DiagTime = timeFormatTwo
  6891. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  6892. }
  6893. }
  6894. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  6895. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  6896. var res ResultCFYLJG001
  6897. var respJSON2 map[string]interface{}
  6898. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6899. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6901. return
  6902. }
  6903. userJSONBytes2, _ := json.Marshal(respJSON2)
  6904. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  6905. utils.ErrorLog("解析失败:%v", err)
  6906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6907. return
  6908. }
  6909. if res.Infcode == -1 {
  6910. c.ServeSuccessJSON(map[string]interface{}{
  6911. "failed_code": -10,
  6912. "msg": res.ErrMsg,
  6913. })
  6914. return
  6915. } else {
  6916. var flow models.HisPrescriptionFlow
  6917. flow.Ctime = time.Now().Unix()
  6918. flow.SignDigest = ""
  6919. flow.RxTraceCode = res.Output.RxTraceCode
  6920. flow.HiRxno = res.Output.HiRxno
  6921. flow.MID = his.Number
  6922. flow.Status = 1
  6923. flow.DCode = doctor_info.DoctorNumber
  6924. flow.OriginalRxFile = ""
  6925. flow.OriginalValue = ""
  6926. flow.SignCertDn = ""
  6927. flow.UserOrgId = 10454
  6928. flow.SignCertSn = ""
  6929. flow.Mtime = time.Now().Unix()
  6930. service.Createflow(&flow)
  6931. c.ServeSuccessJSON(map[string]interface{}{
  6932. "msg": "上传成功",
  6933. })
  6934. }
  6935. }
  6936. }
  6937. func (c *HisApiController) GetCFYLJG002() {
  6938. admin_user_id, _ := c.GetInt64("admin_user_id")
  6939. his_patient_id, _ := c.GetInt64("his_patient_id")
  6940. record_time := c.GetString("record_time")
  6941. admin_user_id = 3626
  6942. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6943. //id, _ := c.GetInt64("id")
  6944. admin_user_id = 3626
  6945. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6946. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6947. flow, _ := service.Getflowtwo(his.Number)
  6948. //his, _ := service.GetHisPatientByNumber(flow.MID)
  6949. //record_time := c.GetString("record_time")
  6950. patient_id, _ := c.GetInt64("patient_id")
  6951. //patient_id = 23834
  6952. //record_time = "2023-09-18"
  6953. timeLayout := "2006-01-02"
  6954. loc, _ := time.LoadLocation("Local")
  6955. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6956. if err != nil {
  6957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6958. return
  6959. }
  6960. recordDateTime := theTime.Unix()
  6961. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  6962. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  6963. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  6964. dept, _ := service.GetDepartMentDetail(info.Departments)
  6965. inputData := make(map[string]interface{})
  6966. inputData["rxTraceCode"] = flow.RxTraceCode
  6967. inputData["hiRxno"] = flow.HiRxno
  6968. inputData["mdtrtId"] = flow.MID
  6969. inputData["patnName"] = his.PsnName
  6970. inputData["psnCertType"] = his.PsnCertType
  6971. inputData["certno"] = his.Certno
  6972. inputData["fixmedinsName"] = miConfig.OrgName
  6973. inputData["fixmedinsCode"] = miConfig.Code
  6974. inputData["drCode"] = doctor_info.DoctorNumber
  6975. inputData["prscDrName"] = doctor_info.UserName
  6976. inputData["pharDeptName"] = dept.Name
  6977. inputData["pharDeptCode"] = dept.Number
  6978. inputData["pharProfttlCodg"] = dept.Name
  6979. inputData["pharProfttlName"] = ""
  6980. inputData["pharCode"] = "HY440309002107"
  6981. inputData["pharCertType"] = "01"
  6982. inputData["pharCertno"] = "430482199408260023"
  6983. inputData["pharName"] = "彭斯遥"
  6984. inputData["pharPracCertNo"] = ""
  6985. tempTime2 := time.Unix(info.Ctime, 0)
  6986. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  6987. inputData["pharChkTime"] = timeFormatTwo
  6988. bytesData, _ := json.Marshal(inputData)
  6989. fmt.Println(string(bytesData))
  6990. encoded := base64.StdEncoding.EncodeToString(bytesData)
  6991. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  6992. if err != nil {
  6993. fmt.Println("Error reading PDF file:", err)
  6994. return
  6995. }
  6996. // 将 PDF 文件内容进行 Base64 编码
  6997. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  6998. fmt.Println(err)
  6999. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  7000. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  7001. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  7002. var res2 Result002
  7003. var respJSON2 map[string]interface{}
  7004. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7005. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7007. return
  7008. }
  7009. userJSONBytes2, _ := json.Marshal(respJSON2)
  7010. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7011. utils.ErrorLog("解析失败:%v", err)
  7012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7013. return
  7014. }
  7015. if res2.Infcode == 0 {
  7016. flow.Ctime = time.Now().Unix()
  7017. flow.SignDigest = res2.Output.SignDigest
  7018. flow.RxFile = res2.Output.RxFile
  7019. flow.MID = his.Number
  7020. flow.Status = 1
  7021. flow.DCode = doctor_info.DoctorNumber
  7022. flow.OriginalRxFile = rx_encoded
  7023. flow.OriginalValue = encoded
  7024. flow.SignCertDn = res2.Output.SignCertDn
  7025. flow.SignCertSn = res2.Output.SignCertSn
  7026. flow.Mtime = time.Now().Unix()
  7027. service.Saveflow(flow)
  7028. c.ServeSuccessJSON(map[string]interface{}{
  7029. "msg": "预签名成功",
  7030. })
  7031. } else {
  7032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7033. return
  7034. }
  7035. }
  7036. func (c *HisApiController) GetCFYLJG003() {
  7037. admin_user_id, _ := c.GetInt64("admin_user_id")
  7038. his_patient_id, _ := c.GetInt64("his_patient_id")
  7039. record_time := c.GetString("record_time")
  7040. admin_user_id = 3626
  7041. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7042. //id, _ := c.GetInt64("id")
  7043. admin_user_id = 3626
  7044. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7045. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7046. flow, _ := service.Getflowtwo(his.Number)
  7047. //id = 3
  7048. patient_id, _ := c.GetInt64("patient_id")
  7049. //patient_id = 23834
  7050. //record_time = "2023-09-18"
  7051. timeLayout := "2006-01-02"
  7052. loc, _ := time.LoadLocation("Local")
  7053. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7054. if err != nil {
  7055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7056. return
  7057. }
  7058. recordDateTime := theTime.Unix()
  7059. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7060. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7061. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7062. dept, _ := service.GetDepartMentDetail(info.Departments)
  7063. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  7064. var cFYLJG003 models.CFYLJG003
  7065. cFYLJG003.RxTraceCode = flow.RxTraceCode
  7066. cFYLJG003.HiRxno = flow.HiRxno
  7067. cFYLJG003.MdtrtID = flow.MID
  7068. cFYLJG003.PatnName = his.Name
  7069. cFYLJG003.Certno = his.Certno
  7070. cFYLJG003.FixmedinsName = miConfig.OrgName
  7071. cFYLJG003.FixmedinsCode = miConfig.Code
  7072. cFYLJG003.DrCode = doctor_info.DoctorNumber
  7073. cFYLJG003.PrscDrName = doctor_info.UserName
  7074. cFYLJG003.PharDeptName = dept.Name
  7075. cFYLJG003.PharDeptCode = dept.Number
  7076. cFYLJG003.PharCode = "HY440309002107"
  7077. cFYLJG003.PharCertType = "01"
  7078. cFYLJG003.PharCertno = "430482199408260023"
  7079. cFYLJG003.PharName = "彭斯遥"
  7080. cFYLJG003.PsnCertType = "01"
  7081. cFYLJG003.RxFile = flow.RxFile
  7082. cFYLJG003.SignDigest = flow.SignDigest
  7083. cFYLJG003.FixmedinsCode = miConfig.Code
  7084. cFYLJG003.PsnCertType = "01"
  7085. cFYLJG003.PharProfttlCodg = dept.Name
  7086. //inputData["pharProfttlCodg"] =dept.Name
  7087. tempTime2 := time.Unix(info.Ctime, 0)
  7088. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7089. cFYLJG003.PharChkTime = timeFormatTwo
  7090. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  7091. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  7092. var res ResultCFYLJG003
  7093. var respJSON2 map[string]interface{}
  7094. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7095. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7097. return
  7098. }
  7099. userJSONBytes2, _ := json.Marshal(respJSON2)
  7100. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7101. utils.ErrorLog("解析失败:%v", err)
  7102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7103. return
  7104. }
  7105. if res.Infcode == -1 {
  7106. c.ServeSuccessJSON(map[string]interface{}{
  7107. "failed_code": -10,
  7108. "msg": res.ErrMsg,
  7109. })
  7110. return
  7111. } else {
  7112. c.ServeSuccessJSON(map[string]interface{}{
  7113. "info": res.Output,
  7114. })
  7115. }
  7116. }
  7117. func (c *HisApiController) GetCFYLJG004() {
  7118. admin_user_id, _ := c.GetInt64("admin_user_id")
  7119. his_patient_id, _ := c.GetInt64("his_patient_id")
  7120. record_time := c.GetString("record_time")
  7121. admin_user_id = 3626
  7122. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7123. //id, _ := c.GetInt64("id")
  7124. admin_user_id = 3626
  7125. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7126. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7127. flow, _ := service.Getflowtwo(his.Number)
  7128. //id = 3
  7129. patient_id, _ := c.GetInt64("patient_id")
  7130. //patient_id = 23834
  7131. //record_time = "2023-09-18"
  7132. timeLayout := "2006-01-02"
  7133. loc, _ := time.LoadLocation("Local")
  7134. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7135. if err != nil {
  7136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7137. return
  7138. }
  7139. recordDateTime := theTime.Unix()
  7140. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7141. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7142. var cFYLJG004 models.CFYLJG004
  7143. cFYLJG004.HiRxno = flow.HiRxno
  7144. cFYLJG004.FixmedinsCode = miConfig.Code
  7145. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  7146. cFYLJG004.UndoDrCertType = "01"
  7147. cFYLJG004.UndoRea = "撤销处方"
  7148. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  7149. cFYLJG004.UndoDrName = doctor_info.UserName
  7150. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  7151. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  7152. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  7153. var res ResultCFYLJG004
  7154. var respJSON2 map[string]interface{}
  7155. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7156. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7158. return
  7159. }
  7160. userJSONBytes2, _ := json.Marshal(respJSON2)
  7161. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7162. utils.ErrorLog("解析失败:%v", err)
  7163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7164. return
  7165. }
  7166. if res.Infcode == -1 {
  7167. c.ServeSuccessJSON(map[string]interface{}{
  7168. "failed_code": -10,
  7169. "msg": res.ErrMsg,
  7170. })
  7171. return
  7172. } else {
  7173. flow.Status = 0
  7174. service.Saveflow(flow)
  7175. c.ServeSuccessJSON(map[string]interface{}{
  7176. "msg": "撤销成功",
  7177. })
  7178. return
  7179. }
  7180. }
  7181. func (c *HisApiController) GetCFYLJG005() {
  7182. admin_user_id, _ := c.GetInt64("admin_user_id")
  7183. his_patient_id, _ := c.GetInt64("his_patient_id")
  7184. //record_time := c.GetString("record_time")
  7185. admin_user_id = 3626
  7186. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7187. //id, _ := c.GetInt64("id")
  7188. admin_user_id = 3626
  7189. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7190. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7191. flow, _ := service.Getflowtwo(his.Number)
  7192. //id = 3
  7193. var cFYLJG005 models.CFYLJG005
  7194. //patient_id, _ := c.GetInt64("patient_id")
  7195. cFYLJG005.HiRxno = flow.HiRxno
  7196. cFYLJG005.MdtrtID = flow.MID
  7197. cFYLJG005.EcToken = ""
  7198. cFYLJG005.PsnName = his.Name
  7199. cFYLJG005.PsnCertType = "01"
  7200. cFYLJG005.Certno = his.IdCardNo
  7201. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  7202. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  7203. var res ResultCFYLJG005
  7204. var respJSON2 map[string]interface{}
  7205. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7206. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7208. return
  7209. }
  7210. userJSONBytes2, _ := json.Marshal(respJSON2)
  7211. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7212. utils.ErrorLog("解析失败:%v", err)
  7213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7214. return
  7215. }
  7216. if res.Infcode == -1 {
  7217. c.ServeSuccessJSON(map[string]interface{}{
  7218. "failed_code": -10,
  7219. "msg": res.ErrMsg,
  7220. })
  7221. return
  7222. } else {
  7223. c.ServeSuccessJSON(map[string]interface{}{
  7224. "info": res.Output,
  7225. })
  7226. return
  7227. }
  7228. }
  7229. func (c *HisApiController) GetCFYLJG006() {
  7230. admin_user_id, _ := c.GetInt64("admin_user_id")
  7231. his_patient_id, _ := c.GetInt64("his_patient_id")
  7232. admin_user_id = 3626
  7233. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7234. //id, _ := c.GetInt64("id")
  7235. admin_user_id = 3626
  7236. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7237. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7238. flow, _ := service.Getflowtwo(his.Number)
  7239. //id = 3
  7240. patient_id, _ := c.GetInt64("patient_id")
  7241. var cFYLJG006 models.CFYLJG006
  7242. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  7243. cFYLJG006.HiRxno = flow.HiRxno
  7244. cFYLJG006.MdtrtID = flow.MID
  7245. cFYLJG006.PsnName = patient.Name
  7246. cFYLJG006.PsnCertType = "01"
  7247. cFYLJG006.Certno = patient.IdCardNo
  7248. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  7249. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  7250. var res ResultCFYLJG006
  7251. var respJSON2 map[string]interface{}
  7252. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7255. return
  7256. }
  7257. userJSONBytes2, _ := json.Marshal(respJSON2)
  7258. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7259. utils.ErrorLog("解析失败:%v", err)
  7260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7261. return
  7262. }
  7263. if res.Infcode == -1 {
  7264. c.ServeSuccessJSON(map[string]interface{}{
  7265. "failed_code": -10,
  7266. "msg": res.ErrMsg,
  7267. })
  7268. return
  7269. } else {
  7270. c.ServeSuccessJSON(map[string]interface{}{
  7271. "info": res.Output,
  7272. })
  7273. return
  7274. }
  7275. }
  7276. func (c *HisApiController) GetCFYLJG007() {
  7277. admin_user_id, _ := c.GetInt64("admin_user_id")
  7278. his_patient_id, _ := c.GetInt64("his_patient_id")
  7279. admin_user_id = 3626
  7280. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7281. //id, _ := c.GetInt64("id")
  7282. admin_user_id = 3626
  7283. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7284. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7285. flow, _ := service.Getflowtwo(his.Number)
  7286. //id = 3
  7287. patient_id, _ := c.GetInt64("patient_id")
  7288. var cFYLJG007 models.CFYLJG007
  7289. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  7290. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7291. cFYLJG007.HiRxno = flow.HiRxno
  7292. cFYLJG007.MdtrtID = flow.MID
  7293. cFYLJG007.PsnNo = his.PsnNo
  7294. cFYLJG007.PsnCertType = "01"
  7295. cFYLJG007.Certno = patient.IdCardNo
  7296. cFYLJG007.PsnName = patient.Name
  7297. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  7298. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  7299. var res ResultCFYLJG007
  7300. var respJSON2 map[string]interface{}
  7301. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7302. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7304. return
  7305. }
  7306. userJSONBytes2, _ := json.Marshal(respJSON2)
  7307. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7308. utils.ErrorLog("解析失败:%v", err)
  7309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7310. return
  7311. }
  7312. if res.Infcode == -1 {
  7313. c.ServeSuccessJSON(map[string]interface{}{
  7314. "failed_code": -10,
  7315. "msg": res.ErrMsg,
  7316. })
  7317. return
  7318. } else {
  7319. c.ServeSuccessJSON(map[string]interface{}{
  7320. "info": res,
  7321. })
  7322. return
  7323. }
  7324. }
  7325. func (c *HisApiController) GetCFYLJG008() {
  7326. admin_user_id, _ := c.GetInt64("admin_user_id")
  7327. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7328. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7329. var cFYLJG008 models.CFYLJG008
  7330. //id, _ := c.GetInt64("id")
  7331. patient_id, _ := c.GetInt64("patient_id")
  7332. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7333. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  7334. //id = 3
  7335. //flow, _ := service.Getflow(id)
  7336. //his, _ := service.GetHisPatientByNumber(flow.MID)
  7337. //
  7338. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7339. //patient_id, _ := c.GetInt64("patient_id")
  7340. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7341. record_time := c.GetString("record_time")
  7342. admin_user_id = 3626
  7343. patient_id = 19424
  7344. //his_patient_id = 263947
  7345. record_time = "2023-08-29"
  7346. timeLayout := "2006-01-02"
  7347. loc, _ := time.LoadLocation("Local")
  7348. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7349. if err != nil {
  7350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7351. return
  7352. }
  7353. recordDateTime := theTime.Unix()
  7354. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7355. cFYLJG008.FixmedinsName = ""
  7356. cFYLJG008.Lat = ""
  7357. cFYLJG008.Lng = ""
  7358. cFYLJG008.OrderType = "1"
  7359. cFYLJG008.PoolareaNo = ""
  7360. cFYLJG008.Lng = ""
  7361. cFYLJG008.PageNum = 1
  7362. cFYLJG008.PageSize = 10
  7363. var MPI models.MedinsProdInvChgDDTO
  7364. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  7365. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  7366. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  7367. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  7368. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  7369. var res ResultCFYLJG008
  7370. var respJSON2 map[string]interface{}
  7371. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7372. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7374. return
  7375. }
  7376. userJSONBytes2, _ := json.Marshal(respJSON2)
  7377. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  7378. utils.ErrorLog("解析失败:%v", err)
  7379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7380. return
  7381. }
  7382. if res.Infcode == -1 {
  7383. c.ServeSuccessJSON(map[string]interface{}{
  7384. "failed_code": -10,
  7385. "msg": res.ErrMsg,
  7386. })
  7387. return
  7388. } else {
  7389. c.ServeSuccessJSON(map[string]interface{}{
  7390. "info": res.Output,
  7391. })
  7392. return
  7393. }
  7394. }
  7395. func (c *HisApiController) GetBL4201A() {
  7396. order_id, _ := c.GetInt64("order_id")
  7397. admin_user_id, _ := c.GetInt64("admin_user_id")
  7398. order, _ := service.GetHisOrderByIDTwo(order_id)
  7399. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7400. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  7401. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  7402. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7403. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7404. department, _ := service.GetDepartMentDetail(his.Departments)
  7405. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  7406. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  7407. if order.ID == 0 {
  7408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  7409. return
  7410. }
  7411. var struct4201A models.Struct4201A
  7412. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  7413. for _, items := range order_info {
  7414. memo := make(map[string]interface{})
  7415. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  7416. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  7417. fsiOPFLD.MedType = "14"
  7418. fsiOPFLD.BkkpSn = items.FeedetlSn
  7419. fsiOPFLD.FixmedinsCode = miConfig.Code
  7420. fsiOPFLD.FixmedinsName = miConfig.OrgName
  7421. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  7422. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  7423. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  7424. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7425. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  7426. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7427. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7428. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7429. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7430. fsiOPFLD.BilgDeptName = department.Name
  7431. fsiOPFLD.BilgDeptCodg = department.Number
  7432. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7433. fsiOPFLD.BilgDrName = doctor.UserName
  7434. fsiOPFLD.MedChrgitmType = "09"
  7435. memo["hosp_appr_flag"] = "1"
  7436. memo["invoice_no"] = order.MdtrtId
  7437. memo["memo"] = "自费"
  7438. bytesData, _ := json.Marshal(memo)
  7439. fsiOPFLD.Memo = string(bytesData)
  7440. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7441. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  7442. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  7443. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7444. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7445. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7446. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  7447. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  7448. fsiOPFLD.BilgDeptName = department.Name
  7449. fsiOPFLD.BilgDeptCodg = department.Number
  7450. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7451. fsiOPFLD.BilgDrName = doctor.UserName
  7452. switch items.HisPrescriptionProject.HisProject.CostClassify {
  7453. case 0:
  7454. break
  7455. case 1:
  7456. fsiOPFLD.MedChrgitmType = "14"
  7457. break
  7458. case 2:
  7459. fsiOPFLD.MedChrgitmType = "05"
  7460. break
  7461. case 3:
  7462. fsiOPFLD.MedChrgitmType = "03"
  7463. break
  7464. case 4:
  7465. fsiOPFLD.MedChrgitmType = "03"
  7466. break
  7467. case 5:
  7468. fsiOPFLD.MedChrgitmType = "08"
  7469. break
  7470. case 6:
  7471. fsiOPFLD.MedChrgitmType = "14"
  7472. break
  7473. case 7:
  7474. fsiOPFLD.MedChrgitmType = "14"
  7475. break
  7476. case 8:
  7477. fsiOPFLD.MedChrgitmType = "03"
  7478. break
  7479. case 9:
  7480. fsiOPFLD.MedChrgitmType = "14"
  7481. break
  7482. case 10:
  7483. fsiOPFLD.MedChrgitmType = "14"
  7484. break
  7485. case 11:
  7486. fsiOPFLD.MedChrgitmType = "06"
  7487. break
  7488. case 12:
  7489. fsiOPFLD.MedChrgitmType = "12"
  7490. break
  7491. case 13:
  7492. fsiOPFLD.MedChrgitmType = "01"
  7493. break
  7494. case 14:
  7495. fsiOPFLD.MedChrgitmType = "04"
  7496. break
  7497. case 15:
  7498. fsiOPFLD.MedChrgitmType = "14"
  7499. break
  7500. }
  7501. memo["hosp_appr_flag"] = "1"
  7502. memo["invoice_no"] = order.MdtrtId
  7503. memo["memo"] = "自费"
  7504. bytesData, _ := json.Marshal(memo)
  7505. fsiOPFLD.Memo = string(bytesData)
  7506. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7507. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  7508. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7509. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7510. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7511. fsiOPFLD.BilgDeptName = department.Name
  7512. fsiOPFLD.BilgDeptCodg = department.Number
  7513. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7514. fsiOPFLD.BilgDrName = doctor.UserName
  7515. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  7516. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  7517. fsiOPFLD.MedChrgitmType = "08"
  7518. memo["hosp_appr_flag"] = "1"
  7519. memo["invoice_no"] = order.MdtrtId
  7520. memo["memo"] = "自费"
  7521. bytesData, _ := json.Marshal(memo)
  7522. fsiOPFLD.Memo = string(bytesData)
  7523. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7524. }
  7525. }
  7526. }
  7527. for _, items := range order_info_two {
  7528. memo := make(map[string]interface{})
  7529. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  7530. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  7531. fsiOPFLD.MedType = "14"
  7532. fsiOPFLD.BkkpSn = items.FeedetlSn
  7533. fsiOPFLD.FixmedinsCode = miConfig.Code
  7534. fsiOPFLD.FixmedinsName = miConfig.OrgName
  7535. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  7536. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  7537. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  7538. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7539. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  7540. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7541. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7542. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7543. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7544. fsiOPFLD.BilgDeptName = department.Name
  7545. fsiOPFLD.BilgDeptCodg = department.Number
  7546. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7547. fsiOPFLD.BilgDrName = doctor.UserName
  7548. fsiOPFLD.MedChrgitmType = "09"
  7549. memo["hosp_appr_flag"] = "1"
  7550. memo["invoice_no"] = order.MdtrtId
  7551. memo["memo"] = "自费"
  7552. bytesData, _ := json.Marshal(memo)
  7553. fsiOPFLD.Memo = string(bytesData)
  7554. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7555. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  7556. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  7557. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7558. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7559. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  7560. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  7561. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7562. fsiOPFLD.BilgDeptName = department.Name
  7563. fsiOPFLD.BilgDeptCodg = department.Number
  7564. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7565. fsiOPFLD.BilgDrName = doctor.UserName
  7566. switch items.HisPrescriptionProject.HisProject.CostClassify {
  7567. case 0:
  7568. break
  7569. case 1:
  7570. fsiOPFLD.MedChrgitmType = "14"
  7571. break
  7572. case 2:
  7573. fsiOPFLD.MedChrgitmType = "05"
  7574. break
  7575. case 3:
  7576. fsiOPFLD.MedChrgitmType = "03"
  7577. break
  7578. case 4:
  7579. fsiOPFLD.MedChrgitmType = "03"
  7580. break
  7581. case 5:
  7582. fsiOPFLD.MedChrgitmType = "08"
  7583. break
  7584. case 6:
  7585. fsiOPFLD.MedChrgitmType = "14"
  7586. break
  7587. case 7:
  7588. fsiOPFLD.MedChrgitmType = "14"
  7589. break
  7590. case 8:
  7591. fsiOPFLD.MedChrgitmType = "03"
  7592. break
  7593. case 9:
  7594. fsiOPFLD.MedChrgitmType = "14"
  7595. break
  7596. case 10:
  7597. fsiOPFLD.MedChrgitmType = "14"
  7598. break
  7599. case 11:
  7600. fsiOPFLD.MedChrgitmType = "06"
  7601. break
  7602. case 12:
  7603. fsiOPFLD.MedChrgitmType = "12"
  7604. break
  7605. case 13:
  7606. fsiOPFLD.MedChrgitmType = "01"
  7607. break
  7608. case 14:
  7609. fsiOPFLD.MedChrgitmType = "04"
  7610. break
  7611. case 15:
  7612. fsiOPFLD.MedChrgitmType = "14"
  7613. break
  7614. }
  7615. memo["hosp_appr_flag"] = "1"
  7616. memo["invoice_no"] = order.MdtrtId
  7617. memo["memo"] = "自费"
  7618. bytesData, _ := json.Marshal(memo)
  7619. fsiOPFLD.Memo = string(bytesData)
  7620. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7621. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  7622. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7623. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7624. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7625. fsiOPFLD.BilgDeptName = department.Name
  7626. fsiOPFLD.BilgDeptCodg = department.Number
  7627. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7628. fsiOPFLD.BilgDrName = doctor.UserName
  7629. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  7630. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  7631. fsiOPFLD.MedChrgitmType = "08"
  7632. memo["hosp_appr_flag"] = "1"
  7633. memo["invoice_no"] = order.MdtrtId
  7634. memo["memo"] = "自费"
  7635. bytesData, _ := json.Marshal(memo)
  7636. fsiOPFLD.Memo = string(bytesData)
  7637. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7638. }
  7639. }
  7640. }
  7641. fmt.Println(fsiOPFLDs)
  7642. struct4201A.Fopfd = fsiOPFLDs
  7643. fmt.Println(struct4201A.Fopfd)
  7644. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  7645. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  7646. var res2 ResultSix
  7647. var respJSON2 map[string]interface{}
  7648. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7649. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7651. return
  7652. }
  7653. userJSONBytes2, _ := json.Marshal(respJSON2)
  7654. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7655. utils.ErrorLog("解析失败:%v", err)
  7656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7657. return
  7658. }
  7659. if res2.Infcode != 0 {
  7660. c.ServeSuccessJSON(map[string]interface{}{
  7661. "failed_code": -10,
  7662. "msg": res2.ErrMsg,
  7663. })
  7664. return
  7665. } else {
  7666. order.IsUploadOrderInfo = 1
  7667. service.UpdateOrder(order)
  7668. c.ServeSuccessJSON(map[string]interface{}{
  7669. "msg": "上传成功",
  7670. })
  7671. }
  7672. }
  7673. func (c *HisApiController) Get2505() {
  7674. admin_user_id, _ := c.GetInt64("admin_user_id")
  7675. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  7676. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7677. 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)
  7678. }
  7679. func (c *HisApiController) Get4201A() {
  7680. order_id, _ := c.GetInt64("order_id")
  7681. admin_user_id, _ := c.GetInt64("admin_user_id")
  7682. order, _ := service.GetHisOrderByIDTwo(order_id)
  7683. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7684. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  7685. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  7686. //order_info = append(order_info, order_info_two...)
  7687. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7688. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7689. department, _ := service.GetDepartMentDetail(his.Departments)
  7690. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  7691. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  7692. if order.ID == 0 {
  7693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  7694. return
  7695. }
  7696. var struct4201A models.Struct4201A
  7697. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  7698. for _, items := range order_info {
  7699. memo := make(map[string]interface{})
  7700. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  7701. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  7702. fsiOPFLD.MedType = "14"
  7703. fsiOPFLD.BkkpSn = items.FeedetlSn
  7704. fsiOPFLD.FixmedinsCode = miConfig.Code
  7705. fsiOPFLD.FixmedinsName = miConfig.OrgName
  7706. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  7707. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  7708. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  7709. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7710. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  7711. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7712. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7713. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7714. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7715. fsiOPFLD.BilgDeptName = department.Name
  7716. fsiOPFLD.BilgDeptCodg = department.Number
  7717. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7718. fsiOPFLD.BilgDrName = doctor.UserName
  7719. fsiOPFLD.MedChrgitmType = "09"
  7720. memo["hosp_appr_flag"] = "1"
  7721. memo["invoice_no"] = order.MdtrtId
  7722. memo["memo"] = "自费"
  7723. bytesData, _ := json.Marshal(memo)
  7724. fsiOPFLD.Memo = string(bytesData)
  7725. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7726. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  7727. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  7728. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7729. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7730. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7731. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  7732. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  7733. fsiOPFLD.BilgDeptName = department.Name
  7734. fsiOPFLD.BilgDeptCodg = department.Number
  7735. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7736. fsiOPFLD.BilgDrName = doctor.UserName
  7737. switch items.HisPrescriptionProject.HisProject.CostClassify {
  7738. case 0:
  7739. break
  7740. case 1:
  7741. fsiOPFLD.MedChrgitmType = "14"
  7742. break
  7743. case 2:
  7744. fsiOPFLD.MedChrgitmType = "05"
  7745. break
  7746. case 3:
  7747. fsiOPFLD.MedChrgitmType = "03"
  7748. break
  7749. case 4:
  7750. fsiOPFLD.MedChrgitmType = "03"
  7751. break
  7752. case 5:
  7753. fsiOPFLD.MedChrgitmType = "08"
  7754. break
  7755. case 6:
  7756. fsiOPFLD.MedChrgitmType = "14"
  7757. break
  7758. case 7:
  7759. fsiOPFLD.MedChrgitmType = "14"
  7760. break
  7761. case 8:
  7762. fsiOPFLD.MedChrgitmType = "03"
  7763. break
  7764. case 9:
  7765. fsiOPFLD.MedChrgitmType = "14"
  7766. break
  7767. case 10:
  7768. fsiOPFLD.MedChrgitmType = "14"
  7769. break
  7770. case 11:
  7771. fsiOPFLD.MedChrgitmType = "06"
  7772. break
  7773. case 12:
  7774. fsiOPFLD.MedChrgitmType = "12"
  7775. break
  7776. case 13:
  7777. fsiOPFLD.MedChrgitmType = "01"
  7778. break
  7779. case 14:
  7780. fsiOPFLD.MedChrgitmType = "04"
  7781. break
  7782. case 15:
  7783. fsiOPFLD.MedChrgitmType = "14"
  7784. break
  7785. }
  7786. memo["hosp_appr_flag"] = "1"
  7787. memo["invoice_no"] = order.MdtrtId
  7788. memo["memo"] = "自费"
  7789. bytesData, _ := json.Marshal(memo)
  7790. fsiOPFLD.Memo = string(bytesData)
  7791. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7792. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  7793. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7794. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7795. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7796. fsiOPFLD.BilgDeptName = department.Name
  7797. fsiOPFLD.BilgDeptCodg = department.Number
  7798. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7799. fsiOPFLD.BilgDrName = doctor.UserName
  7800. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  7801. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  7802. fsiOPFLD.MedChrgitmType = "08"
  7803. memo["hosp_appr_flag"] = "1"
  7804. memo["invoice_no"] = order.MdtrtId
  7805. memo["memo"] = "自费"
  7806. bytesData, _ := json.Marshal(memo)
  7807. fsiOPFLD.Memo = string(bytesData)
  7808. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7809. }
  7810. }
  7811. }
  7812. for _, items := range order_info_two {
  7813. memo := make(map[string]interface{})
  7814. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  7815. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  7816. fsiOPFLD.MedType = "14"
  7817. fsiOPFLD.BkkpSn = items.FeedetlSn
  7818. fsiOPFLD.FixmedinsCode = miConfig.Code
  7819. fsiOPFLD.FixmedinsName = miConfig.OrgName
  7820. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  7821. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  7822. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  7823. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7824. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  7825. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7826. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  7827. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7828. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  7829. fsiOPFLD.BilgDeptName = department.Name
  7830. fsiOPFLD.BilgDeptCodg = department.Number
  7831. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7832. fsiOPFLD.BilgDrName = doctor.UserName
  7833. fsiOPFLD.MedChrgitmType = "09"
  7834. memo["hosp_appr_flag"] = "1"
  7835. memo["invoice_no"] = order.MdtrtId
  7836. memo["memo"] = "自费"
  7837. bytesData, _ := json.Marshal(memo)
  7838. fsiOPFLD.Memo = string(bytesData)
  7839. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7840. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  7841. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  7842. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7843. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7844. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  7845. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  7846. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  7847. fsiOPFLD.BilgDeptName = department.Name
  7848. fsiOPFLD.BilgDeptCodg = department.Number
  7849. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7850. fsiOPFLD.BilgDrName = doctor.UserName
  7851. switch items.HisPrescriptionProject.HisProject.CostClassify {
  7852. case 0:
  7853. break
  7854. case 1:
  7855. fsiOPFLD.MedChrgitmType = "14"
  7856. break
  7857. case 2:
  7858. fsiOPFLD.MedChrgitmType = "05"
  7859. break
  7860. case 3:
  7861. fsiOPFLD.MedChrgitmType = "03"
  7862. break
  7863. case 4:
  7864. fsiOPFLD.MedChrgitmType = "03"
  7865. break
  7866. case 5:
  7867. fsiOPFLD.MedChrgitmType = "08"
  7868. break
  7869. case 6:
  7870. fsiOPFLD.MedChrgitmType = "14"
  7871. break
  7872. case 7:
  7873. fsiOPFLD.MedChrgitmType = "14"
  7874. break
  7875. case 8:
  7876. fsiOPFLD.MedChrgitmType = "03"
  7877. break
  7878. case 9:
  7879. fsiOPFLD.MedChrgitmType = "14"
  7880. break
  7881. case 10:
  7882. fsiOPFLD.MedChrgitmType = "14"
  7883. break
  7884. case 11:
  7885. fsiOPFLD.MedChrgitmType = "06"
  7886. break
  7887. case 12:
  7888. fsiOPFLD.MedChrgitmType = "12"
  7889. break
  7890. case 13:
  7891. fsiOPFLD.MedChrgitmType = "01"
  7892. break
  7893. case 14:
  7894. fsiOPFLD.MedChrgitmType = "04"
  7895. break
  7896. case 15:
  7897. fsiOPFLD.MedChrgitmType = "14"
  7898. break
  7899. }
  7900. memo["hosp_appr_flag"] = "1"
  7901. memo["invoice_no"] = order.MdtrtId
  7902. memo["memo"] = "自费"
  7903. bytesData, _ := json.Marshal(memo)
  7904. fsiOPFLD.Memo = string(bytesData)
  7905. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7906. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  7907. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  7908. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7909. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  7910. fsiOPFLD.BilgDeptName = department.Name
  7911. fsiOPFLD.BilgDeptCodg = department.Number
  7912. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  7913. fsiOPFLD.BilgDrName = doctor.UserName
  7914. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  7915. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  7916. fsiOPFLD.MedChrgitmType = "08"
  7917. memo["hosp_appr_flag"] = "1"
  7918. memo["invoice_no"] = order.MdtrtId
  7919. memo["memo"] = "自费"
  7920. bytesData, _ := json.Marshal(memo)
  7921. fsiOPFLD.Memo = string(bytesData)
  7922. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  7923. }
  7924. }
  7925. }
  7926. fmt.Println(fsiOPFLDs)
  7927. struct4201A.Fopfd = fsiOPFLDs
  7928. fmt.Println(struct4201A.Fopfd)
  7929. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  7930. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  7931. var res2 ResultSix
  7932. var respJSON2 map[string]interface{}
  7933. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7934. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7936. return
  7937. }
  7938. userJSONBytes2, _ := json.Marshal(respJSON2)
  7939. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7940. utils.ErrorLog("解析失败:%v", err)
  7941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7942. return
  7943. }
  7944. if res2.Infcode != 0 {
  7945. c.ServeSuccessJSON(map[string]interface{}{
  7946. "failed_code": -10,
  7947. "msg": res2.ErrMsg,
  7948. })
  7949. return
  7950. } else {
  7951. order.IsUploadOrderInfo = 1
  7952. service.UpdateOrder(order)
  7953. c.ServeSuccessJSON(map[string]interface{}{
  7954. "msg": "上传成功",
  7955. })
  7956. }
  7957. }
  7958. func (c *HisApiController) Get4202() {
  7959. order_id, _ := c.GetInt64("order_id")
  7960. admin_user_id, _ := c.GetInt64("admin_user_id")
  7961. order, _ := service.GetHisOrderByIDTwo(order_id)
  7962. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7963. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7964. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7965. if order.ID == 0 {
  7966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  7967. return
  7968. }
  7969. var struct4202 models.Struct4202
  7970. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  7971. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  7972. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  7973. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  7974. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  7975. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  7976. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  7977. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  7978. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  7979. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  7980. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7981. var config []*models.HisXtDiagnoseConfig
  7982. for _, item := range diagnosis_ids {
  7983. id, _ := strconv.ParseInt(item, 10, 64)
  7984. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7985. config = append(config, &diagnosisConfig)
  7986. }
  7987. var tempDiaginfos []models.OwnPayPatnDiagListD
  7988. for index, item := range config {
  7989. if index == 0 {
  7990. var tempDiaginfo models.OwnPayPatnDiagListD
  7991. tempDiaginfo.InoutDiagType = "1"
  7992. tempDiaginfo.DiagCode = item.CountryCode
  7993. tempDiaginfo.DiagName = item.CountryContentName
  7994. tempDiaginfo.DiagType = "1"
  7995. tempDiaginfo.DiagSrtNo = "1"
  7996. tempDiaginfo.MaindiagFlag = "1"
  7997. tempDiaginfo.ValiFlag = "1"
  7998. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  7999. } else {
  8000. var tempDiaginfo models.OwnPayPatnDiagListD
  8001. tempDiaginfo.DiagCode = item.CountryCode
  8002. tempDiaginfo.DiagName = item.CountryContentName
  8003. tempDiaginfo.DiagType = "2"
  8004. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8005. tempDiaginfo.MaindiagFlag = "0"
  8006. tempDiaginfo.ValiFlag = "1"
  8007. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8008. }
  8009. }
  8010. struct4202.ODiagListD = tempDiaginfos
  8011. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  8012. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  8013. var res2 ResultSix
  8014. var respJSON2 map[string]interface{}
  8015. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8016. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8018. return
  8019. }
  8020. userJSONBytes2, _ := json.Marshal(respJSON2)
  8021. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8022. utils.ErrorLog("解析失败:%v", err)
  8023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8024. return
  8025. }
  8026. if res2.Infcode != 0 {
  8027. c.ServeSuccessJSON(map[string]interface{}{
  8028. "failed_code": -10,
  8029. "msg": res2.ErrMsg,
  8030. })
  8031. return
  8032. } else {
  8033. order.IsUploadDiagnose = 1
  8034. service.UpdateOrder(order)
  8035. c.ServeSuccessJSON(map[string]interface{}{
  8036. "msg": "上传成功",
  8037. })
  8038. }
  8039. }
  8040. func (c *HisApiController) Get4203() {
  8041. admin_user_id, _ := c.GetInt64("admin_user_id")
  8042. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8043. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8044. order_id, _ := c.GetInt64("order_id")
  8045. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8046. number := ""
  8047. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8048. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8049. if his.ID == 0 {
  8050. number = hospital.Number
  8051. } else {
  8052. number = his.Number
  8053. }
  8054. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  8055. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  8056. var res2 ResultSix
  8057. var respJSON2 map[string]interface{}
  8058. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8059. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8061. return
  8062. }
  8063. userJSONBytes2, _ := json.Marshal(respJSON2)
  8064. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8065. utils.ErrorLog("解析失败:%v", err)
  8066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8067. return
  8068. }
  8069. if res2.Infcode != 0 {
  8070. c.ServeSuccessJSON(map[string]interface{}{
  8071. "failed_code": -10,
  8072. "msg": res2.ErrMsg,
  8073. })
  8074. return
  8075. } else {
  8076. order.IsUploadSuccess = 1
  8077. service.UpdateOrderTwo(order)
  8078. c.ServeSuccessJSON(map[string]interface{}{
  8079. "msg": "上传成功",
  8080. })
  8081. }
  8082. }
  8083. func (c *HisApiController) Get4205() {
  8084. order_id, _ := c.GetInt64("order_id")
  8085. admin_user_id, _ := c.GetInt64("admin_user_id")
  8086. fapiao_code := c.GetString("fapiao_code")
  8087. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  8088. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8089. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8090. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8091. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  8092. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8093. //order_info = append(order_info, order_info_two...)
  8094. department, _ := service.GetDepartMentDetail(his.Departments)
  8095. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8096. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8097. if order.ID == 0 {
  8098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8099. return
  8100. }
  8101. var struct4201A models.Struct4201A
  8102. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8103. for _, items := range order_info {
  8104. memo := make(map[string]interface{})
  8105. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8106. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8107. fsiOPFLD.MedType = pre.MedType
  8108. fsiOPFLD.FixmedinsCode = miConfig.Code
  8109. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8110. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8111. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8112. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8113. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8114. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8115. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8116. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  8117. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8118. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8119. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8120. fsiOPFLD.BilgDeptName = department.Name
  8121. fsiOPFLD.BilgDeptCodg = department.Number
  8122. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8123. fsiOPFLD.BilgDrName = doctor.UserName
  8124. fsiOPFLD.MedChrgitmType = "09"
  8125. memo["hosp_appr_flag"] = "1"
  8126. memo["invoice_no"] = fapiao_code
  8127. memo["memo"] = "自费"
  8128. bytesData, _ := json.Marshal(memo)
  8129. fsiOPFLD.Memo = string(bytesData)
  8130. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8131. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8132. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8133. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8134. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8135. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8136. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8137. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8138. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8139. fsiOPFLD.BilgDeptName = department.Name
  8140. fsiOPFLD.BilgDeptCodg = department.Number
  8141. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8142. fsiOPFLD.BilgDrName = doctor.UserName
  8143. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8144. case 0:
  8145. break
  8146. case 1:
  8147. fsiOPFLD.MedChrgitmType = "14"
  8148. break
  8149. case 2:
  8150. fsiOPFLD.MedChrgitmType = "05"
  8151. break
  8152. case 3:
  8153. fsiOPFLD.MedChrgitmType = "03"
  8154. break
  8155. case 4:
  8156. fsiOPFLD.MedChrgitmType = "03"
  8157. break
  8158. case 5:
  8159. fsiOPFLD.MedChrgitmType = "08"
  8160. break
  8161. case 6:
  8162. fsiOPFLD.MedChrgitmType = "14"
  8163. break
  8164. case 7:
  8165. fsiOPFLD.MedChrgitmType = "14"
  8166. break
  8167. case 8:
  8168. fsiOPFLD.MedChrgitmType = "03"
  8169. break
  8170. case 9:
  8171. fsiOPFLD.MedChrgitmType = "14"
  8172. break
  8173. case 10:
  8174. fsiOPFLD.MedChrgitmType = "14"
  8175. break
  8176. case 11:
  8177. fsiOPFLD.MedChrgitmType = "06"
  8178. break
  8179. case 12:
  8180. fsiOPFLD.MedChrgitmType = "12"
  8181. break
  8182. case 13:
  8183. fsiOPFLD.MedChrgitmType = "01"
  8184. break
  8185. case 14:
  8186. fsiOPFLD.MedChrgitmType = "04"
  8187. break
  8188. case 15:
  8189. fsiOPFLD.MedChrgitmType = "14"
  8190. break
  8191. }
  8192. memo["hosp_appr_flag"] = "1"
  8193. memo["invoice_no"] = fapiao_code
  8194. memo["memo"] = "自费"
  8195. bytesData, _ := json.Marshal(memo)
  8196. fsiOPFLD.Memo = string(bytesData)
  8197. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8198. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8199. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8200. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8201. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8202. fsiOPFLD.BilgDeptName = department.Name
  8203. fsiOPFLD.BilgDeptCodg = department.Number
  8204. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8205. fsiOPFLD.BilgDrName = doctor.UserName
  8206. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8207. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8208. fsiOPFLD.MedChrgitmType = "08"
  8209. memo["hosp_appr_flag"] = "1"
  8210. memo["invoice_no"] = fapiao_code
  8211. memo["memo"] = "自费"
  8212. bytesData, _ := json.Marshal(memo)
  8213. fsiOPFLD.Memo = string(bytesData)
  8214. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8215. }
  8216. }
  8217. }
  8218. for _, items := range order_info_two {
  8219. memo := make(map[string]interface{})
  8220. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8221. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8222. fsiOPFLD.MedType = pre.MedType
  8223. fsiOPFLD.BkkpSn = items.FeedetlSn
  8224. fsiOPFLD.FixmedinsCode = miConfig.Code
  8225. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8226. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8227. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8228. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8229. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8230. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8231. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8232. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8233. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8234. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8235. fsiOPFLD.BilgDeptName = department.Name
  8236. fsiOPFLD.BilgDeptCodg = department.Number
  8237. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8238. fsiOPFLD.BilgDrName = doctor.UserName
  8239. fsiOPFLD.MedChrgitmType = "09"
  8240. memo["hosp_appr_flag"] = "1"
  8241. memo["invoice_no"] = fapiao_code
  8242. memo["memo"] = "自费"
  8243. bytesData, _ := json.Marshal(memo)
  8244. fsiOPFLD.Memo = string(bytesData)
  8245. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8246. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8247. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  8248. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8249. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8250. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8251. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8252. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8253. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8254. fsiOPFLD.BilgDeptName = department.Name
  8255. fsiOPFLD.BilgDeptCodg = department.Number
  8256. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8257. fsiOPFLD.BilgDrName = doctor.UserName
  8258. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8259. case 0:
  8260. break
  8261. case 1:
  8262. fsiOPFLD.MedChrgitmType = "14"
  8263. break
  8264. case 2:
  8265. fsiOPFLD.MedChrgitmType = "05"
  8266. break
  8267. case 3:
  8268. fsiOPFLD.MedChrgitmType = "03"
  8269. break
  8270. case 4:
  8271. fsiOPFLD.MedChrgitmType = "03"
  8272. break
  8273. case 5:
  8274. fsiOPFLD.MedChrgitmType = "08"
  8275. break
  8276. case 6:
  8277. fsiOPFLD.MedChrgitmType = "14"
  8278. break
  8279. case 7:
  8280. fsiOPFLD.MedChrgitmType = "14"
  8281. break
  8282. case 8:
  8283. fsiOPFLD.MedChrgitmType = "03"
  8284. break
  8285. case 9:
  8286. fsiOPFLD.MedChrgitmType = "14"
  8287. break
  8288. case 10:
  8289. fsiOPFLD.MedChrgitmType = "14"
  8290. break
  8291. case 11:
  8292. fsiOPFLD.MedChrgitmType = "06"
  8293. break
  8294. case 12:
  8295. fsiOPFLD.MedChrgitmType = "12"
  8296. break
  8297. case 13:
  8298. fsiOPFLD.MedChrgitmType = "01"
  8299. break
  8300. case 14:
  8301. fsiOPFLD.MedChrgitmType = "04"
  8302. break
  8303. case 15:
  8304. fsiOPFLD.MedChrgitmType = "14"
  8305. break
  8306. }
  8307. memo["hosp_appr_flag"] = "1"
  8308. memo["invoice_no"] = fapiao_code
  8309. memo["memo"] = "自费"
  8310. bytesData, _ := json.Marshal(memo)
  8311. fsiOPFLD.Memo = string(bytesData)
  8312. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8313. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  8314. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8315. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8316. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8317. fsiOPFLD.BilgDeptName = department.Name
  8318. fsiOPFLD.BilgDeptCodg = department.Number
  8319. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8320. fsiOPFLD.BilgDrName = doctor.UserName
  8321. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8322. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8323. fsiOPFLD.MedChrgitmType = "08"
  8324. memo["hosp_appr_flag"] = "1"
  8325. memo["invoice_no"] = fapiao_code
  8326. memo["memo"] = "自费"
  8327. bytesData, _ := json.Marshal(memo)
  8328. fsiOPFLD.Memo = string(bytesData)
  8329. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8330. }
  8331. }
  8332. }
  8333. fmt.Println(fsiOPFLDs)
  8334. struct4201A.Fopfd = fsiOPFLDs
  8335. fmt.Println(struct4201A.Fopfd)
  8336. var struct4202 models.Struct4202
  8337. timeLayout := "2006-01-02 15:04:05"
  8338. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  8339. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  8340. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  8341. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  8342. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  8343. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  8344. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  8345. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  8346. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  8347. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  8348. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  8349. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8350. var config []*models.HisXtDiagnoseConfig
  8351. for _, item := range diagnosis_ids {
  8352. id, _ := strconv.ParseInt(item, 10, 64)
  8353. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8354. config = append(config, &diagnosisConfig)
  8355. }
  8356. var tempDiaginfos []models.OwnPayPatnDiagListD
  8357. for index, item := range config {
  8358. if index == 0 {
  8359. var tempDiaginfo models.OwnPayPatnDiagListD
  8360. tempDiaginfo.InoutDiagType = "1"
  8361. tempDiaginfo.DiagCode = item.CountryCode
  8362. tempDiaginfo.DiagName = item.CountryContentName
  8363. tempDiaginfo.DiagType = "1"
  8364. tempDiaginfo.DiagSrtNo = "1"
  8365. tempDiaginfo.MaindiagFlag = "1"
  8366. tempDiaginfo.ValiFlag = "1"
  8367. tempDiaginfo.DiagDrName = doctor.UserName
  8368. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  8369. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  8370. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8371. } else {
  8372. var tempDiaginfo models.OwnPayPatnDiagListD
  8373. tempDiaginfo.DiagCode = item.CountryCode
  8374. tempDiaginfo.DiagName = item.CountryContentName
  8375. tempDiaginfo.DiagType = "2"
  8376. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8377. tempDiaginfo.MaindiagFlag = "0"
  8378. tempDiaginfo.ValiFlag = "1"
  8379. tempDiaginfo.DiagDrName = doctor.UserName
  8380. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  8381. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  8382. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8383. }
  8384. }
  8385. struct4202.ODiagListD = tempDiaginfos
  8386. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  8387. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  8388. var res2 ResultSix
  8389. var respJSON2 map[string]interface{}
  8390. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8391. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8393. return
  8394. }
  8395. userJSONBytes2, _ := json.Marshal(respJSON2)
  8396. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8397. utils.ErrorLog("解析失败:%v", err)
  8398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8399. return
  8400. }
  8401. if res2.Infcode != 0 {
  8402. c.ServeSuccessJSON(map[string]interface{}{
  8403. "failed_code": -10,
  8404. "msg": res2.ErrMsg,
  8405. })
  8406. return
  8407. } else {
  8408. order.IsUploadDiagnose = 1
  8409. order.IsUploadOrderInfo = 1
  8410. service.UpdateOrderTwo(order)
  8411. c.ServeSuccessJSON(map[string]interface{}{
  8412. "msg": "上传成功",
  8413. })
  8414. }
  8415. }
  8416. func (c *HisApiController) Get4207() {
  8417. admin_user_id, _ := c.GetInt64("admin_user_id")
  8418. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8419. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8420. order_id, _ := c.GetInt64("order_id")
  8421. order, _ := service.GetHisOrderByIDTwo(order_id)
  8422. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8423. var struct4207 models.Struct4207
  8424. struct4207.PageNum = "1"
  8425. struct4207.PageSize = "1000"
  8426. struct4207.FixmedinsCode = miConfig.Code
  8427. struct4207.FixmedinsMdtrtID = order.Number
  8428. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  8429. saveLog(result, requestLog, "4207", "查询")
  8430. var res2 ResultSix
  8431. var respJSON2 map[string]interface{}
  8432. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8433. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8435. return
  8436. }
  8437. userJSONBytes2, _ := json.Marshal(respJSON2)
  8438. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8439. utils.ErrorLog("解析失败:%v", err)
  8440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8441. return
  8442. }
  8443. if res2.Infcode != 0 {
  8444. c.ServeSuccessJSON(map[string]interface{}{
  8445. "failed_code": -10,
  8446. "msg": res2.ErrMsg,
  8447. })
  8448. return
  8449. } else {
  8450. c.ServeSuccessJSON(map[string]interface{}{
  8451. "msg": "查询成功",
  8452. })
  8453. }
  8454. }
  8455. func (c *HisApiController) Get4208() {
  8456. admin_user_id, _ := c.GetInt64("admin_user_id")
  8457. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8458. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8459. order_id, _ := c.GetInt64("order_id")
  8460. order, _ := service.GetHisOrderByIDTwo(order_id)
  8461. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8462. var struct4208 models.Struct4208
  8463. struct4208.PageNum = "1"
  8464. struct4208.PageSize = "1000"
  8465. struct4208.PsnCertType = "01"
  8466. struct4208.Certno = his.Certno
  8467. struct4208.MedType = order.MedType
  8468. struct4208.PsnName = his.Name
  8469. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  8470. saveLog(result, requestLog, "4208", "查询")
  8471. var res2 ResultSix
  8472. var respJSON2 map[string]interface{}
  8473. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8474. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8476. return
  8477. }
  8478. userJSONBytes2, _ := json.Marshal(respJSON2)
  8479. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8480. utils.ErrorLog("解析失败:%v", err)
  8481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8482. return
  8483. }
  8484. if res2.Infcode != 0 {
  8485. c.ServeSuccessJSON(map[string]interface{}{
  8486. "failed_code": -10,
  8487. "msg": res2.ErrMsg,
  8488. })
  8489. return
  8490. } else {
  8491. c.ServeSuccessJSON(map[string]interface{}{
  8492. "msg": "查询成功",
  8493. })
  8494. }
  8495. }
  8496. func (c *HisApiController) Get4209() {
  8497. admin_user_id, _ := c.GetInt64("admin_user_id")
  8498. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8499. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8500. order_id, _ := c.GetInt64("order_id")
  8501. order, _ := service.GetHisOrderByIDTwo(order_id)
  8502. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8503. var struct4209 models.Struct4209
  8504. struct4209.FixmedinsMdtrtID = order.Number
  8505. struct4209.FixmedinsCode = miConfig.Code
  8506. struct4209.PageSize = "1000"
  8507. struct4209.PageNum = "1"
  8508. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  8509. saveLog(result, requestLog, "4209", "查询")
  8510. var res2 ResultSix
  8511. var respJSON2 map[string]interface{}
  8512. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8513. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8515. return
  8516. }
  8517. userJSONBytes2, _ := json.Marshal(respJSON2)
  8518. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8519. utils.ErrorLog("解析失败:%v", err)
  8520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8521. return
  8522. }
  8523. if res2.Infcode != 0 {
  8524. c.ServeSuccessJSON(map[string]interface{}{
  8525. "failed_code": -10,
  8526. "msg": res2.ErrMsg,
  8527. })
  8528. return
  8529. } else {
  8530. c.ServeSuccessJSON(map[string]interface{}{
  8531. "msg": "查询成功",
  8532. })
  8533. }
  8534. }
  8535. type Result3101 struct {
  8536. Infcode string `json:"infcode"`
  8537. InfRefmsgid string `json:"inf_refmsgid"`
  8538. RefmsgTime string `json:"refmsg_time"`
  8539. RespondTime string `json:"respond_time"`
  8540. Enctype string `json:"enctype"`
  8541. Signtype string `json:"signtype"`
  8542. ErrMsg string `json:"err_msg"`
  8543. Output struct {
  8544. Result []struct {
  8545. JudgeResultDetailDtos []struct {
  8546. VolaItemType string `json:"vola_item_type"`
  8547. MdtrtID string `json:"mdtrt_id"`
  8548. JrdID string `json:"jrd_id"`
  8549. PatnID string `json:"patn_id"`
  8550. RxID string `json:"rx_id"`
  8551. VolaAmt interface{} `json:"vola_amt"`
  8552. } `json:"judge_result_detail_dtos"`
  8553. RuleID string `json:"rule_id"`
  8554. VolaEvid string `json:"vola_evid"`
  8555. MdtrtID string `json:"mdtrt_id"`
  8556. RuleName string `json:"rule_name"`
  8557. VolaAmtStas string `json:"vola_amt_stas"`
  8558. JrID string `json:"jr_id"`
  8559. PatnID string `json:"patn_id"`
  8560. SevDeg string `json:"sev_deg"`
  8561. VolaAmt float64 `json:"vola_amt"`
  8562. VolaBhvrType string `json:"vola_bhvr_type"`
  8563. VolaCont string `json:"vola_cont"`
  8564. } `json:"result"`
  8565. } `json:"output"`
  8566. }
  8567. type Resultgd3101 struct {
  8568. Infcode int64 `json:"infcode"`
  8569. InfRefmsgid string `json:"inf_refmsgid"`
  8570. RefmsgTime string `json:"refmsg_time"`
  8571. RespondTime string `json:"respond_time"`
  8572. Enctype string `json:"enctype"`
  8573. Signtype string `json:"signtype"`
  8574. ErrMsg string `json:"err_msg"`
  8575. Output struct {
  8576. Result []struct {
  8577. JudgeResultDetailDtos []struct {
  8578. VolaItemType string `json:"vola_item_type"`
  8579. MdtrtID string `json:"mdtrt_id"`
  8580. JrdID string `json:"jrd_id"`
  8581. PatnID string `json:"patn_id"`
  8582. RxID string `json:"rx_id"`
  8583. VolaAmt interface{} `json:"vola_amt"`
  8584. } `json:"judge_result_detail_dtos"`
  8585. RuleID string `json:"rule_id"`
  8586. VolaEvid string `json:"vola_evid"`
  8587. MdtrtID string `json:"mdtrt_id"`
  8588. RuleName string `json:"rule_name"`
  8589. VolaAmtStas string `json:"vola_amt_stas"`
  8590. JrID string `json:"jr_id"`
  8591. PatnID string `json:"patn_id"`
  8592. SevDeg string `json:"sev_deg"`
  8593. VolaAmt float64 `json:"vola_amt"`
  8594. VolaBhvrType string `json:"vola_bhvr_type"`
  8595. VolaCont string `json:"vola_cont"`
  8596. } `json:"result"`
  8597. } `json:"output"`
  8598. }
  8599. func (c *HisApiController) ReadEleToken() {
  8600. admin_user_id, _ := c.GetInt64("admin_user_id")
  8601. his_patient_id, _ := c.GetInt64("his_patient_id")
  8602. adminUser := c.GetAdminUserInfo()
  8603. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8604. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8605. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8606. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8607. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  8608. if len(tokens) > 0 {
  8609. c.ServeSuccessJSON(map[string]interface{}{
  8610. "msg": "读取成功",
  8611. })
  8612. } else {
  8613. c.ServeSuccessJSON(map[string]interface{}{
  8614. "failed_code": -10,
  8615. "msg": "读取失败",
  8616. })
  8617. }
  8618. } else if miConfig.MdtrtareaAdmvs == "341203" {
  8619. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  8620. if len(tokens) > 0 {
  8621. c.ServeSuccessJSON(map[string]interface{}{
  8622. "msg": "读取成功",
  8623. })
  8624. } else {
  8625. c.ServeSuccessJSON(map[string]interface{}{
  8626. "failed_code": -10,
  8627. "msg": "读取失败",
  8628. })
  8629. }
  8630. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8631. var api string
  8632. 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 +
  8633. "&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"
  8634. resp, requestErr := http.Get(api)
  8635. if requestErr != nil {
  8636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8637. }
  8638. body, ioErr := ioutil.ReadAll(resp.Body)
  8639. if ioErr != nil {
  8640. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8642. }
  8643. var respJSON map[string]interface{}
  8644. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8645. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8647. return
  8648. }
  8649. var status string
  8650. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8651. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8652. var token string
  8653. var res ResultTwo //1101结果
  8654. var res10265 ResultTwo10265 //1101结果
  8655. if status == "0" { //读卡成功
  8656. var card_info string //卡信息
  8657. var busi_card_info string
  8658. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8659. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8660. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8661. fmt.Println(card_info)
  8662. fmt.Println(busi_card_info)
  8663. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8664. result, _ := json.Marshal(respJSON)
  8665. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8666. utils.ErrorLog("解析失败:%v", err)
  8667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8668. return
  8669. }
  8670. res.ErrMsg = res10265.ErrMsg
  8671. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8672. res.Infcode = infocode
  8673. res.Output = res10265.Output
  8674. res.InfRefmsgid = res10265.InfRefmsgid
  8675. if res.Infcode == 0 {
  8676. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8677. if err == gorm.ErrRecordNotFound {
  8678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8679. return
  8680. } else if err != nil {
  8681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8682. return
  8683. } else {
  8684. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8685. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8686. infoStr := string(Iinfos)
  8687. idetinfoStr := string(Idetinfos)
  8688. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  8689. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  8690. psn := &models.HisPsn{
  8691. PsnNo: res.Output.Baseinfo.PsnNo,
  8692. PatientId: patient.ID,
  8693. Certno: res.Output.Baseinfo.Certno,
  8694. Gend: res.Output.Baseinfo.Gend,
  8695. Naty: res.Output.Baseinfo.Naty,
  8696. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8697. PsnName: res.Output.Baseinfo.PsnName,
  8698. Age: float64(age),
  8699. Brdy: b,
  8700. Idetinfo: idetinfoStr,
  8701. Insuinfo: infoStr,
  8702. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8703. CardInfo: card_info,
  8704. VerifyNumber: token,
  8705. IdCardType: 4,
  8706. }
  8707. var rf []*ResultFive
  8708. json.Unmarshal([]byte(infoStr), &rf)
  8709. var insutypes []*ResultFive
  8710. var insutype string
  8711. var is390 int = 0
  8712. var is310 int = 0
  8713. for _, item := range rf {
  8714. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8715. insutypes = append(insutypes, item)
  8716. }
  8717. }
  8718. if len(insutypes) == 1 {
  8719. insutype = insutypes[0].Insutype
  8720. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8721. } else {
  8722. for _, i := range insutypes {
  8723. if i.Insutype == "390" {
  8724. is390 = 1
  8725. }
  8726. if i.Insutype == "310" {
  8727. is310 = 1
  8728. }
  8729. }
  8730. }
  8731. if is390 == 1 {
  8732. insutype = "390"
  8733. }
  8734. if is310 == 1 {
  8735. insutype = "310"
  8736. }
  8737. if len(insutypes) == 0 {
  8738. insutype = "310"
  8739. }
  8740. service.CreateHisPsn(psn)
  8741. c.ServeSuccessJSON(map[string]interface{}{
  8742. "patient": patient,
  8743. "number": token,
  8744. "insutype": insutype,
  8745. })
  8746. }
  8747. } else {
  8748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8749. return
  8750. }
  8751. } else { //读卡失败
  8752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8753. return
  8754. }
  8755. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8756. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  8757. if len(errMsg) == 0 {
  8758. type ELeData struct {
  8759. Data struct {
  8760. IdNo string `json:"idNo"`
  8761. IdType string `json:"idType"`
  8762. UserName string `json:"userName"`
  8763. EcToken string `json:"ecToken"`
  8764. InsuOrg string `json:"insuOrg"`
  8765. Gender string `json:"gender"`
  8766. Birthday string `json:"birthday"`
  8767. Nationality string `json:"nationality"`
  8768. Email string `json:"email"`
  8769. Extra string `json:"extra"`
  8770. } `json:"data"`
  8771. Code int `json:"code"`
  8772. Message string `json:"message"`
  8773. }
  8774. var ele ELeData
  8775. err := json.Unmarshal([]byte(outPutInfo), &ele)
  8776. if err != nil {
  8777. utils.ErrorLog("解析失败:%v", err)
  8778. }
  8779. token := ele.Data.EcToken
  8780. if len(token) > 0 {
  8781. psn := &models.HisPsn{
  8782. PsnNo: his.PsnNo,
  8783. Age: 0,
  8784. PatientId: his.PatientId,
  8785. Certno: his.Certno,
  8786. Brdy: his.Brdy,
  8787. Gend: his.Gend,
  8788. Naty: his.Naty,
  8789. PsnCertType: his.PsnCertType,
  8790. PsnName: his.PsnName,
  8791. Idetinfo: his.Idetinfo,
  8792. Insuinfo: his.Iinfo,
  8793. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8794. CardInfo: outPutInfo,
  8795. VerifyNumber: token,
  8796. }
  8797. service.CreateHisPsn(psn)
  8798. }
  8799. if len(token) > 0 {
  8800. c.ServeSuccessJSON(map[string]interface{}{
  8801. "msg": "读取成功",
  8802. })
  8803. } else {
  8804. c.ServeSuccessJSON(map[string]interface{}{
  8805. "failed_code": -10,
  8806. "msg": "读取失败",
  8807. })
  8808. }
  8809. }
  8810. } else if miConfig.MdtrtareaAdmvs == "360302" {
  8811. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  8812. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  8813. type ELeData struct {
  8814. Data struct {
  8815. IdNo string `json:"idNo"`
  8816. IdType string `json:"idType"`
  8817. UserName string `json:"userName"`
  8818. EcToken string `json:"ecToken"`
  8819. InsuOrg string `json:"insuOrg"`
  8820. Gender string `json:"gender"`
  8821. Birthday string `json:"birthday"`
  8822. Nationality string `json:"nationality"`
  8823. Email string `json:"email"`
  8824. Extra string `json:"extra"`
  8825. } `json:"data"`
  8826. Code int `json:"code"`
  8827. Message string `json:"message"`
  8828. }
  8829. var ele ELeData
  8830. err := json.Unmarshal([]byte(result), &ele)
  8831. if err != nil {
  8832. utils.ErrorLog("解析失败:%v", err)
  8833. }
  8834. token := ele.Data.EcToken
  8835. token = Remove0000(token)
  8836. fmt.Println(ele.Data.UserName)
  8837. 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)
  8838. saveLog(result2, requestLog2, "1101", "获取人员信息")
  8839. var res ResultTwo
  8840. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8841. utils.ErrorLog("解析失败:%v", err)
  8842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8843. return
  8844. }
  8845. if res.Infcode == 0 {
  8846. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8847. if err == gorm.ErrRecordNotFound {
  8848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8849. return
  8850. } else if err != nil {
  8851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8852. return
  8853. } else {
  8854. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8855. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8856. infoStr := string(Iinfos)
  8857. idetinfoStr := string(Idetinfos)
  8858. psn := &models.HisPsn{
  8859. PsnNo: res.Output.Baseinfo.PsnNo,
  8860. PatientId: patient.ID,
  8861. Certno: res.Output.Baseinfo.Certno,
  8862. Gend: res.Output.Baseinfo.Gend,
  8863. Naty: res.Output.Baseinfo.Naty,
  8864. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8865. PsnName: res.Output.Baseinfo.PsnName,
  8866. Idetinfo: idetinfoStr,
  8867. Insuinfo: infoStr,
  8868. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8869. CardInfo: "",
  8870. VerifyNumber: token,
  8871. }
  8872. service.CreateHisPsn(psn)
  8873. c.ServeSuccessJSON(map[string]interface{}{
  8874. "patient": patient,
  8875. "number": token,
  8876. })
  8877. }
  8878. } else {
  8879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8880. return
  8881. }
  8882. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8883. //if initFlag == 0 {
  8884. //c.TestGetJiangXiBasBaseInit()
  8885. //}
  8886. //if initEleFlag == 0 {
  8887. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  8888. //}
  8889. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  8890. utils.ErrorLog("解析失败:%v", json_result)
  8891. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  8892. type ELeData struct {
  8893. Data struct {
  8894. IdNo string `json:"idNo"`
  8895. IdType string `json:"idType"`
  8896. UserName string `json:"userName"`
  8897. EcToken string `json:"ecToken"`
  8898. InsuOrg string `json:"insuOrg"`
  8899. Gender string `json:"gender"`
  8900. Birthday string `json:"birthday"`
  8901. Nationality string `json:"nationality"`
  8902. Email string `json:"email"`
  8903. Extra string `json:"extra"`
  8904. } `json:"data"`
  8905. Code int `json:"code"`
  8906. Message string `json:"message"`
  8907. }
  8908. var ele ELeData
  8909. err := json.Unmarshal([]byte(json_result), &ele)
  8910. if err != nil {
  8911. utils.ErrorLog("解析失败:%v", err)
  8912. }
  8913. token := ele.Data.EcToken
  8914. token = Remove0000(token)
  8915. //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)
  8916. 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)
  8917. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  8918. saveLog(result2, requestLog2, "1101", "获取人员信息")
  8919. var res ResultTwo
  8920. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8921. utils.ErrorLog("解析失败:%v", err)
  8922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8923. return
  8924. }
  8925. if res.Infcode == 0 {
  8926. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8927. if err == gorm.ErrRecordNotFound {
  8928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8929. return
  8930. } else if err != nil {
  8931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8932. return
  8933. } else {
  8934. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8935. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8936. infoStr := string(Iinfos)
  8937. idetinfoStr := string(Idetinfos)
  8938. psn := &models.HisPsn{
  8939. PsnNo: res.Output.Baseinfo.PsnNo,
  8940. PatientId: patient.ID,
  8941. Certno: res.Output.Baseinfo.Certno,
  8942. Gend: res.Output.Baseinfo.Gend,
  8943. Naty: res.Output.Baseinfo.Naty,
  8944. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8945. PsnName: res.Output.Baseinfo.PsnName,
  8946. Idetinfo: idetinfoStr,
  8947. Insuinfo: infoStr,
  8948. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8949. CardInfo: "",
  8950. VerifyNumber: token,
  8951. InsuplcAdmdvs: ele.Data.InsuOrg,
  8952. }
  8953. service.CreateHisPsn(psn)
  8954. c.ServeSuccessJSON(map[string]interface{}{
  8955. "patient": patient,
  8956. "number": token,
  8957. })
  8958. }
  8959. } else {
  8960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8961. return
  8962. }
  8963. } else if miConfig.MdtrtareaAdmvs == "450721" {
  8964. res := c.GetoleInfo()
  8965. if res.Infcode == 0 {
  8966. var result string
  8967. if res.Output.MdtrtCertType == "01" {
  8968. 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)
  8969. } else if res.Output.MdtrtCertType == "02" {
  8970. 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)
  8971. } else if res.Output.MdtrtCertType == "03" {
  8972. 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)
  8973. }
  8974. var dat map[string]interface{}
  8975. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8976. fmt.Println(dat)
  8977. } else {
  8978. fmt.Println(err)
  8979. }
  8980. userJSONBytes, _ := json.Marshal(dat)
  8981. var res2 ResultTwo
  8982. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8983. utils.ErrorLog("解析失败:%v", err)
  8984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8985. return
  8986. }
  8987. if res2.Infcode == 0 {
  8988. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  8989. if err == gorm.ErrRecordNotFound {
  8990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8991. return
  8992. } else if err != nil {
  8993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8994. return
  8995. } else {
  8996. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  8997. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  8998. infoStr := string(Iinfos)
  8999. idetinfoStr := string(Idetinfos)
  9000. var rf []*ResultFive
  9001. json.Unmarshal([]byte(infoStr), &rf)
  9002. var insutypes []*ResultFive
  9003. var insutype string
  9004. var is390 int = 0
  9005. var is310 int = 0
  9006. //var insuplc_admdvs string
  9007. for _, item := range rf {
  9008. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9009. insutypes = append(insutypes, item)
  9010. }
  9011. }
  9012. if len(insutypes) == 1 {
  9013. insutype = insutypes[0].Insutype
  9014. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9015. } else {
  9016. for _, i := range insutypes {
  9017. if i.Insutype == "390" {
  9018. is390 = 1
  9019. }
  9020. if i.Insutype == "310" {
  9021. is310 = 1
  9022. }
  9023. }
  9024. }
  9025. if is390 == 1 {
  9026. insutype = "390"
  9027. }
  9028. if is310 == 1 {
  9029. insutype = "310"
  9030. }
  9031. if len(insutypes) == 0 {
  9032. insutype = "310"
  9033. }
  9034. psn := &models.HisPsn{
  9035. PsnNo: res2.Output.Baseinfo.PsnNo,
  9036. PatientId: patient.ID,
  9037. Certno: res2.Output.Baseinfo.Certno,
  9038. Gend: res2.Output.Baseinfo.Gend,
  9039. Naty: res2.Output.Baseinfo.Naty,
  9040. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9041. PsnName: res2.Output.Baseinfo.PsnName,
  9042. Idetinfo: idetinfoStr,
  9043. Insuinfo: infoStr,
  9044. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9045. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9046. VerifyNumber: res.Output.EcToken,
  9047. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9048. }
  9049. service.CreateHisPsn(psn)
  9050. c.ServeSuccessJSON(map[string]interface{}{
  9051. "patient": patient,
  9052. "number": res.Output.CardNo,
  9053. "insutype": insutype,
  9054. })
  9055. }
  9056. } else {
  9057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9058. return
  9059. }
  9060. } else {
  9061. c.ServeSuccessJSON(map[string]interface{}{
  9062. "failed_code": -10,
  9063. "msg": res.ErrMsg,
  9064. })
  9065. }
  9066. } else {
  9067. //if initFlag == 0 {
  9068. // c.TestGetBasBaseInit()
  9069. //}
  9070. //token := c.GetEleBaseInfo()
  9071. //token = Remove0000(token)
  9072. type ELeData struct {
  9073. Code string `json:"code"`
  9074. Data struct {
  9075. Aac002 string `json:"aac002"`
  9076. Aaz500 string `json:"aaz500"`
  9077. ActCardNo string `json:"actCardNo"`
  9078. Bab520 string `json:"bab520"`
  9079. Bkz543 string `json:"bkz543"`
  9080. BusinessType string `json:"businessType"`
  9081. CertfCodg string `json:"certfCodg"`
  9082. EcIndexNo string `json:"ecIndexNo"`
  9083. EcToken string `json:"ecToken"`
  9084. ID0000 string `json:"id0000"`
  9085. IDNo string `json:"idNo"`
  9086. IDType string `json:"idType"`
  9087. Idcode string `json:"idcode"`
  9088. IdentityToken string `json:"identity_token"`
  9089. InsuOrg string `json:"insuOrg"`
  9090. OfficeID string `json:"officeId"`
  9091. OfficeName string `json:"officeName"`
  9092. OperatorID string `json:"operatorId"`
  9093. OperatorName string `json:"operatorName"`
  9094. OrgID string `json:"orgId"`
  9095. UserName string `json:"userName"`
  9096. } `json:"data"`
  9097. Infno interface{} `json:"infno"`
  9098. Message string `json:"message"`
  9099. OrgID string `json:"orgId"`
  9100. TransType string `json:"transType"`
  9101. }
  9102. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  9103. fmt.Println(result)
  9104. outPutInfo := Remove0000(result)
  9105. fmt.Println(outPutInfo)
  9106. var ele ELeData
  9107. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9108. if err != nil {
  9109. utils.ErrorLog("解析失败:%v", err)
  9110. }
  9111. token := ele.Data.EcToken
  9112. var result2 string
  9113. var requestLog2 string
  9114. if len(token) > 0 {
  9115. if strings.Contains(ele.Data.IDNo, "HKG") {
  9116. 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)
  9117. } else {
  9118. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  9119. }
  9120. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9121. var res ResultTwo
  9122. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9123. utils.ErrorLog("解析失败:%v", err)
  9124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9125. return
  9126. }
  9127. if res.Infcode == 0 {
  9128. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9129. if err == gorm.ErrRecordNotFound {
  9130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9131. return
  9132. } else if err != nil {
  9133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9134. return
  9135. } else {
  9136. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9137. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9138. infoStr := string(Iinfos)
  9139. idetinfoStr := string(Idetinfos)
  9140. psn := &models.HisPsn{
  9141. PsnNo: res.Output.Baseinfo.PsnNo,
  9142. PatientId: patient.ID,
  9143. Certno: res.Output.Baseinfo.Certno,
  9144. Gend: res.Output.Baseinfo.Gend,
  9145. Naty: res.Output.Baseinfo.Naty,
  9146. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9147. PsnName: res.Output.Baseinfo.PsnName,
  9148. Idetinfo: idetinfoStr,
  9149. Insuinfo: infoStr,
  9150. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9151. CardInfo: "",
  9152. VerifyNumber: token,
  9153. }
  9154. service.CreateHisPsn(psn)
  9155. c.ServeSuccessJSON(map[string]interface{}{
  9156. "msg": "读取成功",
  9157. })
  9158. }
  9159. } else {
  9160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9161. return
  9162. }
  9163. } else {
  9164. c.ServeSuccessJSON(map[string]interface{}{
  9165. "failed_code": -10,
  9166. "msg": "读取失败",
  9167. })
  9168. }
  9169. }
  9170. }
  9171. func (c *HisApiController) ReadEleFace() {
  9172. admin_user_id, _ := c.GetInt64("admin_user_id")
  9173. //his_patient_id, _ := c.GetInt64("his_patient_id")
  9174. adminUser := c.GetAdminUserInfo()
  9175. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9176. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9177. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9178. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9179. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  9180. if len(tokens) > 0 {
  9181. c.ServeSuccessJSON(map[string]interface{}{
  9182. "msg": "读取成功",
  9183. })
  9184. } else {
  9185. c.ServeSuccessJSON(map[string]interface{}{
  9186. "failed_code": -10,
  9187. "msg": "读取失败",
  9188. })
  9189. }
  9190. }
  9191. }
  9192. func (c *HisApiController) Get9001() {
  9193. adminUser := c.GetAdminUserInfo()
  9194. admin_user_id, _ := c.GetInt64("admin_user_id")
  9195. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9196. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9197. if miConfig.MdtrtareaAdmvs == "350500" {
  9198. service.GetFjAuthorizationInfo(miConfig.Code)
  9199. } else if miConfig.MdtrtareaAdmvs == "131023" {
  9200. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9201. var dat map[string]interface{}
  9202. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9203. fmt.Println(dat)
  9204. } else {
  9205. fmt.Println(err)
  9206. }
  9207. userJSONBytes, _ := json.Marshal(dat)
  9208. var res models.Result9001
  9209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9210. utils.ErrorLog("解析失败:%v", err)
  9211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9212. return
  9213. }
  9214. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9215. fmt.Println(miConfig.SecretKey)
  9216. var res models.Result9001Two
  9217. 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 +
  9218. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  9219. resp, requestErr := http.Get(api)
  9220. if requestErr != nil {
  9221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9222. return
  9223. }
  9224. body, ioErr := ioutil.ReadAll(resp.Body)
  9225. if ioErr != nil {
  9226. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9228. return
  9229. }
  9230. var respJSON map[string]interface{}
  9231. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9232. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9234. return
  9235. }
  9236. status := respJSON["data"].(map[string]interface{})["status"].(string)
  9237. if status == "0" {
  9238. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  9239. c.ServeSuccessJSON(map[string]interface{}{
  9240. "failed_code": -10,
  9241. "msg": err_msg,
  9242. })
  9243. return
  9244. }
  9245. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9246. result, _ := json.Marshal(respJSON)
  9247. fmt.Println("log")
  9248. fmt.Println(string(result))
  9249. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9250. utils.ErrorLog("解析失败:%v", err)
  9251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9252. return
  9253. }
  9254. if res.Infcode == 0 {
  9255. sign := models.HisSignIn{
  9256. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9257. SignNo: res.Output.Signinoutb.SignNo,
  9258. SignTime: "",
  9259. Ctime: time.Now().Unix(),
  9260. Mtime: time.Now().Unix(),
  9261. Status: 1,
  9262. InputLog: "",
  9263. OutputLog: "",
  9264. FixmedinsCode: miConfig.Code,
  9265. }
  9266. err := service.CreateSignIn(&sign)
  9267. if err == nil {
  9268. c.ServeSuccessJSON(map[string]interface{}{
  9269. "msg": "签到成功",
  9270. })
  9271. }
  9272. } else {
  9273. c.ServeSuccessJSON(map[string]interface{}{
  9274. "failed_code": -10,
  9275. "msg": res.ErrMsg,
  9276. })
  9277. return
  9278. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9279. //return
  9280. }
  9281. } else {
  9282. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  9283. var dat map[string]interface{}
  9284. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9285. fmt.Println(dat)
  9286. } else {
  9287. fmt.Println(err)
  9288. }
  9289. userJSONBytes, _ := json.Marshal(dat)
  9290. var res models.Result9001
  9291. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9292. utils.ErrorLog("解析失败:%v", err)
  9293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9294. return
  9295. }
  9296. if res.Infcode == 0 {
  9297. sign := models.HisSignIn{
  9298. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9299. SignNo: res.Output.Signinoutb.SignNo,
  9300. SignTime: res.Output.Signinoutb.SignTime,
  9301. Ctime: time.Now().Unix(),
  9302. Mtime: time.Now().Unix(),
  9303. Status: 1,
  9304. InputLog: "",
  9305. OutputLog: "",
  9306. FixmedinsCode: miConfig.Code,
  9307. }
  9308. err := service.CreateSignIn(&sign)
  9309. if err == nil {
  9310. c.ServeSuccessJSON(map[string]interface{}{
  9311. "msg": "签到成功",
  9312. })
  9313. }
  9314. }
  9315. }
  9316. }
  9317. 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) {
  9318. var res Result3101
  9319. adminUser := c.GetAdminUserInfo()
  9320. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9321. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9322. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9323. //record_time := c.GetString("record_time")
  9324. //trig_scen := c.GetString("trig_scen")
  9325. timeLayout := "2006-01-02"
  9326. loc, _ := time.LoadLocation("Local")
  9327. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9328. if err != nil {
  9329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9330. return res
  9331. }
  9332. recordDateTime := theTime.Unix()
  9333. var patientPrescription models.HisPrescriptionInfo
  9334. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9335. //if patientPrescription.ID == 0 {
  9336. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  9337. //}
  9338. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9339. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9340. //
  9341. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  9342. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9343. var pp models.PublicParams
  9344. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9345. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9346. pp.FixmedinsName = miConfig.OrgName
  9347. pp.FixmedinsCode = miConfig.Code
  9348. pp.RequestUrl = miConfig.Url
  9349. pp.Cainfo = miConfig.Cainfo
  9350. pp.SecretKey = miConfig.SecretKey
  9351. pp.AccessKey = miConfig.AccessKey
  9352. pp.OpterName = roles.UserName
  9353. var config []*models.HisXtDiagnoseConfig
  9354. for _, item := range diagnosis_ids {
  9355. id, _ := strconv.ParseInt(item, 10, 64)
  9356. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9357. config = append(config, &diagnosisConfig)
  9358. }
  9359. var pd models.PatientDtos
  9360. pd.PatnID = his.PsnNo
  9361. pd.PatnName = his.Name
  9362. pd.Gend = his.Gend
  9363. pd.Brdy = his.Brdy
  9364. pd.Poolarea = miConfig.MdtrtareaAdmvs
  9365. pd.CurrMdtrtID = his.Number
  9366. var fed models.FsiEncounterDtos
  9367. fed.MdtrtID = his.Number
  9368. fed.MedinsID = miConfig.Code
  9369. fed.MedinsName = miConfig.OrgName
  9370. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  9371. fed.MedMdtrtType = "1"
  9372. fed.MedinsType = "1"
  9373. fed.MedinsLv = "11"
  9374. tm := time.Unix(his.RecordDate, 0)
  9375. s_tm := tm.Format("2006-01-02 15:04:05")
  9376. fed.AdmDate = s_tm
  9377. fed.DscgDate = s_tm
  9378. fed.DscgMainDiseCodg = config[0].CountryCode
  9379. fed.DscgMainDiseName = config[0].CountryContentName
  9380. //诊断信息
  9381. var fdds []*models.FsiDiagnoseDtos
  9382. for index, item := range config {
  9383. if index == 0 {
  9384. var fdd models.FsiDiagnoseDtos
  9385. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9386. fdd.InoutDiseType = "1"
  9387. fdd.MaindiseFlag = "1"
  9388. fdd.DiseDate = s_tm
  9389. fdd.DiasSrtNo = "1"
  9390. fdd.DiseName = item.CountryContentName
  9391. fdd.DiseCodg = item.CountryCode
  9392. fdds = append(fdds, &fdd)
  9393. } else {
  9394. var fdd models.FsiDiagnoseDtos
  9395. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9396. fdd.InoutDiseType = "1"
  9397. fdd.MaindiseFlag = "1"
  9398. fdd.DiseDate = s_tm
  9399. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  9400. fdd.DiseName = item.CountryContentName
  9401. fdd.DiseCodg = item.CountryCode
  9402. fdds = append(fdds, &fdd)
  9403. }
  9404. }
  9405. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  9406. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  9407. fed.AdmDeptName = de.Name
  9408. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  9409. fed.DscgDeptName = de.Name
  9410. fed.MedMdtrtType = "1"
  9411. fed.MedType = "11"
  9412. //if his.Insutype == "390" {
  9413. // fed.MedType = "1402"
  9414. //} else {
  9415. // fed.MedType = "9933"
  9416. //}
  9417. var orders []*models.FsiOrderDtos
  9418. if trig_scen == "2" {
  9419. //处方医嘱信息
  9420. for _, item := range prescriptions {
  9421. for _, subItem := range item.HisDoctorAdviceInfo {
  9422. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9423. var order models.FsiOrderDtos
  9424. order.RxID = strconv.FormatInt(item.ID, 10)
  9425. order.Rxno = strconv.FormatInt(item.ID, 10)
  9426. order.LongDrordFlag = "0"
  9427. order.HilistType = "1"
  9428. order.ChrgType = "1"
  9429. order.DrordBhvr = "-"
  9430. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9431. order.HosplistName = subItem.BaseDrugLib.DrugName
  9432. order.HilistLv = "1"
  9433. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9434. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9435. order.HosplistName = subItem.BaseDrugLib.DrugName
  9436. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  9437. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9438. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  9439. order.OwnpayAmt = ""
  9440. order.SelfpayAmt = ""
  9441. order.Spec = ""
  9442. order.SpecUnt = ""
  9443. order.DrordBegnDate = s_tm
  9444. order.DrordStopDate = ""
  9445. order.DrordDrCodg = doctor_info.DoctorNumber
  9446. order.DrordDeptName = department.Name
  9447. order.DrordDeptCodg = department.Number
  9448. order.DrordDrName = doctor_info.UserName
  9449. order.DrordDrProfttl = "234"
  9450. order.CurrDrordFlag = "1"
  9451. orders = append(orders, &order)
  9452. }
  9453. }
  9454. for _, subItem := range item.HisPrescriptionProject {
  9455. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  9456. var order models.FsiOrderDtos
  9457. order.RxID = strconv.FormatInt(item.ID, 10)
  9458. order.Rxno = strconv.FormatInt(item.ID, 10)
  9459. order.LongDrordFlag = "0"
  9460. order.HilistType = "1"
  9461. order.ChrgType = "1"
  9462. order.DrordBhvr = "-"
  9463. order.HilistCode = subItem.HisProject.MedicalCode
  9464. order.HosplistName = subItem.HisProject.ProjectName
  9465. order.HilistLv = "1"
  9466. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9467. order.HosplistCode = subItem.HisProject.MedicalCode
  9468. order.HosplistName = subItem.HisProject.ProjectName
  9469. order.Cnt = subItem.Count
  9470. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9471. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9472. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  9473. order.OwnpayAmt = ""
  9474. order.SelfpayAmt = ""
  9475. order.Spec = ""
  9476. order.SpecUnt = ""
  9477. order.DrordBegnDate = s_tm
  9478. order.DrordStopDate = ""
  9479. order.DrordDrCodg = doctor_info.DoctorNumber
  9480. order.DrordDeptName = department.Name
  9481. order.DrordDeptCodg = department.Number
  9482. order.DrordDrName = doctor_info.UserName
  9483. order.DrordDrProfttl = "234"
  9484. order.CurrDrordFlag = "1"
  9485. orders = append(orders, &order)
  9486. }
  9487. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  9488. var order models.FsiOrderDtos
  9489. order.RxID = strconv.FormatInt(item.ID, 10)
  9490. order.Rxno = strconv.FormatInt(item.ID, 10)
  9491. order.LongDrordFlag = "0"
  9492. order.HilistType = "1"
  9493. order.ChrgType = "1"
  9494. order.DrordBhvr = "-"
  9495. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9496. order.HosplistName = subItem.GoodInfo.GoodName
  9497. order.HilistLv = "1"
  9498. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9499. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9500. order.HosplistName = subItem.GoodInfo.GoodName
  9501. order.Cnt = subItem.Count
  9502. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9503. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9504. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  9505. order.OwnpayAmt = ""
  9506. order.SelfpayAmt = ""
  9507. order.Spec = ""
  9508. order.SpecUnt = ""
  9509. order.DrordBegnDate = s_tm
  9510. order.DrordStopDate = ""
  9511. order.DrordDrCodg = doctor_info.DoctorNumber
  9512. order.DrordDeptName = department.Name
  9513. order.DrordDeptCodg = department.Number
  9514. order.DrordDrName = doctor_info.UserName
  9515. order.DrordDrProfttl = "234"
  9516. order.CurrDrordFlag = "1"
  9517. orders = append(orders, &order)
  9518. }
  9519. }
  9520. }
  9521. //处方医嘱信息
  9522. }
  9523. fed.MatnStas = "0"
  9524. fed.MedfeeSumamt = "0"
  9525. fed.OwnpayAmt = "0"
  9526. fed.SelfpayAmt = "0"
  9527. fed.AcctPayamt = "0"
  9528. fed.MaAmt = "0"
  9529. fed.HifpPayamt = "0"
  9530. fed.SetlTotlnum = "1"
  9531. fed.Insutype = his.Insutype
  9532. fed.ReimFlag = "0"
  9533. fed.OutSetlFlag = "0"
  9534. var fopd []*models.FsiOperationDtosData
  9535. data := make(map[string]interface{})
  9536. data["fed"] = fed
  9537. data["fdd"] = fdds
  9538. data["fod"] = orders
  9539. data["pd"] = pd
  9540. data["pp"] = pp
  9541. data["fopd"] = fopd
  9542. data["trig_scen"] = trig_scen
  9543. fmt.Println(data)
  9544. fmt.Println(fed)
  9545. fmt.Println(fdds)
  9546. fmt.Println(orders)
  9547. fmt.Println(pd)
  9548. fmt.Println(pp)
  9549. fmt.Println(fopd)
  9550. client := &http.Client{}
  9551. bytesData, _ := json.Marshal(data)
  9552. var req *http.Request
  9553. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9554. if miConfig.MdtrtareaAdmvs == "320921" {
  9555. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  9556. } else {
  9557. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  9558. }
  9559. resp, _ := client.Do(req)
  9560. defer resp.Body.Close()
  9561. body, ioErr := ioutil.ReadAll(resp.Body)
  9562. if ioErr != nil {
  9563. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9565. return res
  9566. }
  9567. var respJSON map[string]interface{}
  9568. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9569. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9571. return res
  9572. }
  9573. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  9574. fmt.Println(respJSON)
  9575. result, _ := json.Marshal(respJSON)
  9576. fmt.Println(result)
  9577. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9578. utils.ErrorLog("解析失败:%v", err)
  9579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9580. return res
  9581. }
  9582. return res
  9583. } else {
  9584. //if miConfig.MdtrtareaAdmvs == "441202" {
  9585. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  9586. saveLog(output, input, "3101", "事前")
  9587. if err := json.Unmarshal([]byte(output), &res); err != nil {
  9588. utils.ErrorLog("解析失败:%v", err)
  9589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9590. return
  9591. }
  9592. return res
  9593. //}
  9594. }
  9595. }
  9596. 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) {
  9597. adminUser := c.GetAdminUserInfo()
  9598. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9599. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9600. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9601. //record_time := c.GetString("record_time")
  9602. //trig_scen := c.GetString("trig_scen")
  9603. timeLayout := "2006-01-02"
  9604. loc, _ := time.LoadLocation("Local")
  9605. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9606. if err != nil {
  9607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9608. return res
  9609. }
  9610. recordDateTime := theTime.Unix()
  9611. var patientPrescription models.HisPrescriptionInfo
  9612. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9613. if patientPrescription.ID == 0 {
  9614. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  9615. }
  9616. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9617. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9618. //
  9619. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  9620. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9621. var pp models.PublicParams
  9622. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9623. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9624. pp.FixmedinsName = miConfig.OrgName
  9625. pp.FixmedinsCode = miConfig.Code
  9626. pp.RequestUrl = miConfig.Url
  9627. pp.Cainfo = miConfig.Cainfo
  9628. pp.SecretKey = miConfig.SecretKey
  9629. pp.AccessKey = miConfig.AccessKey
  9630. pp.OpterName = roles.UserName
  9631. var config []*models.HisXtDiagnoseConfig
  9632. for _, item := range diagnosis_ids {
  9633. id, _ := strconv.ParseInt(item, 10, 64)
  9634. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9635. config = append(config, &diagnosisConfig)
  9636. }
  9637. var pd models.PatientDtos
  9638. pd.PatnID = his.PsnNo
  9639. pd.PatnName = his.Name
  9640. pd.Gend = his.Gend
  9641. pd.Brdy = his.Brdy
  9642. pd.Poolarea = his.InsuplcAdmdvs
  9643. pd.CurrMdtrtID = his.Number
  9644. var fed models.FsiEncounterDtos
  9645. fed.MdtrtID = his.Number
  9646. fed.MedinsID = miConfig.Code
  9647. fed.MedinsName = miConfig.OrgName
  9648. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  9649. fed.MedMdtrtType = "1"
  9650. fed.MedinsType = "1"
  9651. fed.MedinsLv = "11"
  9652. tm := time.Unix(his.RecordDate, 0)
  9653. s_tm := tm.Format("2006-01-02 15:04:05")
  9654. fed.AdmDate = s_tm
  9655. fed.DscgDate = s_tm
  9656. fed.DscgMainDiseCodg = config[0].CountryCode
  9657. fed.DscgMainDiseName = config[0].CountryContentName
  9658. //诊断信息
  9659. var fdds []*models.FsiDiagnoseDtos
  9660. for index, item := range config {
  9661. if index == 0 {
  9662. var fdd models.FsiDiagnoseDtos
  9663. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9664. fdd.InoutDiseType = "1"
  9665. fdd.MaindiseFlag = "1"
  9666. fdd.DiseDate = s_tm
  9667. fdd.DiasSrtNo = "1"
  9668. fdd.DiseName = item.CountryContentName
  9669. fdd.DiseCodg = item.CountryCode
  9670. fdds = append(fdds, &fdd)
  9671. } else {
  9672. var fdd models.FsiDiagnoseDtos
  9673. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9674. fdd.InoutDiseType = "1"
  9675. fdd.MaindiseFlag = "1"
  9676. fdd.DiseDate = s_tm
  9677. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  9678. fdd.DiseName = item.CountryContentName
  9679. fdd.DiseCodg = item.CountryCode
  9680. fdds = append(fdds, &fdd)
  9681. }
  9682. }
  9683. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  9684. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  9685. fed.AdmDeptName = department.Name
  9686. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  9687. fed.DscgDeptName = department.Name
  9688. fed.MedMdtrtType = "1"
  9689. fed.MedType = "11"
  9690. //if his.Insutype == "390" {
  9691. // fed.MedType = "1402"
  9692. //} else {
  9693. // fed.MedType = "9933"
  9694. //}
  9695. var orders []*models.FsiOrderDtos
  9696. if trig_scen == "2" {
  9697. //处方医嘱信息
  9698. for _, item := range prescriptions {
  9699. for _, subItem := range item.HisDoctorAdviceInfo {
  9700. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9701. var order models.FsiOrderDtos
  9702. order.RxID = strconv.FormatInt(item.ID, 10)
  9703. order.Rxno = strconv.FormatInt(item.ID, 10)
  9704. order.LongDrordFlag = "0"
  9705. order.HilistType = "1"
  9706. order.ChrgType = "1"
  9707. order.DrordBhvr = "-"
  9708. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9709. order.HosplistName = subItem.BaseDrugLib.DrugName
  9710. order.HilistLv = "1"
  9711. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9712. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9713. order.HosplistName = subItem.BaseDrugLib.DrugName
  9714. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  9715. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9716. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  9717. order.OwnpayAmt = ""
  9718. order.SelfpayAmt = ""
  9719. order.Spec = ""
  9720. order.SpecUnt = ""
  9721. order.DrordBegnDate = s_tm
  9722. order.DrordStopDate = ""
  9723. order.DrordDrCodg = doctor_info.DoctorNumber
  9724. order.DrordDeptName = department.Name
  9725. order.DrordDeptCodg = department.Number
  9726. order.DrordDrName = doctor_info.UserName
  9727. order.DrordDrProfttl = "234"
  9728. order.CurrDrordFlag = "1"
  9729. orders = append(orders, &order)
  9730. }
  9731. }
  9732. for _, subItem := range item.HisPrescriptionProject {
  9733. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  9734. var order models.FsiOrderDtos
  9735. order.RxID = strconv.FormatInt(item.ID, 10)
  9736. order.Rxno = strconv.FormatInt(item.ID, 10)
  9737. order.LongDrordFlag = "0"
  9738. order.HilistType = "1"
  9739. order.ChrgType = "1"
  9740. order.DrordBhvr = "-"
  9741. order.HilistCode = subItem.HisProject.MedicalCode
  9742. order.HosplistName = subItem.HisProject.ProjectName
  9743. order.HilistLv = "1"
  9744. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9745. order.HosplistCode = subItem.HisProject.MedicalCode
  9746. order.HosplistName = subItem.HisProject.ProjectName
  9747. order.Cnt = subItem.Count
  9748. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9749. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9750. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  9751. order.OwnpayAmt = ""
  9752. order.SelfpayAmt = ""
  9753. order.Spec = ""
  9754. order.SpecUnt = ""
  9755. order.DrordBegnDate = s_tm
  9756. order.DrordStopDate = ""
  9757. order.DrordDrCodg = doctor_info.DoctorNumber
  9758. order.DrordDeptName = department.Name
  9759. order.DrordDeptCodg = department.Number
  9760. order.DrordDrName = doctor_info.UserName
  9761. order.DrordDrProfttl = "234"
  9762. order.CurrDrordFlag = "1"
  9763. orders = append(orders, &order)
  9764. }
  9765. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  9766. var order models.FsiOrderDtos
  9767. order.RxID = strconv.FormatInt(item.ID, 10)
  9768. order.Rxno = strconv.FormatInt(item.ID, 10)
  9769. order.LongDrordFlag = "0"
  9770. order.HilistType = "1"
  9771. order.ChrgType = "1"
  9772. order.DrordBhvr = "-"
  9773. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9774. order.HosplistName = subItem.GoodInfo.GoodName
  9775. order.HilistLv = "1"
  9776. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  9777. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  9778. order.HosplistName = subItem.GoodInfo.GoodName
  9779. order.Cnt = subItem.Count
  9780. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9781. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  9782. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  9783. order.OwnpayAmt = ""
  9784. order.SelfpayAmt = ""
  9785. order.Spec = ""
  9786. order.SpecUnt = ""
  9787. order.DrordBegnDate = s_tm
  9788. order.DrordStopDate = ""
  9789. order.DrordDrCodg = doctor_info.DoctorNumber
  9790. order.DrordDeptName = department.Name
  9791. order.DrordDeptCodg = department.Number
  9792. order.DrordDrName = doctor_info.UserName
  9793. order.DrordDrProfttl = "234"
  9794. order.CurrDrordFlag = "1"
  9795. orders = append(orders, &order)
  9796. }
  9797. }
  9798. }
  9799. //处方医嘱信息
  9800. }
  9801. fed.MatnStas = "0"
  9802. fed.MedfeeSumamt = "0"
  9803. fed.OwnpayAmt = "0"
  9804. fed.SelfpayAmt = "0"
  9805. fed.AcctPayamt = "0"
  9806. fed.MaAmt = "0"
  9807. fed.HifpPayamt = "0"
  9808. fed.SetlTotlnum = "1"
  9809. fed.Insutype = his.Insutype
  9810. fed.ReimFlag = "0"
  9811. fed.OutSetlFlag = "0"
  9812. var fopd []*models.FsiOperationDtosData
  9813. data := make(map[string]interface{})
  9814. data["fed"] = fed
  9815. data["fdd"] = fdds
  9816. data["fod"] = orders
  9817. data["pd"] = pd
  9818. data["pp"] = pp
  9819. data["fopd"] = fopd
  9820. data["trig_scen"] = trig_scen
  9821. fmt.Println(data)
  9822. fmt.Println(fed)
  9823. fmt.Println(fdds)
  9824. fmt.Println(orders)
  9825. fmt.Println(pd)
  9826. fmt.Println(pp)
  9827. fmt.Println(fopd)
  9828. client := &http.Client{}
  9829. bytesData, _ := json.Marshal(data)
  9830. var req *http.Request
  9831. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9832. if miConfig.MdtrtareaAdmvs == "320921" {
  9833. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  9834. } else {
  9835. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  9836. }
  9837. resp, _ := client.Do(req)
  9838. defer resp.Body.Close()
  9839. body, ioErr := ioutil.ReadAll(resp.Body)
  9840. if ioErr != nil {
  9841. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9843. return res
  9844. }
  9845. var respJSON map[string]interface{}
  9846. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9847. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9849. return res
  9850. }
  9851. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  9852. fmt.Println(respJSON)
  9853. result, _ := json.Marshal(respJSON)
  9854. fmt.Println(result)
  9855. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9856. utils.ErrorLog("解析失败:%v", err)
  9857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9858. return res
  9859. }
  9860. return res
  9861. } else {
  9862. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  9863. saveLog(output, input, "3101", "事前")
  9864. if err := json.Unmarshal([]byte(output), &res); err != nil {
  9865. utils.ErrorLog("解析失败:%v", err)
  9866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9867. return
  9868. }
  9869. return res
  9870. }
  9871. return res
  9872. }
  9873. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  9874. ////patient_id, _ := c.GetInt64("patient_id")
  9875. //order_id, _ := c.GetInt64("order_id")
  9876. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  9877. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  9878. //trig_scen := c.GetString("trig_scen")
  9879. adminUser := c.GetAdminUserInfo()
  9880. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9881. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  9882. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9883. record_time := c.GetString("record_time")
  9884. order, _ := service.GetHisOrderByID(order_id)
  9885. psn_info, _ := service.GetPsnByPatientId(patient_id)
  9886. timeLayout := "2006-01-02"
  9887. loc, _ := time.LoadLocation("Local")
  9888. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9889. if err != nil {
  9890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9891. return
  9892. }
  9893. recordDateTime := theTime.Unix()
  9894. var patientPrescription models.HisPrescriptionInfo
  9895. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9896. if patientPrescription.ID == 0 {
  9897. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  9898. }
  9899. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9900. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9901. //
  9902. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9903. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9904. var pp models.PublicParams
  9905. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  9906. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  9907. pp.FixmedinsName = miConfig.OrgName
  9908. pp.FixmedinsCode = miConfig.Code
  9909. pp.RequestUrl = miConfig.Url
  9910. pp.Cainfo = miConfig.Cainfo
  9911. pp.SecretKey = miConfig.SecretKey
  9912. pp.AccessKey = miConfig.AccessKey
  9913. pp.OpterName = roles.UserName
  9914. var config []*models.HisXtDiagnoseConfig
  9915. for _, item := range diagnosis_ids {
  9916. id, _ := strconv.ParseInt(item, 10, 64)
  9917. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9918. config = append(config, &diagnosisConfig)
  9919. }
  9920. var pd models.PatientDtos
  9921. pd.PatnID = his.PsnNo
  9922. pd.PatnName = his.Name
  9923. pd.Gend = his.Gend
  9924. pd.Brdy = psn_info.Brdy
  9925. pd.Poolarea = his.InsuplcAdmdvs
  9926. pd.CurrMdtrtID = his.Number
  9927. var fed models.FsiEncounterDtos
  9928. fed.MdtrtID = his.Number
  9929. fed.MedinsID = miConfig.Code
  9930. fed.MedinsName = miConfig.OrgName
  9931. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  9932. fed.MedMdtrtType = "1"
  9933. fed.MedinsType = "1"
  9934. fed.MedinsLv = "11"
  9935. tm := time.Unix(his.RecordDate, 0)
  9936. s_tm := tm.Format("2006-01-02 15:04:05")
  9937. fed.AdmDate = s_tm
  9938. fed.DscgDate = s_tm
  9939. fed.DscgMainDiseCodg = config[0].CountryCode
  9940. fed.DscgMainDiseName = config[0].CountryContentName
  9941. //诊断信息
  9942. var fdds []*models.FsiDiagnoseDtos
  9943. for index, item := range config {
  9944. if index == 0 {
  9945. var fdd models.FsiDiagnoseDtos
  9946. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9947. fdd.InoutDiseType = "1"
  9948. fdd.MaindiseFlag = "1"
  9949. fdd.DiseDate = s_tm
  9950. fdd.DiasSrtNo = "1"
  9951. fdd.DiseName = item.CountryContentName
  9952. fdd.DiseCodg = item.CountryCode
  9953. fdds = append(fdds, &fdd)
  9954. } else {
  9955. var fdd models.FsiDiagnoseDtos
  9956. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  9957. fdd.InoutDiseType = "1"
  9958. fdd.MaindiseFlag = "1"
  9959. fdd.DiseDate = s_tm
  9960. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  9961. fdd.DiseName = item.CountryContentName
  9962. fdd.DiseCodg = item.CountryCode
  9963. fdds = append(fdds, &fdd)
  9964. }
  9965. }
  9966. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  9967. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  9968. fed.AdmDeptName = department.Name
  9969. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  9970. fed.DscgDeptName = department.Name
  9971. fed.MedType = order.MedType
  9972. //处方医嘱信息
  9973. var orders []*models.FsiOrderDtos
  9974. //for _, item := range prescriptions {
  9975. // for _, subItem := range item.HisDoctorAdviceInfo {
  9976. // var order models.FsiOrderDtos
  9977. // order.RxID = strconv.FormatInt(item.ID, 10)
  9978. // order.Rxno = strconv.FormatInt(item.ID, 10)
  9979. // order.LongDrordFlag = "0"
  9980. // order.HilistType = "1"
  9981. // order.ChrgType = "1"
  9982. // order.DrordBhvr = "-"
  9983. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9984. // order.HosplistName = subItem.BaseDrugLib.DrugName
  9985. // order.HilistLv = "1"
  9986. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  9987. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  9988. // order.HosplistName = subItem.BaseDrugLib.DrugName
  9989. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  9990. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  9991. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  9992. // order.OwnpayAmt = ""
  9993. // order.SelfpayAmt = ""
  9994. // order.Spec = ""
  9995. // order.SpecUnt = ""
  9996. // order.DrordBegnDate = s_tm
  9997. // order.DrordStopDate = ""
  9998. // order.DrordDrCodg = "1"
  9999. // order.DrordDeptName = department.Name
  10000. // order.DrordDrCodg = "1"
  10001. // order.DrordDrName = doctor_info.UserName
  10002. // order.DrordDrProfttl = ""
  10003. // order.CurrDrordFlag = "1"
  10004. // orders = append(orders, &order)
  10005. // }
  10006. // for _, subItem := range item.HisPrescriptionProject {
  10007. // if subItem.Type == 2 {
  10008. // var order models.FsiOrderDtos
  10009. // order.RxID = strconv.FormatInt(item.ID, 10)
  10010. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10011. // order.LongDrordFlag = "0"
  10012. // order.HilistType = "1"
  10013. // order.ChrgType = "1"
  10014. // order.DrordBhvr = "-"
  10015. // order.HilistCode = subItem.HisProject.MedicalCode
  10016. // order.HosplistName = subItem.HisProject.ProjectName
  10017. // order.HilistLv = "1"
  10018. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10019. // order.HosplistCode = subItem.HisProject.MedicalCode
  10020. // order.HosplistName = subItem.HisProject.ProjectName
  10021. // order.Cnt = subItem.Count
  10022. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10023. //
  10024. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10025. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10026. // order.OwnpayAmt = ""
  10027. // order.SelfpayAmt = ""
  10028. // order.Spec = ""
  10029. // order.SpecUnt = ""
  10030. // order.DrordBegnDate = s_tm
  10031. // order.DrordStopDate = ""
  10032. // order.DrordDrCodg = "1"
  10033. // order.DrordDeptName = department.Name
  10034. // order.DrordDrCodg = "1"
  10035. // order.DrordDrName = doctor_info.UserName
  10036. // order.DrordDrProfttl = ""
  10037. // order.CurrDrordFlag = "1"
  10038. // orders = append(orders, &order)
  10039. //
  10040. // }
  10041. // if subItem.Type == 3 {
  10042. //
  10043. // var order models.FsiOrderDtos
  10044. // order.RxID = strconv.FormatInt(item.ID, 10)
  10045. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10046. // order.LongDrordFlag = "0"
  10047. // order.HilistType = "1"
  10048. // order.ChrgType = "1"
  10049. // order.DrordBhvr = "-"
  10050. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10051. // order.HosplistName = subItem.GoodInfo.GoodName
  10052. // order.HilistLv = "1"
  10053. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10054. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10055. // order.HosplistName = subItem.GoodInfo.GoodName
  10056. // order.Cnt = subItem.Count
  10057. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10058. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10059. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10060. // order.OwnpayAmt = ""
  10061. // order.SelfpayAmt = ""
  10062. // order.Spec = ""
  10063. // order.SpecUnt = ""
  10064. // order.DrordBegnDate = s_tm
  10065. // order.DrordStopDate = ""
  10066. // order.DrordDrCodg = "1"
  10067. // order.DrordDeptName = department.Name
  10068. // order.DrordDrCodg = "1"
  10069. // order.DrordDrName = doctor_info.UserName
  10070. // order.DrordDrProfttl = ""
  10071. // order.CurrDrordFlag = "1"
  10072. // orders = append(orders, &order)
  10073. //
  10074. // }
  10075. // }
  10076. //}
  10077. for _, item := range prescriptions {
  10078. for _, subItem := range item.HisDoctorAdviceInfo {
  10079. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10080. var order models.FsiOrderDtos
  10081. order.RxID = strconv.FormatInt(item.ID, 10)
  10082. order.Rxno = strconv.FormatInt(item.ID, 10)
  10083. order.LongDrordFlag = "0"
  10084. order.HilistType = "1"
  10085. order.ChrgType = "1"
  10086. order.DrordBhvr = "-"
  10087. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10088. order.HosplistName = subItem.BaseDrugLib.DrugName
  10089. order.HilistLv = "1"
  10090. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10091. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10092. order.HosplistName = subItem.BaseDrugLib.DrugName
  10093. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10094. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10095. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10096. order.OwnpayAmt = ""
  10097. order.SelfpayAmt = ""
  10098. order.Spec = ""
  10099. order.SpecUnt = ""
  10100. order.DrordBegnDate = s_tm
  10101. order.DrordStopDate = ""
  10102. order.DrordDrCodg = doctor_info.DoctorNumber
  10103. order.DrordDeptName = department.Name
  10104. order.DrordDeptCodg = department.Number
  10105. order.DrordDrName = doctor_info.UserName
  10106. order.DrordDrProfttl = "234"
  10107. order.CurrDrordFlag = "1"
  10108. orders = append(orders, &order)
  10109. }
  10110. }
  10111. for _, subItem := range item.HisPrescriptionProject {
  10112. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10113. var order models.FsiOrderDtos
  10114. order.RxID = strconv.FormatInt(item.ID, 10)
  10115. order.Rxno = strconv.FormatInt(item.ID, 10)
  10116. order.LongDrordFlag = "0"
  10117. order.HilistType = "1"
  10118. order.ChrgType = "1"
  10119. order.DrordBhvr = "-"
  10120. order.HilistCode = subItem.HisProject.MedicalCode
  10121. order.HosplistName = subItem.HisProject.ProjectName
  10122. order.HilistLv = "1"
  10123. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10124. order.HosplistCode = subItem.HisProject.MedicalCode
  10125. order.HosplistName = subItem.HisProject.ProjectName
  10126. order.Cnt = subItem.Count
  10127. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10128. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10129. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10130. order.OwnpayAmt = ""
  10131. order.SelfpayAmt = ""
  10132. order.Spec = ""
  10133. order.SpecUnt = ""
  10134. order.DrordBegnDate = s_tm
  10135. order.DrordStopDate = ""
  10136. order.DrordDrCodg = doctor_info.DoctorNumber
  10137. order.DrordDeptName = department.Name
  10138. order.DrordDeptCodg = department.Number
  10139. order.DrordDrName = doctor_info.UserName
  10140. order.DrordDrProfttl = "234"
  10141. order.CurrDrordFlag = "1"
  10142. orders = append(orders, &order)
  10143. }
  10144. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10145. var order models.FsiOrderDtos
  10146. order.RxID = strconv.FormatInt(item.ID, 10)
  10147. order.Rxno = strconv.FormatInt(item.ID, 10)
  10148. order.LongDrordFlag = "0"
  10149. order.HilistType = "1"
  10150. order.ChrgType = "1"
  10151. order.DrordBhvr = "0"
  10152. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10153. order.HosplistName = subItem.GoodInfo.GoodName
  10154. order.HilistLv = "1"
  10155. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10156. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10157. order.HosplistName = subItem.GoodInfo.GoodName
  10158. order.Cnt = subItem.Count
  10159. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10160. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10161. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10162. order.OwnpayAmt = ""
  10163. order.SelfpayAmt = ""
  10164. order.Spec = ""
  10165. order.SpecUnt = ""
  10166. order.DrordBegnDate = s_tm
  10167. order.DrordStopDate = ""
  10168. order.DrordDrCodg = doctor_info.DoctorNumber
  10169. order.DrordDeptName = department.Name
  10170. order.DrordDeptCodg = department.Number
  10171. order.DrordDrName = doctor_info.UserName
  10172. order.DrordDrProfttl = "234"
  10173. order.CurrDrordFlag = "1"
  10174. orders = append(orders, &order)
  10175. }
  10176. }
  10177. }
  10178. //处方医嘱信息
  10179. fed.MatnStas = "0"
  10180. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  10181. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  10182. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  10183. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  10184. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  10185. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  10186. fed.SetlTotlnum = "1"
  10187. fed.Insutype = his.Insutype
  10188. fed.ReimFlag = "0"
  10189. fed.OutSetlFlag = "0"
  10190. var fopd []*models.FsiOperationDtosData
  10191. data := make(map[string]interface{})
  10192. data["fed"] = fed
  10193. data["fdd"] = fdds
  10194. data["fod"] = orders
  10195. data["pd"] = pd
  10196. data["pp"] = pp
  10197. data["fopd"] = fopd
  10198. data["trig_scen"] = trig_scen
  10199. client := &http.Client{}
  10200. bytesData, _ := json.Marshal(data)
  10201. var req *http.Request
  10202. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10203. if miConfig.MdtrtareaAdmvs == "320921" {
  10204. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  10205. } else {
  10206. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  10207. }
  10208. resp, _ := client.Do(req)
  10209. defer resp.Body.Close()
  10210. body, ioErr := ioutil.ReadAll(resp.Body)
  10211. if ioErr != nil {
  10212. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10214. return res
  10215. }
  10216. var respJSON map[string]interface{}
  10217. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10218. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10220. return res
  10221. }
  10222. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10223. result, _ := json.Marshal(respJSON)
  10224. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10225. utils.ErrorLog("解析失败:%v", err)
  10226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10227. return res
  10228. }
  10229. return res
  10230. } else {
  10231. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10232. saveLog(output, input, "3102", "事中")
  10233. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10234. utils.ErrorLog("解析失败:%v", err)
  10235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10236. return
  10237. }
  10238. return res
  10239. }
  10240. return res
  10241. }
  10242. 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) {
  10243. var res Resultgd3101
  10244. adminUser := c.GetAdminUserInfo()
  10245. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10246. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10247. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10248. //record_time := c.GetString("record_time")
  10249. //trig_scen := c.GetString("trig_scen")
  10250. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  10251. //psn_info, _ := service.GetPatientId(patient_id)
  10252. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  10253. timeLayout := "2006-01-02"
  10254. loc, _ := time.LoadLocation("Local")
  10255. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10256. if err != nil {
  10257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10258. return res
  10259. }
  10260. recordDateTime := theTime.Unix()
  10261. var patientPrescription models.HisPrescriptionInfo
  10262. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10263. //if patientPrescription.ID == 0 {
  10264. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10265. //}
  10266. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10267. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10268. //
  10269. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10270. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10271. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  10272. var pp models.PublicParams
  10273. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10274. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10275. pp.FixmedinsName = miConfig.OrgName
  10276. pp.FixmedinsCode = miConfig.Code
  10277. pp.RequestUrl = miConfig.Url
  10278. pp.Cainfo = miConfig.Cainfo
  10279. pp.SecretKey = miConfig.SecretKey
  10280. pp.AccessKey = miConfig.AccessKey
  10281. pp.OpterName = roles.UserName
  10282. var config []*models.HisXtDiagnoseConfig
  10283. for _, item := range diagnosis_ids {
  10284. id, _ := strconv.ParseInt(item, 10, 64)
  10285. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10286. config = append(config, &diagnosisConfig)
  10287. }
  10288. var pd models.PatientDtos
  10289. pd.PatnID = his.PsnNo
  10290. pd.PatnName = his.Name
  10291. pd.Gend = his.Gend
  10292. pd.Brdy = str
  10293. pd.Poolarea = miConfig.MdtrtareaAdmvs
  10294. pd.CurrMdtrtID = his.Number
  10295. var fed models.FsiEncounterDtos
  10296. fed.MdtrtID = his.Number
  10297. fed.MedinsID = miConfig.Code
  10298. fed.MedinsName = miConfig.OrgName
  10299. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10300. fed.MedMdtrtType = "1"
  10301. fed.MedinsType = "1"
  10302. fed.MedinsLv = "11"
  10303. tm := time.Unix(his.RecordDate, 0)
  10304. s_tm := tm.Format("2006-01-02 15:04:05")
  10305. fed.AdmDate = s_tm
  10306. fed.DscgDate = s_tm
  10307. fed.DscgMainDiseCodg = config[0].CountryCode
  10308. fed.DscgMainDiseName = config[0].CountryContentName
  10309. //诊断信息
  10310. var fdds []*models.FsiDiagnoseDtos
  10311. for index, item := range config {
  10312. if index == 0 {
  10313. var fdd models.FsiDiagnoseDtos
  10314. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10315. fdd.InoutDiseType = "1"
  10316. fdd.MaindiseFlag = "1"
  10317. fdd.DiseDate = s_tm
  10318. fdd.DiasSrtNo = "1"
  10319. fdd.DiseName = item.CountryContentName
  10320. fdd.DiseCodg = item.CountryCode
  10321. fdds = append(fdds, &fdd)
  10322. } else {
  10323. var fdd models.FsiDiagnoseDtos
  10324. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10325. fdd.InoutDiseType = "1"
  10326. fdd.MaindiseFlag = "1"
  10327. fdd.DiseDate = s_tm
  10328. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10329. fdd.DiseName = item.CountryContentName
  10330. fdd.DiseCodg = item.CountryCode
  10331. fdds = append(fdds, &fdd)
  10332. }
  10333. }
  10334. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10335. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  10336. fed.AdmDeptName = de.Name
  10337. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  10338. fed.DscgDeptName = de.Name
  10339. fed.MedMdtrtType = "1"
  10340. fed.MedType = "11"
  10341. //if his.Insutype == "390" {
  10342. // fed.MedType = "1402"
  10343. //} else {
  10344. // fed.MedType = "9933"
  10345. //}
  10346. var orders []*models.FsiOrderDtos
  10347. if trig_scen == "2" {
  10348. //处方医嘱信息
  10349. for _, item := range prescriptions {
  10350. for _, subItem := range item.HisDoctorAdviceInfo {
  10351. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10352. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  10353. var order models.FsiOrderDtos
  10354. order.RxID = strconv.FormatInt(item.ID, 10)
  10355. order.Rxno = strconv.FormatInt(item.ID, 10)
  10356. order.LongDrordFlag = "0"
  10357. order.HilistType = "1"
  10358. order.ChrgType = "1"
  10359. order.DrordBhvr = "0"
  10360. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10361. order.HosplistName = subItem.BaseDrugLib.DrugName
  10362. order.HilistLv = "1"
  10363. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10364. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10365. order.HosplistName = subItem.BaseDrugLib.DrugName
  10366. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10367. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10368. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10369. order.OwnpayAmt = ""
  10370. order.SelfpayAmt = ""
  10371. order.Spec = spec
  10372. order.SpecUnt = subItem.PrescribingNumberUnit
  10373. order.DrordBegnDate = s_tm
  10374. order.DrordStopDate = ""
  10375. order.DrordDrCodg = doctor_info.DoctorNumber
  10376. order.DrordDeptName = department.Name
  10377. order.DrordDeptCodg = department.Number
  10378. order.DrordDrName = doctor_info.UserName
  10379. order.DrordDrProfttl = "234"
  10380. order.CurrDrordFlag = "1"
  10381. orders = append(orders, &order)
  10382. }
  10383. }
  10384. for _, subItem := range item.HisPrescriptionProject {
  10385. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10386. var order models.FsiOrderDtos
  10387. order.RxID = strconv.FormatInt(item.ID, 10)
  10388. order.Rxno = strconv.FormatInt(item.ID, 10)
  10389. order.LongDrordFlag = "0"
  10390. order.HilistType = "1"
  10391. order.ChrgType = "1"
  10392. order.DrordBhvr = "0"
  10393. order.HilistCode = subItem.HisProject.MedicalCode
  10394. order.HosplistName = subItem.HisProject.ProjectName
  10395. order.HilistLv = "1"
  10396. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10397. order.HosplistCode = subItem.HisProject.MedicalCode
  10398. order.HosplistName = subItem.HisProject.ProjectName
  10399. order.Cnt = subItem.Count
  10400. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10401. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10402. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10403. order.OwnpayAmt = ""
  10404. order.SelfpayAmt = ""
  10405. order.Spec = subItem.Unit
  10406. order.SpecUnt = subItem.Unit
  10407. order.DrordBegnDate = s_tm
  10408. order.DrordStopDate = ""
  10409. order.DrordDrCodg = doctor_info.DoctorNumber
  10410. order.DrordDeptName = department.Name
  10411. order.DrordDeptCodg = department.Number
  10412. order.DrordDrName = doctor_info.UserName
  10413. order.DrordDrProfttl = "234"
  10414. order.CurrDrordFlag = "1"
  10415. orders = append(orders, &order)
  10416. }
  10417. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10418. var order models.FsiOrderDtos
  10419. order.RxID = strconv.FormatInt(item.ID, 10)
  10420. order.Rxno = strconv.FormatInt(item.ID, 10)
  10421. order.LongDrordFlag = "0"
  10422. order.HilistType = "1"
  10423. order.ChrgType = "1"
  10424. order.DrordBhvr = "0"
  10425. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10426. order.HosplistName = subItem.GoodInfo.GoodName
  10427. order.HilistLv = "1"
  10428. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10429. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10430. order.HosplistName = subItem.GoodInfo.GoodName
  10431. order.Cnt = subItem.Count
  10432. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10433. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10434. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10435. order.OwnpayAmt = ""
  10436. order.SelfpayAmt = ""
  10437. order.Spec = subItem.GoodInfo.SpecificationName
  10438. order.SpecUnt = subItem.Unit
  10439. order.DrordBegnDate = s_tm
  10440. order.DrordStopDate = ""
  10441. order.DrordDrCodg = doctor_info.DoctorNumber
  10442. order.DrordDeptName = department.Name
  10443. order.DrordDeptCodg = department.Number
  10444. order.DrordDrName = doctor_info.UserName
  10445. order.DrordDrProfttl = "234"
  10446. order.CurrDrordFlag = "1"
  10447. orders = append(orders, &order)
  10448. }
  10449. }
  10450. }
  10451. //处方医嘱信息
  10452. }
  10453. fed.MatnStas = "0"
  10454. fed.MedfeeSumamt = "0"
  10455. fed.OwnpayAmt = "0"
  10456. fed.SelfpayAmt = "0"
  10457. fed.AcctPayamt = "0"
  10458. fed.MaAmt = "0"
  10459. fed.HifpPayamt = "0"
  10460. fed.SetlTotlnum = "1"
  10461. fed.Insutype = his.Insutype
  10462. fed.ReimFlag = "0"
  10463. fed.OutSetlFlag = "0"
  10464. var fopd []*models.FsiOperationDtosData
  10465. data := make(map[string]interface{})
  10466. data["fed"] = fed
  10467. data["fdd"] = fdds
  10468. data["fod"] = orders
  10469. data["pd"] = pd
  10470. data["pp"] = pp
  10471. data["fopd"] = fopd
  10472. data["trig_scen"] = trig_scen
  10473. fmt.Println(data)
  10474. fmt.Println(fed)
  10475. fmt.Println(fdds)
  10476. fmt.Println(orders)
  10477. fmt.Println(pd)
  10478. fmt.Println(pp)
  10479. fmt.Println(fopd)
  10480. client := &http.Client{}
  10481. bytesData, _ := json.Marshal(data)
  10482. var req *http.Request
  10483. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10484. if miConfig.MdtrtareaAdmvs == "320921" {
  10485. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10486. } else {
  10487. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10488. }
  10489. resp, _ := client.Do(req)
  10490. defer resp.Body.Close()
  10491. body, ioErr := ioutil.ReadAll(resp.Body)
  10492. if ioErr != nil {
  10493. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10495. return res
  10496. }
  10497. var respJSON map[string]interface{}
  10498. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10499. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10501. return res
  10502. }
  10503. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10504. fmt.Println(respJSON)
  10505. result, _ := json.Marshal(respJSON)
  10506. fmt.Println(result)
  10507. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10508. utils.ErrorLog("解析失败:%v", err)
  10509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10510. return res
  10511. }
  10512. return res
  10513. } else {
  10514. //if miConfig.MdtrtareaAdmvs == "441202" {
  10515. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10516. saveLog(output, input, "3101", "事前")
  10517. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10518. utils.ErrorLog("解析失败:%v", err)
  10519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10520. return
  10521. }
  10522. return res
  10523. //}
  10524. }
  10525. }
  10526. 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) {
  10527. adminUser := c.GetAdminUserInfo()
  10528. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10529. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10530. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10531. //record_time := c.GetString("record_time")
  10532. //trig_scen := c.GetString("trig_scen")
  10533. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  10534. timeLayout := "2006-01-02"
  10535. loc, _ := time.LoadLocation("Local")
  10536. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10537. if err != nil {
  10538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10539. return res
  10540. }
  10541. recordDateTime := theTime.Unix()
  10542. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  10543. var patientPrescription models.HisPrescriptionInfo
  10544. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10545. if patientPrescription.ID == 0 {
  10546. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10547. }
  10548. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10549. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10550. //
  10551. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  10552. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10553. var pp models.PublicParams
  10554. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10555. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10556. pp.FixmedinsName = miConfig.OrgName
  10557. pp.FixmedinsCode = miConfig.Code
  10558. pp.RequestUrl = miConfig.Url
  10559. pp.Cainfo = miConfig.Cainfo
  10560. pp.SecretKey = miConfig.SecretKey
  10561. pp.AccessKey = miConfig.AccessKey
  10562. pp.OpterName = roles.UserName
  10563. var config []*models.HisXtDiagnoseConfig
  10564. for _, item := range diagnosis_ids {
  10565. id, _ := strconv.ParseInt(item, 10, 64)
  10566. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10567. config = append(config, &diagnosisConfig)
  10568. }
  10569. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  10570. var pd models.PatientDtos
  10571. pd.PatnID = his.PsnNo
  10572. pd.PatnName = his.Name
  10573. pd.Gend = his.Gend
  10574. pd.Brdy = str
  10575. pd.Poolarea = his.InsuplcAdmdvs
  10576. pd.CurrMdtrtID = his.Number
  10577. var fed models.FsiEncounterDtos
  10578. fed.MdtrtID = his.Number
  10579. fed.MedinsID = miConfig.Code
  10580. fed.MedinsName = miConfig.OrgName
  10581. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10582. fed.MedMdtrtType = "1"
  10583. fed.MedinsType = "1"
  10584. fed.MedinsLv = "11"
  10585. tm := time.Unix(his.RecordDate, 0)
  10586. s_tm := tm.Format("2006-01-02 15:04:05")
  10587. fed.AdmDate = s_tm
  10588. fed.DscgDate = s_tm
  10589. fed.DscgMainDiseCodg = config[0].CountryCode
  10590. fed.DscgMainDiseName = config[0].CountryContentName
  10591. //诊断信息
  10592. var fdds []*models.FsiDiagnoseDtos
  10593. for index, item := range config {
  10594. if index == 0 {
  10595. var fdd models.FsiDiagnoseDtos
  10596. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10597. fdd.InoutDiseType = "1"
  10598. fdd.MaindiseFlag = "1"
  10599. fdd.DiseDate = s_tm
  10600. fdd.DiasSrtNo = "1"
  10601. fdd.DiseName = item.CountryContentName
  10602. fdd.DiseCodg = item.CountryCode
  10603. fdds = append(fdds, &fdd)
  10604. } else {
  10605. var fdd models.FsiDiagnoseDtos
  10606. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10607. fdd.InoutDiseType = "1"
  10608. fdd.MaindiseFlag = "1"
  10609. fdd.DiseDate = s_tm
  10610. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10611. fdd.DiseName = item.CountryContentName
  10612. fdd.DiseCodg = item.CountryCode
  10613. fdds = append(fdds, &fdd)
  10614. }
  10615. }
  10616. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10617. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10618. fed.AdmDeptName = department.Name
  10619. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10620. fed.DscgDeptName = department.Name
  10621. fed.MedMdtrtType = "1"
  10622. fed.MedType = "11"
  10623. //if his.Insutype == "390" {
  10624. // fed.MedType = "1402"
  10625. //} else {
  10626. // fed.MedType = "9933"
  10627. //}
  10628. var orders []*models.FsiOrderDtos
  10629. if trig_scen == "2" {
  10630. //处方医嘱信息
  10631. for _, item := range prescriptions {
  10632. for _, subItem := range item.HisDoctorAdviceInfo {
  10633. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  10634. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  10635. var order models.FsiOrderDtos
  10636. order.RxID = strconv.FormatInt(item.ID, 10)
  10637. order.Rxno = strconv.FormatInt(item.ID, 10)
  10638. order.LongDrordFlag = "0"
  10639. order.HilistType = "1"
  10640. order.ChrgType = "1"
  10641. order.DrordBhvr = "0"
  10642. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10643. order.HosplistName = subItem.BaseDrugLib.DrugName
  10644. order.HilistLv = "1"
  10645. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10646. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10647. order.HosplistName = subItem.BaseDrugLib.DrugName
  10648. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  10649. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10650. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  10651. order.OwnpayAmt = ""
  10652. order.SelfpayAmt = ""
  10653. order.Spec = spec
  10654. order.SpecUnt = subItem.PrescribingNumberUnit
  10655. order.DrordBegnDate = s_tm
  10656. order.DrordStopDate = ""
  10657. order.DrordDrCodg = doctor_info.DoctorNumber
  10658. order.DrordDeptName = department.Name
  10659. order.DrordDeptCodg = department.Number
  10660. order.DrordDrName = doctor_info.UserName
  10661. order.DrordDrProfttl = "234"
  10662. order.CurrDrordFlag = "1"
  10663. orders = append(orders, &order)
  10664. }
  10665. }
  10666. for _, subItem := range item.HisPrescriptionProject {
  10667. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  10668. var order models.FsiOrderDtos
  10669. order.RxID = strconv.FormatInt(item.ID, 10)
  10670. order.Rxno = strconv.FormatInt(item.ID, 10)
  10671. order.LongDrordFlag = "0"
  10672. order.HilistType = "1"
  10673. order.ChrgType = "1"
  10674. order.DrordBhvr = "0"
  10675. order.HilistCode = subItem.HisProject.MedicalCode
  10676. order.HosplistName = subItem.HisProject.ProjectName
  10677. order.HilistLv = "1"
  10678. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10679. order.HosplistCode = subItem.HisProject.MedicalCode
  10680. order.HosplistName = subItem.HisProject.ProjectName
  10681. order.Cnt = subItem.Count
  10682. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10683. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10684. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10685. order.OwnpayAmt = ""
  10686. order.SelfpayAmt = ""
  10687. order.Spec = subItem.Unit
  10688. order.SpecUnt = subItem.Unit
  10689. order.DrordBegnDate = s_tm
  10690. order.DrordStopDate = ""
  10691. order.DrordDrCodg = doctor_info.DoctorNumber
  10692. order.DrordDeptName = department.Name
  10693. order.DrordDeptCodg = department.Number
  10694. order.DrordDrName = doctor_info.UserName
  10695. order.DrordDrProfttl = "234"
  10696. order.CurrDrordFlag = "1"
  10697. orders = append(orders, &order)
  10698. }
  10699. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  10700. var order models.FsiOrderDtos
  10701. order.RxID = strconv.FormatInt(item.ID, 10)
  10702. order.Rxno = strconv.FormatInt(item.ID, 10)
  10703. order.LongDrordFlag = "0"
  10704. order.HilistType = "1"
  10705. order.ChrgType = "1"
  10706. order.DrordBhvr = "0"
  10707. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10708. order.HosplistName = subItem.GoodInfo.GoodName
  10709. order.HilistLv = "1"
  10710. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  10711. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10712. order.HosplistName = subItem.GoodInfo.GoodName
  10713. order.Cnt = subItem.Count
  10714. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10715. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  10716. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  10717. order.OwnpayAmt = ""
  10718. order.SelfpayAmt = ""
  10719. order.Spec = subItem.GoodInfo.SpecificationName
  10720. order.SpecUnt = subItem.Unit
  10721. order.DrordBegnDate = s_tm
  10722. order.DrordStopDate = ""
  10723. order.DrordDrCodg = doctor_info.DoctorNumber
  10724. order.DrordDeptName = department.Name
  10725. order.DrordDeptCodg = department.Number
  10726. order.DrordDrName = doctor_info.UserName
  10727. order.DrordDrProfttl = "234"
  10728. order.CurrDrordFlag = "1"
  10729. orders = append(orders, &order)
  10730. }
  10731. }
  10732. }
  10733. //处方医嘱信息
  10734. }
  10735. fed.MatnStas = "0"
  10736. fed.MedfeeSumamt = "0"
  10737. fed.OwnpayAmt = "0"
  10738. fed.SelfpayAmt = "0"
  10739. fed.AcctPayamt = "0"
  10740. fed.MaAmt = "0"
  10741. fed.HifpPayamt = "0"
  10742. fed.SetlTotlnum = "1"
  10743. fed.Insutype = his.Insutype
  10744. fed.ReimFlag = "0"
  10745. fed.OutSetlFlag = "0"
  10746. var fopd []*models.FsiOperationDtosData
  10747. data := make(map[string]interface{})
  10748. data["fed"] = fed
  10749. data["fdd"] = fdds
  10750. data["fod"] = orders
  10751. data["pd"] = pd
  10752. data["pp"] = pp
  10753. data["fopd"] = fopd
  10754. data["trig_scen"] = trig_scen
  10755. fmt.Println(data)
  10756. fmt.Println(fed)
  10757. fmt.Println(fdds)
  10758. fmt.Println(orders)
  10759. fmt.Println(pd)
  10760. fmt.Println(pp)
  10761. fmt.Println(fopd)
  10762. client := &http.Client{}
  10763. bytesData, _ := json.Marshal(data)
  10764. var req *http.Request
  10765. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10766. if miConfig.MdtrtareaAdmvs == "320921" {
  10767. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10768. } else {
  10769. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  10770. }
  10771. resp, _ := client.Do(req)
  10772. defer resp.Body.Close()
  10773. body, ioErr := ioutil.ReadAll(resp.Body)
  10774. if ioErr != nil {
  10775. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10777. return res
  10778. }
  10779. var respJSON map[string]interface{}
  10780. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10781. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10783. return res
  10784. }
  10785. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  10786. fmt.Println(respJSON)
  10787. result, _ := json.Marshal(respJSON)
  10788. fmt.Println(result)
  10789. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10790. utils.ErrorLog("解析失败:%v", err)
  10791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10792. return res
  10793. }
  10794. return res
  10795. } else {
  10796. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  10797. saveLog(output, input, "3101", "事前")
  10798. if err := json.Unmarshal([]byte(output), &res); err != nil {
  10799. utils.ErrorLog("解析失败:%v", err)
  10800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10801. return
  10802. }
  10803. return res
  10804. }
  10805. return res
  10806. }
  10807. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  10808. ////patient_id, _ := c.GetInt64("patient_id")
  10809. //order_id, _ := c.GetInt64("order_id")
  10810. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  10811. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  10812. //trig_scen := c.GetString("trig_scen")
  10813. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  10814. //utils.ErrorLog("解析失败:%v", psn_info)
  10815. adminUser := c.GetAdminUserInfo()
  10816. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10817. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10818. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10819. record_time := c.GetString("record_time")
  10820. order, _ := service.GetHisOrderByID(order_id)
  10821. timeLayout := "2006-01-02"
  10822. loc, _ := time.LoadLocation("Local")
  10823. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10824. if err != nil {
  10825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10826. return
  10827. }
  10828. recordDateTime := theTime.Unix()
  10829. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  10830. var patientPrescription models.HisPrescriptionInfo
  10831. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10832. if patientPrescription.ID == 0 {
  10833. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10834. }
  10835. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10836. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  10837. //
  10838. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  10839. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10840. var pp models.PublicParams
  10841. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  10842. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  10843. pp.FixmedinsName = miConfig.OrgName
  10844. pp.FixmedinsCode = miConfig.Code
  10845. pp.RequestUrl = miConfig.Url
  10846. pp.Cainfo = miConfig.Cainfo
  10847. pp.SecretKey = miConfig.SecretKey
  10848. pp.AccessKey = miConfig.AccessKey
  10849. pp.OpterName = roles.UserName
  10850. var config []*models.HisXtDiagnoseConfig
  10851. for _, item := range diagnosis_ids {
  10852. id, _ := strconv.ParseInt(item, 10, 64)
  10853. diagnosisConfig, _ := service.FindDiagnoseById(id)
  10854. config = append(config, &diagnosisConfig)
  10855. }
  10856. str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  10857. var pd models.PatientDtos
  10858. pd.PatnID = his.PsnNo
  10859. pd.PatnName = his.Name
  10860. pd.Gend = his.Gend
  10861. pd.Brdy = str
  10862. pd.Poolarea = his.InsuplcAdmdvs
  10863. pd.CurrMdtrtID = his.Number
  10864. var fed models.FsiEncounterDtos
  10865. fed.MdtrtID = his.Number
  10866. fed.MedinsID = miConfig.Code
  10867. fed.MedinsName = miConfig.OrgName
  10868. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  10869. fed.MedMdtrtType = "1"
  10870. fed.MedinsType = "1"
  10871. fed.MedinsLv = "11"
  10872. tm := time.Unix(his.RecordDate, 0)
  10873. s_tm := tm.Format("2006-01-02 15:04:05")
  10874. fed.AdmDate = s_tm
  10875. fed.DscgDate = s_tm
  10876. fed.DscgMainDiseCodg = config[0].CountryCode
  10877. fed.DscgMainDiseName = config[0].CountryContentName
  10878. //诊断信息
  10879. var fdds []*models.FsiDiagnoseDtos
  10880. for index, item := range config {
  10881. if index == 0 {
  10882. var fdd models.FsiDiagnoseDtos
  10883. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10884. fdd.InoutDiseType = "1"
  10885. fdd.MaindiseFlag = "1"
  10886. fdd.DiseDate = s_tm
  10887. fdd.DiasSrtNo = "1"
  10888. fdd.DiseName = item.CountryContentName
  10889. fdd.DiseCodg = item.CountryCode
  10890. fdds = append(fdds, &fdd)
  10891. } else {
  10892. var fdd models.FsiDiagnoseDtos
  10893. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  10894. fdd.InoutDiseType = "1"
  10895. fdd.MaindiseFlag = "1"
  10896. fdd.DiseDate = s_tm
  10897. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  10898. fdd.DiseName = item.CountryContentName
  10899. fdd.DiseCodg = item.CountryCode
  10900. fdds = append(fdds, &fdd)
  10901. }
  10902. }
  10903. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  10904. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  10905. fed.AdmDeptName = department.Name
  10906. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  10907. fed.DscgDeptName = department.Name
  10908. fed.MedType = order.MedType
  10909. //处方医嘱信息
  10910. var orders []*models.FsiOrderDtos
  10911. //for _, item := range prescriptions {
  10912. // for _, subItem := range item.HisDoctorAdviceInfo {
  10913. // var order models.FsiOrderDtos
  10914. // order.RxID = strconv.FormatInt(item.ID, 10)
  10915. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10916. // order.LongDrordFlag = "0"
  10917. // order.HilistType = "1"
  10918. // order.ChrgType = "1"
  10919. // order.DrordBhvr = "-"
  10920. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10921. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10922. // order.HilistLv = "1"
  10923. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10924. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  10925. // order.HosplistName = subItem.BaseDrugLib.DrugName
  10926. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  10927. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10928. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  10929. // order.OwnpayAmt = ""
  10930. // order.SelfpayAmt = ""
  10931. // order.Spec = ""
  10932. // order.SpecUnt = ""
  10933. // order.DrordBegnDate = s_tm
  10934. // order.DrordStopDate = ""
  10935. // order.DrordDrCodg = "1"
  10936. // order.DrordDeptName = department.Name
  10937. // order.DrordDrCodg = "1"
  10938. // order.DrordDrName = doctor_info.UserName
  10939. // order.DrordDrProfttl = ""
  10940. // order.CurrDrordFlag = "1"
  10941. // orders = append(orders, &order)
  10942. // }
  10943. // for _, subItem := range item.HisPrescriptionProject {
  10944. // if subItem.Type == 2 {
  10945. // var order models.FsiOrderDtos
  10946. // order.RxID = strconv.FormatInt(item.ID, 10)
  10947. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10948. // order.LongDrordFlag = "0"
  10949. // order.HilistType = "1"
  10950. // order.ChrgType = "1"
  10951. // order.DrordBhvr = "-"
  10952. // order.HilistCode = subItem.HisProject.MedicalCode
  10953. // order.HosplistName = subItem.HisProject.ProjectName
  10954. // order.HilistLv = "1"
  10955. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10956. // order.HosplistCode = subItem.HisProject.MedicalCode
  10957. // order.HosplistName = subItem.HisProject.ProjectName
  10958. // order.Cnt = subItem.Count
  10959. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10960. //
  10961. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10962. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10963. // order.OwnpayAmt = ""
  10964. // order.SelfpayAmt = ""
  10965. // order.Spec = ""
  10966. // order.SpecUnt = ""
  10967. // order.DrordBegnDate = s_tm
  10968. // order.DrordStopDate = ""
  10969. // order.DrordDrCodg = "1"
  10970. // order.DrordDeptName = department.Name
  10971. // order.DrordDrCodg = "1"
  10972. // order.DrordDrName = doctor_info.UserName
  10973. // order.DrordDrProfttl = ""
  10974. // order.CurrDrordFlag = "1"
  10975. // orders = append(orders, &order)
  10976. //
  10977. // }
  10978. // if subItem.Type == 3 {
  10979. //
  10980. // var order models.FsiOrderDtos
  10981. // order.RxID = strconv.FormatInt(item.ID, 10)
  10982. // order.Rxno = strconv.FormatInt(item.ID, 10)
  10983. // order.LongDrordFlag = "0"
  10984. // order.HilistType = "1"
  10985. // order.ChrgType = "1"
  10986. // order.DrordBhvr = "-"
  10987. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10988. // order.HosplistName = subItem.GoodInfo.GoodName
  10989. // order.HilistLv = "1"
  10990. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10991. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  10992. // order.HosplistName = subItem.GoodInfo.GoodName
  10993. // order.Cnt = subItem.Count
  10994. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10995. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  10996. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  10997. // order.OwnpayAmt = ""
  10998. // order.SelfpayAmt = ""
  10999. // order.Spec = ""
  11000. // order.SpecUnt = ""
  11001. // order.DrordBegnDate = s_tm
  11002. // order.DrordStopDate = ""
  11003. // order.DrordDrCodg = "1"
  11004. // order.DrordDeptName = department.Name
  11005. // order.DrordDrCodg = "1"
  11006. // order.DrordDrName = doctor_info.UserName
  11007. // order.DrordDrProfttl = ""
  11008. // order.CurrDrordFlag = "1"
  11009. // orders = append(orders, &order)
  11010. //
  11011. // }
  11012. // }
  11013. //}
  11014. for _, item := range prescriptions {
  11015. for _, subItem := range item.HisDoctorAdviceInfo {
  11016. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11017. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  11018. var order models.FsiOrderDtos
  11019. order.RxID = strconv.FormatInt(item.ID, 10)
  11020. order.Rxno = strconv.FormatInt(item.ID, 10)
  11021. order.LongDrordFlag = "0"
  11022. order.HilistType = "1"
  11023. order.ChrgType = "1"
  11024. order.DrordBhvr = "0"
  11025. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11026. order.HosplistName = subItem.BaseDrugLib.DrugName
  11027. order.HilistLv = "1"
  11028. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11029. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11030. order.HosplistName = subItem.BaseDrugLib.DrugName
  11031. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11032. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11033. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11034. order.OwnpayAmt = ""
  11035. order.SelfpayAmt = ""
  11036. order.Spec = spec
  11037. order.SpecUnt = subItem.PrescribingNumberUnit
  11038. order.DrordBegnDate = s_tm
  11039. order.DrordStopDate = ""
  11040. order.DrordDrCodg = doctor_info.DoctorNumber
  11041. order.DrordDeptName = department.Name
  11042. order.DrordDeptCodg = department.Number
  11043. order.DrordDrName = doctor_info.UserName
  11044. order.DrordDrProfttl = "234"
  11045. order.CurrDrordFlag = "1"
  11046. orders = append(orders, &order)
  11047. }
  11048. }
  11049. for _, subItem := range item.HisPrescriptionProject {
  11050. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11051. var order models.FsiOrderDtos
  11052. order.RxID = strconv.FormatInt(item.ID, 10)
  11053. order.Rxno = strconv.FormatInt(item.ID, 10)
  11054. order.LongDrordFlag = "0"
  11055. order.HilistType = "1"
  11056. order.ChrgType = "1"
  11057. order.DrordBhvr = "0"
  11058. order.HilistCode = subItem.HisProject.MedicalCode
  11059. order.HosplistName = subItem.HisProject.ProjectName
  11060. order.HilistLv = "1"
  11061. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11062. order.HosplistCode = subItem.HisProject.MedicalCode
  11063. order.HosplistName = subItem.HisProject.ProjectName
  11064. order.Cnt = subItem.Count
  11065. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11066. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11067. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11068. order.OwnpayAmt = ""
  11069. order.SelfpayAmt = ""
  11070. order.Spec = subItem.Unit
  11071. order.SpecUnt = subItem.Unit
  11072. order.DrordBegnDate = s_tm
  11073. order.DrordStopDate = ""
  11074. order.DrordDrCodg = doctor_info.DoctorNumber
  11075. order.DrordDeptName = department.Name
  11076. order.DrordDeptCodg = department.Number
  11077. order.DrordDrName = doctor_info.UserName
  11078. order.DrordDrProfttl = "234"
  11079. order.CurrDrordFlag = "1"
  11080. orders = append(orders, &order)
  11081. }
  11082. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11083. var order models.FsiOrderDtos
  11084. order.RxID = strconv.FormatInt(item.ID, 10)
  11085. order.Rxno = strconv.FormatInt(item.ID, 10)
  11086. order.LongDrordFlag = "0"
  11087. order.HilistType = "1"
  11088. order.ChrgType = "1"
  11089. order.DrordBhvr = "0"
  11090. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11091. order.HosplistName = subItem.GoodInfo.GoodName
  11092. order.HilistLv = "1"
  11093. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11094. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11095. order.HosplistName = subItem.GoodInfo.GoodName
  11096. order.Cnt = subItem.Count
  11097. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11098. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11099. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11100. order.OwnpayAmt = ""
  11101. order.SelfpayAmt = ""
  11102. order.Spec = subItem.GoodInfo.SpecificationName
  11103. order.SpecUnt = subItem.Unit
  11104. order.DrordBegnDate = s_tm
  11105. order.DrordStopDate = ""
  11106. order.DrordDrCodg = doctor_info.DoctorNumber
  11107. order.DrordDeptName = department.Name
  11108. order.DrordDeptCodg = department.Number
  11109. order.DrordDrName = doctor_info.UserName
  11110. order.DrordDrProfttl = "234"
  11111. order.CurrDrordFlag = "1"
  11112. orders = append(orders, &order)
  11113. }
  11114. }
  11115. }
  11116. //处方医嘱信息
  11117. fed.MatnStas = "0"
  11118. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11119. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11120. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11121. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11122. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11123. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11124. fed.SetlTotlnum = "1"
  11125. fed.Insutype = his.Insutype
  11126. fed.ReimFlag = "0"
  11127. fed.OutSetlFlag = "0"
  11128. var fopd []*models.FsiOperationDtosData
  11129. data := make(map[string]interface{})
  11130. data["fed"] = fed
  11131. data["fdd"] = fdds
  11132. data["fod"] = orders
  11133. data["pd"] = pd
  11134. data["pp"] = pp
  11135. data["fopd"] = fopd
  11136. data["trig_scen"] = trig_scen
  11137. client := &http.Client{}
  11138. bytesData, _ := json.Marshal(data)
  11139. var req *http.Request
  11140. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11141. if miConfig.MdtrtareaAdmvs == "320921" {
  11142. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11143. } else {
  11144. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11145. }
  11146. resp, _ := client.Do(req)
  11147. defer resp.Body.Close()
  11148. body, ioErr := ioutil.ReadAll(resp.Body)
  11149. if ioErr != nil {
  11150. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11152. return res
  11153. }
  11154. var respJSON map[string]interface{}
  11155. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11156. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11158. return res
  11159. }
  11160. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11161. result, _ := json.Marshal(respJSON)
  11162. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11163. utils.ErrorLog("解析失败:%v", err)
  11164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11165. return res
  11166. }
  11167. return res
  11168. } else {
  11169. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11170. saveLog(output, input, "3102", "事中")
  11171. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11172. utils.ErrorLog("解析失败:%v", err)
  11173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11174. return
  11175. }
  11176. return res
  11177. }
  11178. return res
  11179. }
  11180. func (c *HisApiController) Check() {
  11181. psn_no := c.GetString("psn_no")
  11182. in := c.GetString("in")
  11183. mt := c.GetString("mt")
  11184. baseParams := models.BaseParams{
  11185. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  11186. FixmedinsCode: "H15049901371",
  11187. InsuplcAdmdvs: "150499",
  11188. MdtrtareaAdmvs: "150499",
  11189. OrgName: "赤峰费森血液透析中心",
  11190. Doctor: "1111",
  11191. }
  11192. service.Gdyb2001(baseParams, psn_no, in, mt)
  11193. }
  11194. func (c *HisApiController) GetPsnNcdsInfo() {
  11195. admin_user_id, _ := c.GetInt64("admin_user_id")
  11196. patient_id, _ := c.GetInt64("patient_id")
  11197. //id, _ := c.GetInt64("id")
  11198. adminUser := c.GetAdminUserInfo()
  11199. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11200. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11201. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  11202. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11203. //psn_record, _ := service.GetP(id)
  11204. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11205. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  11206. //
  11207. //if psn_record.ID == 0 {
  11208. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  11209. // return
  11210. //}
  11211. var res Result5301
  11212. var res10265 Result5301For10265
  11213. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11214. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11215. var api string
  11216. if miConfig.MdtrtareaAdmvs == "320921" {
  11217. 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 +
  11218. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11219. } else {
  11220. 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 +
  11221. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11222. }
  11223. resp, requestErr := http.Get(api)
  11224. if requestErr != nil {
  11225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11226. return
  11227. }
  11228. body, ioErr := ioutil.ReadAll(resp.Body)
  11229. if ioErr != nil {
  11230. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11232. return
  11233. }
  11234. var respJSON map[string]interface{}
  11235. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11236. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11238. return
  11239. }
  11240. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11241. result, _ := json.Marshal(respJSON)
  11242. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11243. utils.ErrorLog("解析失败:%v", err)
  11244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11245. return
  11246. }
  11247. res.ErrMsg = res10265.ErrMsg
  11248. res.Output = res10265.Output
  11249. res.InfRefmsgid = res10265.InfRefmsgid
  11250. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11251. res.Infcode = infocode
  11252. } else if miConfig.MdtrtareaAdmvs == "341203" {
  11253. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11254. var api string
  11255. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  11256. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  11257. resp, requestErr := http.Get(api)
  11258. if requestErr != nil {
  11259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11260. return
  11261. }
  11262. body, ioErr := ioutil.ReadAll(resp.Body)
  11263. if ioErr != nil {
  11264. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11266. return
  11267. }
  11268. var respJSON map[string]interface{}
  11269. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11270. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11272. return
  11273. }
  11274. status := respJSON["data"].(map[string]interface{})["status"].(string)
  11275. if status == "0" {
  11276. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  11277. c.ServeSuccessJSON(map[string]interface{}{
  11278. "failed_code": -10,
  11279. "msg": err_msg,
  11280. })
  11281. return
  11282. }
  11283. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11284. result, _ := json.Marshal(respJSON)
  11285. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11286. utils.ErrorLog("解析失败:%v", err)
  11287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11288. return
  11289. }
  11290. } else if miConfig.MdtrtareaAdmvs == "360302" {
  11291. p, _ := service.GetHisPatientById(patient_id)
  11292. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  11293. var dat map[string]interface{}
  11294. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11295. fmt.Println(dat)
  11296. } else {
  11297. fmt.Println(err)
  11298. }
  11299. userJSONBytes, _ := json.Marshal(dat)
  11300. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11301. utils.ErrorLog("解析失败:%v", err)
  11302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11303. return
  11304. }
  11305. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11306. p, _ := service.GetHisPatientById(patient_id)
  11307. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  11308. var dat map[string]interface{}
  11309. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11310. fmt.Println(dat)
  11311. } else {
  11312. fmt.Println(err)
  11313. }
  11314. userJSONBytes, _ := json.Marshal(dat)
  11315. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11316. utils.ErrorLog("解析失败:%v", err)
  11317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11318. return
  11319. }
  11320. } else if miConfig.MdtrtareaAdmvs == "420200" {
  11321. p, _ := service.GetHisPatientById(patient_id)
  11322. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  11323. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11324. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11325. resp, requestErr := http.Get(api)
  11326. if requestErr != nil {
  11327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11328. return
  11329. }
  11330. body, ioErr := ioutil.ReadAll(resp.Body)
  11331. if ioErr != nil {
  11332. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11334. return
  11335. }
  11336. var respJSON map[string]interface{}
  11337. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11338. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11340. return
  11341. }
  11342. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11343. result, _ := json.Marshal(respJSON)
  11344. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11345. utils.ErrorLog("解析失败:%v", err)
  11346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11347. return
  11348. }
  11349. } else if miConfig.MdtrtareaAdmvs == "420902" {
  11350. p, _ := service.GetHisPatientById(patient_id)
  11351. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  11352. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11353. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11354. resp, requestErr := http.Get(api)
  11355. if requestErr != nil {
  11356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11357. return
  11358. }
  11359. body, ioErr := ioutil.ReadAll(resp.Body)
  11360. if ioErr != nil {
  11361. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11363. return
  11364. }
  11365. var respJSON map[string]interface{}
  11366. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11369. return
  11370. }
  11371. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11372. result, _ := json.Marshal(respJSON)
  11373. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11374. utils.ErrorLog("解析失败:%v", err)
  11375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11376. return
  11377. }
  11378. } else if miConfig.MdtrtareaAdmvs == "421182" {
  11379. p, _ := service.GetHisPatientById(patient_id)
  11380. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  11381. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11382. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11383. resp, requestErr := http.Get(api)
  11384. if requestErr != nil {
  11385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11386. return
  11387. }
  11388. body, ioErr := ioutil.ReadAll(resp.Body)
  11389. if ioErr != nil {
  11390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11392. return
  11393. }
  11394. var respJSON map[string]interface{}
  11395. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11398. return
  11399. }
  11400. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11401. result, _ := json.Marshal(respJSON)
  11402. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11403. utils.ErrorLog("解析失败:%v", err)
  11404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11405. return
  11406. }
  11407. } else if miConfig.MdtrtareaAdmvs == "420902" {
  11408. p, _ := service.GetHisPatientById(patient_id)
  11409. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  11410. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11411. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11412. resp, requestErr := http.Get(api)
  11413. if requestErr != nil {
  11414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11415. return
  11416. }
  11417. body, ioErr := ioutil.ReadAll(resp.Body)
  11418. if ioErr != nil {
  11419. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11421. return
  11422. }
  11423. var respJSON map[string]interface{}
  11424. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11425. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11427. return
  11428. }
  11429. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11430. result, _ := json.Marshal(respJSON)
  11431. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11432. utils.ErrorLog("解析失败:%v", err)
  11433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11434. return
  11435. }
  11436. } else if miConfig.MdtrtareaAdmvs == "421300" {
  11437. p, _ := service.GetHisPatientById(patient_id)
  11438. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  11439. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11440. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11441. resp, requestErr := http.Get(api)
  11442. if requestErr != nil {
  11443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11444. return
  11445. }
  11446. body, ioErr := ioutil.ReadAll(resp.Body)
  11447. if ioErr != nil {
  11448. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11450. return
  11451. }
  11452. var respJSON map[string]interface{}
  11453. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11454. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11456. return
  11457. }
  11458. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11459. result, _ := json.Marshal(respJSON)
  11460. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11461. utils.ErrorLog("解析失败:%v", err)
  11462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11463. return
  11464. }
  11465. } else if miConfig.MdtrtareaAdmvs == "441799" {
  11466. p, _ := service.GetHisPatientById(patient_id)
  11467. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  11468. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  11469. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11470. resp, requestErr := http.Get(api)
  11471. if requestErr != nil {
  11472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11473. return
  11474. }
  11475. body, ioErr := ioutil.ReadAll(resp.Body)
  11476. if ioErr != nil {
  11477. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11479. return
  11480. }
  11481. var respJSON map[string]interface{}
  11482. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11483. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11485. return
  11486. }
  11487. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11488. result, _ := json.Marshal(respJSON)
  11489. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11490. utils.ErrorLog("解析失败:%v", err)
  11491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11492. return
  11493. }
  11494. } else {
  11495. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  11496. var dat map[string]interface{}
  11497. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11498. fmt.Println(dat)
  11499. } else {
  11500. fmt.Println(err)
  11501. }
  11502. userJSONBytes, _ := json.Marshal(dat)
  11503. if miConfig.Code == "H15049901371" {
  11504. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  11505. utils.ErrorLog("解析失败:%v", err)
  11506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11507. return
  11508. }
  11509. res.InfRefmsgid = res10265.InfRefmsgid
  11510. res.Output = res10265.Output
  11511. res.ErrMsg = res10265.ErrMsg
  11512. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11513. res.Infcode = infocode
  11514. } else {
  11515. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11516. utils.ErrorLog("解析失败:%v", err)
  11517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11518. return
  11519. }
  11520. }
  11521. }
  11522. if res.Infcode == 0 {
  11523. c.ServeSuccessJSON(map[string]interface{}{
  11524. "result": res.Output.Result,
  11525. })
  11526. }
  11527. }
  11528. func (c *HisApiController) CheckInsutype() {
  11529. his_patient_id, _ := c.GetInt64("his_patient_id")
  11530. admin_user_id, _ := c.GetInt64("admin_user_id")
  11531. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11532. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11533. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11534. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  11535. var dat map[string]interface{}
  11536. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11537. fmt.Println(dat)
  11538. } else {
  11539. fmt.Println(err)
  11540. }
  11541. userJSONBytes, _ := json.Marshal(dat)
  11542. var res Result90100
  11543. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11544. utils.ErrorLog("解析失败:%v", err)
  11545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11546. return
  11547. }
  11548. if res.Infcode != 0 {
  11549. c.ServeSuccessJSON(map[string]interface{}{
  11550. "failed_code": -10,
  11551. "msg": res.ErrMsg,
  11552. })
  11553. return
  11554. } else {
  11555. fmt.Println(res)
  11556. }
  11557. }
  11558. func (c *HisApiController) CheckCardPWD() {
  11559. card_pwd := c.GetString("card_pwd")
  11560. his_patient_id, _ := c.GetInt64("his_patient_id")
  11561. admin_user_id, _ := c.GetInt64("admin_user_id")
  11562. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11563. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11564. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11565. psn, _ := service.GetPsnByPatientId(his.PatientId)
  11566. bas := strings.Split(psn.CardInfo, "|")
  11567. basNumber := bas[2]
  11568. if psn.InsuplcAdmdvs[:4] == "4403" {
  11569. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  11570. var dat map[string]interface{}
  11571. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11572. fmt.Println(dat)
  11573. } else {
  11574. fmt.Println(err)
  11575. }
  11576. userJSONBytes, _ := json.Marshal(dat)
  11577. var res Result90991
  11578. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11579. utils.ErrorLog("解析失败:%v", err)
  11580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11581. return
  11582. }
  11583. if res.Infcode != 0 {
  11584. c.ServeSuccessJSON(map[string]interface{}{
  11585. "failed_code": -10,
  11586. "msg": res.ErrMsg,
  11587. })
  11588. return
  11589. } else {
  11590. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  11591. var msg string
  11592. switch res.Output.Result.CardStat {
  11593. case "00":
  11594. msg = "未激活"
  11595. break
  11596. case "10":
  11597. msg = "激活"
  11598. break
  11599. case "20":
  11600. msg = "窗口挂失"
  11601. break
  11602. case "21":
  11603. msg = "电话挂失"
  11604. break
  11605. case "22":
  11606. msg = "单位网上申报挂失"
  11607. break
  11608. case "23":
  11609. msg = "保健办挂失"
  11610. break
  11611. case "24":
  11612. msg = "个人网上挂失"
  11613. break
  11614. case "25":
  11615. msg = "网上服务大厅挂失"
  11616. break
  11617. case "30":
  11618. msg = "注销"
  11619. break
  11620. case "40":
  11621. msg = "回收"
  11622. break
  11623. case "99":
  11624. msg = "制卡中(无效卡)"
  11625. break
  11626. }
  11627. c.ServeSuccessJSON(map[string]interface{}{
  11628. "failed_code": -10,
  11629. "msg": msg,
  11630. })
  11631. return
  11632. } else {
  11633. c.ServeSuccessJSON(map[string]interface{}{
  11634. "msg": "校验成功",
  11635. })
  11636. return
  11637. }
  11638. }
  11639. } else {
  11640. c.ServeSuccessJSON(map[string]interface{}{
  11641. "msg": "校验成功",
  11642. })
  11643. return
  11644. }
  11645. }
  11646. func (c *HisApiController) CheckCardPWDTwo() {
  11647. //card_pwd := c.GetString("card_pwd")
  11648. //his_patient_id, _ := c.GetInt64("his_patient_id")
  11649. admin_user_id, _ := c.GetInt64("admin_user_id")
  11650. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11651. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11652. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  11653. var dat map[string]interface{}
  11654. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11655. fmt.Println(dat)
  11656. } else {
  11657. fmt.Println(err)
  11658. }
  11659. userJSONBytes, _ := json.Marshal(dat)
  11660. var res Result90991
  11661. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11662. utils.ErrorLog("解析失败:%v", err)
  11663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11664. return
  11665. }
  11666. if res.Infcode != 0 {
  11667. c.ServeSuccessJSON(map[string]interface{}{
  11668. "failed_code": -10,
  11669. "msg": res.ErrMsg,
  11670. })
  11671. return
  11672. } else {
  11673. if res.Output.Result.SscnoCheckStat == "0" {
  11674. var msg string
  11675. switch res.Output.Result.CardStat {
  11676. case "00":
  11677. msg = "未激活"
  11678. break
  11679. case "10":
  11680. msg = "激活"
  11681. break
  11682. case "20":
  11683. msg = "窗口挂失"
  11684. break
  11685. case "21":
  11686. msg = "电话挂失"
  11687. break
  11688. case "22":
  11689. msg = "单位网上申报挂失"
  11690. break
  11691. case "23":
  11692. msg = "保健办挂失"
  11693. break
  11694. case "24":
  11695. msg = "个人网上挂失"
  11696. break
  11697. case "25":
  11698. msg = "网上服务大厅挂失"
  11699. break
  11700. case "30":
  11701. msg = "注销"
  11702. break
  11703. case "40":
  11704. msg = "回收"
  11705. break
  11706. case "99":
  11707. msg = "制卡中(无效卡)"
  11708. break
  11709. }
  11710. c.ServeSuccessJSON(map[string]interface{}{
  11711. "failed_code": -10,
  11712. "msg": msg,
  11713. })
  11714. return
  11715. } else {
  11716. c.ServeSuccessJSON(map[string]interface{}{
  11717. "msg": "校验成功",
  11718. })
  11719. return
  11720. }
  11721. }
  11722. }
  11723. type ELeCertData struct {
  11724. Data struct {
  11725. Extra string `json:"extra"`
  11726. IDNo string `json:"idNo"`
  11727. IDType string `json:"idType"`
  11728. EcToken string `json:"ecToken"`
  11729. InsuOrg string `json:"insuOrg"`
  11730. UserName string `json:"userName"`
  11731. EcIndexNo string `json:"ecIndexNo"`
  11732. Gender string `json:"gender"`
  11733. Birthday string `json:"birthday"`
  11734. Nationality string `json:"nationality"`
  11735. Email string `json:"email"`
  11736. } `json:"OutData"`
  11737. }
  11738. func (c *HisApiController) ReadCard() {
  11739. id_card_type, _ := c.GetInt64("id_card_type")
  11740. admin_user_id, _ := c.GetInt64("admin_user_id")
  11741. certificates, _ := c.GetInt64("certificates")
  11742. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  11743. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11744. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11745. switch id_card_type {
  11746. case 1:
  11747. if miConfig.MdtrtareaAdmvs == "421300" {
  11748. var res ResultTwo
  11749. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  11750. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11751. "&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)
  11752. resp, requestErr := http.Get(api)
  11753. if requestErr != nil {
  11754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11755. return
  11756. }
  11757. body, ioErr := ioutil.ReadAll(resp.Body)
  11758. if ioErr != nil {
  11759. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11761. return
  11762. }
  11763. var respJSON map[string]interface{}
  11764. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11765. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11767. return
  11768. }
  11769. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11770. result, _ := json.Marshal(respJSON)
  11771. fmt.Println("log")
  11772. fmt.Println(string(result))
  11773. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11774. utils.ErrorLog("解析失败:%v", err)
  11775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11776. return
  11777. }
  11778. if res.Infcode == 0 {
  11779. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11780. if err == gorm.ErrRecordNotFound {
  11781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11782. return
  11783. } else if err != nil {
  11784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11785. return
  11786. } else {
  11787. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11788. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11789. infoStr := string(Iinfos)
  11790. idetinfoStr := string(Idetinfos)
  11791. var rf []*ResultFive
  11792. json.Unmarshal([]byte(infoStr), &rf)
  11793. var insutypes []*ResultFive
  11794. var insutype string
  11795. var is390 int = 0
  11796. var is310 int = 0
  11797. for _, item := range rf {
  11798. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  11799. insutypes = append(insutypes, item)
  11800. }
  11801. }
  11802. if len(insutypes) == 1 {
  11803. insutype = insutypes[0].Insutype
  11804. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11805. } else {
  11806. for _, i := range insutypes {
  11807. if i.Insutype == "390" {
  11808. is390 = 1
  11809. }
  11810. if i.Insutype == "310" {
  11811. is310 = 1
  11812. }
  11813. }
  11814. }
  11815. if is390 == 1 {
  11816. insutype = "390"
  11817. }
  11818. if is310 == 1 {
  11819. insutype = "310"
  11820. }
  11821. if len(insutypes) == 0 {
  11822. insutype = "390"
  11823. }
  11824. var insuplc_admdvs string
  11825. for _, item := range rf {
  11826. if item.Insutype == insutype {
  11827. insuplc_admdvs = item.InsuplcAdmdvs
  11828. }
  11829. }
  11830. if strings.Contains(insuplc_admdvs, "4213") {
  11831. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  11832. }
  11833. psn := &models.HisPsn{
  11834. PsnNo: res.Output.Baseinfo.PsnNo,
  11835. PatientId: patient.ID,
  11836. Certno: res.Output.Baseinfo.Certno,
  11837. Gend: res.Output.Baseinfo.Gend,
  11838. Naty: res.Output.Baseinfo.Naty,
  11839. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11840. PsnName: res.Output.Baseinfo.PsnName,
  11841. Idetinfo: idetinfoStr,
  11842. Insuinfo: infoStr,
  11843. InsuplcAdmdvs: insuplc_admdvs,
  11844. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11845. }
  11846. service.CreateHisPsn(psn)
  11847. c.ServeSuccessJSON(map[string]interface{}{
  11848. "patient": patient,
  11849. "number": res.Output.Baseinfo.Certno,
  11850. })
  11851. }
  11852. } else {
  11853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11854. return
  11855. }
  11856. } else if miConfig.MdtrtareaAdmvs == "420200" {
  11857. var res ResultTwo
  11858. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  11859. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11860. "&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)
  11861. resp, requestErr := http.Get(api)
  11862. if requestErr != nil {
  11863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11864. return
  11865. }
  11866. body, ioErr := ioutil.ReadAll(resp.Body)
  11867. if ioErr != nil {
  11868. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11870. return
  11871. }
  11872. var respJSON map[string]interface{}
  11873. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11874. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11876. return
  11877. }
  11878. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11879. result, _ := json.Marshal(respJSON)
  11880. fmt.Println("log")
  11881. fmt.Println(string(result))
  11882. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11883. utils.ErrorLog("解析失败:%v", err)
  11884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11885. return
  11886. }
  11887. if res.Infcode == 0 {
  11888. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11889. if err == gorm.ErrRecordNotFound {
  11890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11891. return
  11892. } else if err != nil {
  11893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11894. return
  11895. } else {
  11896. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11897. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11898. infoStr := string(Iinfos)
  11899. idetinfoStr := string(Idetinfos)
  11900. psn := &models.HisPsn{
  11901. PsnNo: res.Output.Baseinfo.PsnNo,
  11902. PatientId: patient.ID,
  11903. Certno: res.Output.Baseinfo.Certno,
  11904. Gend: res.Output.Baseinfo.Gend,
  11905. Naty: res.Output.Baseinfo.Naty,
  11906. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11907. PsnName: res.Output.Baseinfo.PsnName,
  11908. Idetinfo: idetinfoStr,
  11909. Insuinfo: infoStr,
  11910. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11911. }
  11912. service.CreateHisPsn(psn)
  11913. var rf []*ResultFive
  11914. json.Unmarshal([]byte(infoStr), &rf)
  11915. var insutypes []*ResultFive
  11916. var insutype string
  11917. var is390 int = 0
  11918. var is310 int = 0
  11919. for _, item := range rf {
  11920. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11921. insutypes = append(insutypes, item)
  11922. }
  11923. }
  11924. if len(insutypes) == 1 {
  11925. insutype = insutypes[0].Insutype
  11926. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11927. } else {
  11928. for _, i := range insutypes {
  11929. if i.Insutype == "390" {
  11930. is390 = 1
  11931. }
  11932. if i.Insutype == "310" {
  11933. is310 = 1
  11934. }
  11935. }
  11936. }
  11937. if is390 == 1 {
  11938. insutype = "390"
  11939. }
  11940. if is310 == 1 {
  11941. insutype = "310"
  11942. }
  11943. if len(insutypes) == 0 {
  11944. insutype = "310"
  11945. }
  11946. c.ServeSuccessJSON(map[string]interface{}{
  11947. "patient": patient,
  11948. "number": res.Output.Baseinfo.Certno,
  11949. "insutype": insutype,
  11950. })
  11951. }
  11952. } else {
  11953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11954. return
  11955. }
  11956. } else if miConfig.MdtrtareaAdmvs == "420902" {
  11957. var res ResultTwo
  11958. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  11959. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11960. "&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)
  11961. resp, requestErr := http.Get(api)
  11962. if requestErr != nil {
  11963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11964. return
  11965. }
  11966. body, ioErr := ioutil.ReadAll(resp.Body)
  11967. if ioErr != nil {
  11968. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11970. return
  11971. }
  11972. var respJSON map[string]interface{}
  11973. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11974. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11976. return
  11977. }
  11978. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11979. result, _ := json.Marshal(respJSON)
  11980. fmt.Println("log")
  11981. fmt.Println(string(result))
  11982. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11983. utils.ErrorLog("解析失败:%v", err)
  11984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11985. return
  11986. }
  11987. if res.Infcode == 0 {
  11988. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11989. if err == gorm.ErrRecordNotFound {
  11990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11991. return
  11992. } else if err != nil {
  11993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11994. return
  11995. } else {
  11996. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11997. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11998. infoStr := string(Iinfos)
  11999. idetinfoStr := string(Idetinfos)
  12000. var rf []*ResultFive
  12001. json.Unmarshal([]byte(infoStr), &rf)
  12002. var insutypes []*ResultFive
  12003. var insutype string
  12004. var is390 int = 0
  12005. var is310 int = 0
  12006. for _, item := range rf {
  12007. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12008. insutypes = append(insutypes, item)
  12009. }
  12010. }
  12011. if len(insutypes) == 1 {
  12012. insutype = insutypes[0].Insutype
  12013. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12014. } else {
  12015. for _, i := range insutypes {
  12016. if i.Insutype == "390" {
  12017. is390 = 1
  12018. }
  12019. if i.Insutype == "310" {
  12020. is310 = 1
  12021. }
  12022. }
  12023. }
  12024. if is390 == 1 {
  12025. insutype = "390"
  12026. }
  12027. if is310 == 1 {
  12028. insutype = "310"
  12029. }
  12030. if len(insutypes) == 0 {
  12031. insutype = "390"
  12032. }
  12033. var insuplc_admdvs string
  12034. for _, item := range rf {
  12035. if item.Insutype == insutype {
  12036. insuplc_admdvs = item.InsuplcAdmdvs
  12037. }
  12038. }
  12039. psn := &models.HisPsn{
  12040. PsnNo: res.Output.Baseinfo.PsnNo,
  12041. PatientId: patient.ID,
  12042. Certno: res.Output.Baseinfo.Certno,
  12043. Gend: res.Output.Baseinfo.Gend,
  12044. Naty: res.Output.Baseinfo.Naty,
  12045. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12046. PsnName: res.Output.Baseinfo.PsnName,
  12047. Idetinfo: idetinfoStr,
  12048. Insuinfo: infoStr,
  12049. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12050. InsuplcAdmdvs: insuplc_admdvs,
  12051. }
  12052. service.CreateHisPsn(psn)
  12053. for _, item := range rf {
  12054. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12055. insutypes = append(insutypes, item)
  12056. }
  12057. }
  12058. if len(insutypes) == 1 {
  12059. insutype = insutypes[0].Insutype
  12060. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12061. } else {
  12062. for _, i := range insutypes {
  12063. if i.Insutype == "390" {
  12064. is390 = 1
  12065. }
  12066. if i.Insutype == "310" {
  12067. is310 = 1
  12068. }
  12069. }
  12070. }
  12071. if is390 == 1 {
  12072. insutype = "390"
  12073. }
  12074. if is310 == 1 {
  12075. insutype = "310"
  12076. }
  12077. if len(insutypes) == 0 {
  12078. insutype = "310"
  12079. }
  12080. c.ServeSuccessJSON(map[string]interface{}{
  12081. "patient": patient,
  12082. "number": res.Output.Baseinfo.Certno,
  12083. "insutype": insutype,
  12084. })
  12085. }
  12086. } else {
  12087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12088. return
  12089. }
  12090. } else if miConfig.MdtrtareaAdmvs == "421182" {
  12091. var res ResultTwo
  12092. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  12093. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12094. "&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)
  12095. resp, requestErr := http.Get(api)
  12096. if requestErr != nil {
  12097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12098. return
  12099. }
  12100. body, ioErr := ioutil.ReadAll(resp.Body)
  12101. if ioErr != nil {
  12102. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12104. return
  12105. }
  12106. var respJSON map[string]interface{}
  12107. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12108. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12110. return
  12111. }
  12112. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12113. result, _ := json.Marshal(respJSON)
  12114. fmt.Println("log")
  12115. fmt.Println(string(result))
  12116. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12117. utils.ErrorLog("解析失败:%v", err)
  12118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12119. return
  12120. }
  12121. if res.Infcode == 0 {
  12122. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12123. if err == gorm.ErrRecordNotFound {
  12124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12125. return
  12126. } else if err != nil {
  12127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12128. return
  12129. } else {
  12130. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12131. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12132. infoStr := string(Iinfos)
  12133. idetinfoStr := string(Idetinfos)
  12134. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  12135. psn := &models.HisPsn{
  12136. PsnNo: res.Output.Baseinfo.PsnNo,
  12137. PatientId: patient.ID,
  12138. Certno: res.Output.Baseinfo.Certno,
  12139. Brdy: b,
  12140. Age: float64(age),
  12141. Gend: res.Output.Baseinfo.Gend,
  12142. Naty: res.Output.Baseinfo.Naty,
  12143. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12144. PsnName: res.Output.Baseinfo.PsnName,
  12145. Idetinfo: idetinfoStr,
  12146. Insuinfo: infoStr,
  12147. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12148. }
  12149. service.CreateHisPsn(psn)
  12150. var rf []*ResultFive
  12151. json.Unmarshal([]byte(infoStr), &rf)
  12152. var insutypes []*ResultFive
  12153. var insutype string
  12154. var is390 int = 0
  12155. var is310 int = 0
  12156. for _, item := range rf {
  12157. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12158. insutypes = append(insutypes, item)
  12159. }
  12160. }
  12161. if len(insutypes) == 1 {
  12162. insutype = insutypes[0].Insutype
  12163. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12164. } else {
  12165. for _, i := range insutypes {
  12166. if i.Insutype == "390" {
  12167. is390 = 1
  12168. }
  12169. if i.Insutype == "310" {
  12170. is310 = 1
  12171. }
  12172. }
  12173. }
  12174. if is390 == 1 {
  12175. insutype = "390"
  12176. }
  12177. if is310 == 1 {
  12178. insutype = "310"
  12179. }
  12180. if len(insutypes) == 0 {
  12181. insutype = "310"
  12182. }
  12183. c.ServeSuccessJSON(map[string]interface{}{
  12184. "patient": patient,
  12185. "number": res.Output.Baseinfo.Certno,
  12186. "insutype": insutype,
  12187. })
  12188. }
  12189. } else {
  12190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12191. return
  12192. }
  12193. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12194. var api string
  12195. if miConfig.MdtrtareaAdmvs == "320921" {
  12196. 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 +
  12197. "&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
  12198. fmt.Println(api)
  12199. } else {
  12200. 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 +
  12201. "&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)
  12202. }
  12203. resp, requestErr := http.Get(api)
  12204. if requestErr != nil {
  12205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12206. return
  12207. }
  12208. body, ioErr := ioutil.ReadAll(resp.Body)
  12209. if ioErr != nil {
  12210. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12212. return
  12213. }
  12214. var respJSON map[string]interface{}
  12215. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12218. return
  12219. }
  12220. var status string
  12221. status = respJSON["data"].(map[string]interface{})["status"].(string)
  12222. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  12223. //console.log()
  12224. fmt.Println("type===")
  12225. fmt.Println(card_type)
  12226. var token string
  12227. var res ResultTwo //1101结果
  12228. var res10265 ResultTwo10265 //1101结果
  12229. var card_info string //卡信息
  12230. var busi_card_info string
  12231. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  12232. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  12233. if status == "0" { //读卡成功
  12234. if card_type == "1" {
  12235. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12236. result, _ := json.Marshal(respJSON)
  12237. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12238. utils.ErrorLog("解析失败:%v", err)
  12239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12240. return
  12241. }
  12242. res.ErrMsg = res10265.ErrMsg
  12243. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12244. res.Infcode = infocode
  12245. res.Output = res10265.Output
  12246. res.InfRefmsgid = res10265.InfRefmsgid
  12247. } else {
  12248. //var card_info string //卡信息
  12249. //var busi_card_info string
  12250. token = respJSON["data"].(map[string]interface{})["token"].(string)
  12251. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  12252. //fmt.Println(card_info)
  12253. //fmt.Println(busi_card_info)
  12254. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12255. result, _ := json.Marshal(respJSON)
  12256. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12257. utils.ErrorLog("解析失败:%v", err)
  12258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12259. return
  12260. }
  12261. res.ErrMsg = res10265.ErrMsg
  12262. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12263. res.Infcode = infocode
  12264. res.Output = res10265.Output
  12265. res.InfRefmsgid = res10265.InfRefmsgid
  12266. }
  12267. if res.Infcode == 0 {
  12268. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12269. if err == gorm.ErrRecordNotFound {
  12270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12271. return
  12272. } else if err != nil {
  12273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12274. return
  12275. } else {
  12276. if card_type == "1" {
  12277. bas := strings.Split(card_info, "|")
  12278. basNumber := bas[2]
  12279. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12280. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12281. infoStr := string(Iinfos)
  12282. idetinfoStr := string(Idetinfos)
  12283. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  12284. psn := &models.HisPsn{
  12285. PsnNo: res.Output.Baseinfo.PsnNo,
  12286. PatientId: patient.ID,
  12287. Certno: res.Output.Baseinfo.Certno,
  12288. Brdy: b,
  12289. Age: float64(age),
  12290. Gend: res.Output.Baseinfo.Gend,
  12291. Naty: res.Output.Baseinfo.Naty,
  12292. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12293. PsnName: res.Output.Baseinfo.PsnName,
  12294. Idetinfo: idetinfoStr,
  12295. Insuinfo: infoStr,
  12296. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12297. CardInfo: card_info,
  12298. VerifyNumber: busi_card_info,
  12299. }
  12300. service.CreateHisPsn(psn)
  12301. var rf []*ResultFive
  12302. json.Unmarshal([]byte(infoStr), &rf)
  12303. var insutypes []*ResultFive
  12304. var insutype string
  12305. var is390 int = 0
  12306. var is310 int = 0
  12307. for _, item := range rf {
  12308. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12309. insutypes = append(insutypes, item)
  12310. }
  12311. }
  12312. if len(insutypes) == 1 {
  12313. insutype = insutypes[0].Insutype
  12314. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12315. } else {
  12316. for _, i := range insutypes {
  12317. if i.Insutype == "390" {
  12318. is390 = 1
  12319. }
  12320. if i.Insutype == "310" {
  12321. is310 = 1
  12322. }
  12323. }
  12324. }
  12325. if is390 == 1 {
  12326. insutype = "390"
  12327. }
  12328. if is310 == 1 {
  12329. insutype = "310"
  12330. }
  12331. if len(insutypes) == 0 {
  12332. insutype = "310"
  12333. }
  12334. c.ServeSuccessJSON(map[string]interface{}{
  12335. "patient": patient,
  12336. "number": basNumber,
  12337. "insutype": insutype,
  12338. })
  12339. } else {
  12340. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12341. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12342. infoStr := string(Iinfos)
  12343. idetinfoStr := string(Idetinfos)
  12344. psn := &models.HisPsn{
  12345. PsnNo: res.Output.Baseinfo.PsnNo,
  12346. PatientId: patient.ID,
  12347. Certno: res.Output.Baseinfo.Certno,
  12348. Gend: res.Output.Baseinfo.Gend,
  12349. Naty: res.Output.Baseinfo.Naty,
  12350. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12351. PsnName: res.Output.Baseinfo.PsnName,
  12352. Idetinfo: idetinfoStr,
  12353. Insuinfo: infoStr,
  12354. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12355. CardInfo: card_info,
  12356. VerifyNumber: token,
  12357. }
  12358. service.CreateHisPsn(psn)
  12359. c.ServeSuccessJSON(map[string]interface{}{
  12360. "patient": patient,
  12361. "number": token,
  12362. })
  12363. }
  12364. }
  12365. } else {
  12366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12367. return
  12368. }
  12369. } else { //读卡失败
  12370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12371. return
  12372. }
  12373. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12374. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  12375. cardnum = DeleteExtraSpaceTwo(cardnum)
  12376. cardCode = DeleteExtraSpaceTwo(cardCode)
  12377. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  12378. name = DeleteExtraSpaceTwo(name)
  12379. errmsg = DeleteExtraSpaceTwo(errmsg)
  12380. cardnum = Remove0000(cardnum)
  12381. cardCode = Remove0000(cardCode)
  12382. id_card_no = Remove0000(id_card_no)
  12383. name = Remove0000(name)
  12384. errmsg = Remove0000(errmsg)
  12385. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  12386. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  12387. //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)
  12388. //fmt.Println(result2)
  12389. //fmt.Println(requestLog2)
  12390. //fmt.Println(errMsgLog2)
  12391. 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)
  12392. saveLog(result, requestLog, "1101", "获取人员信息")
  12393. fmt.Println(errMsgLog)
  12394. if len(errMsgLog) > 0 {
  12395. } else {
  12396. var dat map[string]interface{}
  12397. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12398. fmt.Println(dat)
  12399. } else {
  12400. fmt.Println(err)
  12401. }
  12402. userJSONBytes, _ := json.Marshal(dat)
  12403. var res ResultTwo
  12404. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12405. utils.ErrorLog("解析失败:%v", err)
  12406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12407. return
  12408. }
  12409. res.ErrMsg = errMsgLog
  12410. if res.Infcode == 0 {
  12411. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12412. if err == gorm.ErrRecordNotFound {
  12413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12414. return
  12415. } else if err != nil {
  12416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12417. return
  12418. } else {
  12419. fmt.Println(res)
  12420. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12421. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12422. infoStr := string(Iinfos)
  12423. idetinfoStr := string(Idetinfos)
  12424. var rf []*ResultFive
  12425. json.Unmarshal([]byte(infoStr), &rf)
  12426. var insutypes []*ResultFive
  12427. var insutype string
  12428. var is390 int = 0
  12429. var is310 int = 0
  12430. for _, item := range rf {
  12431. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  12432. insutypes = append(insutypes, item)
  12433. }
  12434. }
  12435. if len(insutypes) == 1 {
  12436. insutype = insutypes[0].Insutype
  12437. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12438. } else {
  12439. for _, i := range insutypes {
  12440. if i.Insutype == "390" {
  12441. is390 = 1
  12442. }
  12443. if i.Insutype == "310" {
  12444. is310 = 1
  12445. }
  12446. }
  12447. }
  12448. if is390 == 1 {
  12449. insutype = "390"
  12450. }
  12451. if is310 == 1 {
  12452. insutype = "310"
  12453. }
  12454. if len(insutypes) == 0 {
  12455. insutype = "390"
  12456. }
  12457. var insuplc_admdvs string
  12458. for _, item := range rf {
  12459. if item.Insutype == insutype {
  12460. insuplc_admdvs = item.InsuplcAdmdvs
  12461. }
  12462. }
  12463. psn := &models.HisPsn{
  12464. PsnNo: res.Output.Baseinfo.PsnNo,
  12465. PatientId: patient.ID,
  12466. Certno: res.Output.Baseinfo.Certno,
  12467. Gend: res.Output.Baseinfo.Gend,
  12468. Naty: res.Output.Baseinfo.Naty,
  12469. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12470. PsnName: res.Output.Baseinfo.PsnName,
  12471. Idetinfo: idetinfoStr,
  12472. Insuinfo: infoStr,
  12473. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12474. CardInfo: basStr,
  12475. VerifyNumber: "",
  12476. InsuplcAdmdvs: insuplc_admdvs,
  12477. }
  12478. service.CreateHisPsn(psn)
  12479. c.ServeSuccessJSON(map[string]interface{}{
  12480. "patient": patient,
  12481. "number": cardnum,
  12482. "insutype": insutype,
  12483. })
  12484. }
  12485. } else {
  12486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12487. return
  12488. }
  12489. }
  12490. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12491. fmt.Println(initFlag)
  12492. fmt.Println("initFlag")
  12493. if initFlag == 0 {
  12494. c.TestGetJiangXiBasBaseInit()
  12495. }
  12496. basStr := c.GetBasBaseInfo()
  12497. if len(basStr) == 0 {
  12498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  12499. return
  12500. }
  12501. fmt.Println(basStr)
  12502. bas := strings.Split(basStr, "|")
  12503. basNumber := bas[1]
  12504. fmt.Println(basNumber)
  12505. card_sn := bas[3]
  12506. fmt.Println(card_sn)
  12507. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  12508. 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)
  12509. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  12510. var dat map[string]interface{}
  12511. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12512. fmt.Println(dat)
  12513. } else {
  12514. fmt.Println(err)
  12515. }
  12516. userJSONBytes, _ := json.Marshal(dat)
  12517. var res ResultTwo
  12518. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12519. utils.ErrorLog("解析失败:%v", err)
  12520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12521. return
  12522. }
  12523. if res.Infcode == 0 {
  12524. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  12525. if err == gorm.ErrRecordNotFound {
  12526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12527. return
  12528. } else if err != nil {
  12529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12530. return
  12531. } else {
  12532. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12533. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12534. infoStr := string(Iinfos)
  12535. idetinfoStr := string(Idetinfos)
  12536. var rf []*ResultFive
  12537. json.Unmarshal([]byte(infoStr), &rf)
  12538. var insutypes []*ResultFive
  12539. var insutype string
  12540. var is390 int = 0
  12541. var is310 int = 0
  12542. var insuplc_admdvs string
  12543. for _, item := range rf {
  12544. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12545. insutypes = append(insutypes, item)
  12546. }
  12547. }
  12548. if len(insutypes) == 1 {
  12549. insutype = insutypes[0].Insutype
  12550. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12551. } else {
  12552. for _, i := range insutypes {
  12553. if i.Insutype == "390" {
  12554. is390 = 1
  12555. }
  12556. if i.Insutype == "310" {
  12557. is310 = 1
  12558. }
  12559. }
  12560. }
  12561. if is390 == 1 {
  12562. insutype = "390"
  12563. }
  12564. if is310 == 1 {
  12565. insutype = "310"
  12566. }
  12567. if len(insutypes) == 0 {
  12568. insutype = "310"
  12569. }
  12570. for _, item := range rf {
  12571. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  12572. insuplc_admdvs = item.InsuplcAdmdvs
  12573. }
  12574. }
  12575. psn := &models.HisPsn{
  12576. PsnNo: res.Output.Baseinfo.PsnNo,
  12577. PatientId: patient.ID,
  12578. Certno: res.Output.Baseinfo.Certno,
  12579. Gend: res.Output.Baseinfo.Gend,
  12580. Naty: res.Output.Baseinfo.Naty,
  12581. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12582. PsnName: res.Output.Baseinfo.PsnName,
  12583. Idetinfo: idetinfoStr,
  12584. Insuinfo: infoStr,
  12585. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12586. CardInfo: basStr,
  12587. InsuplcAdmdvs: insuplc_admdvs,
  12588. VerifyNumber: "",
  12589. }
  12590. service.CreateHisPsn(psn)
  12591. c.ServeSuccessJSON(map[string]interface{}{
  12592. "patient": patient,
  12593. "number": basNumber,
  12594. "insutype": insutype,
  12595. })
  12596. }
  12597. } else {
  12598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12599. return
  12600. }
  12601. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12602. fmt.Println(initFlag)
  12603. fmt.Println("initFlag")
  12604. if initFlag == 0 {
  12605. c.TestGetHnBasBaseInit()
  12606. }
  12607. basStr := c.GetBasBaseInfo()
  12608. if len(basStr) == 0 {
  12609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  12610. return
  12611. }
  12612. fmt.Println(basStr)
  12613. bas := strings.Split(basStr, "|")
  12614. basNumber := bas[1]
  12615. fmt.Println(basNumber)
  12616. card_sn := bas[3]
  12617. card_no := bas[2]
  12618. fmt.Println(card_sn)
  12619. name := bas[4]
  12620. name = ConvertToString(name, "gbk", "utf-8")
  12621. 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)
  12622. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  12623. var dat map[string]interface{}
  12624. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12625. fmt.Println(dat)
  12626. } else {
  12627. fmt.Println(err)
  12628. }
  12629. userJSONBytes, _ := json.Marshal(dat)
  12630. var res ResultTwo
  12631. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12632. utils.ErrorLog("解析失败:%v", err)
  12633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12634. return
  12635. }
  12636. if res.Infcode == 0 {
  12637. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  12638. if err == gorm.ErrRecordNotFound {
  12639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12640. return
  12641. } else if err != nil {
  12642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12643. return
  12644. } else {
  12645. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12646. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12647. infoStr := string(Iinfos)
  12648. idetinfoStr := string(Idetinfos)
  12649. psn := &models.HisPsn{
  12650. PsnNo: res.Output.Baseinfo.PsnNo,
  12651. PatientId: patient.ID,
  12652. Certno: res.Output.Baseinfo.Certno,
  12653. Gend: res.Output.Baseinfo.Gend,
  12654. Naty: res.Output.Baseinfo.Naty,
  12655. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12656. PsnName: res.Output.Baseinfo.PsnName,
  12657. Idetinfo: idetinfoStr,
  12658. Insuinfo: infoStr,
  12659. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12660. CardInfo: basStr,
  12661. VerifyNumber: "",
  12662. }
  12663. service.CreateHisPsn(psn)
  12664. var rf []*ResultFive
  12665. json.Unmarshal([]byte(infoStr), &rf)
  12666. var insutypes []*ResultFive
  12667. var insutype string
  12668. var is390 int = 0
  12669. var is310 int = 0
  12670. for _, item := range rf {
  12671. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12672. insutypes = append(insutypes, item)
  12673. }
  12674. }
  12675. if len(insutypes) == 1 {
  12676. insutype = insutypes[0].Insutype
  12677. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12678. } else {
  12679. for _, i := range insutypes {
  12680. if i.Insutype == "390" {
  12681. is390 = 1
  12682. }
  12683. if i.Insutype == "310" {
  12684. is310 = 1
  12685. }
  12686. }
  12687. }
  12688. if is390 == 1 {
  12689. insutype = "390"
  12690. }
  12691. if is310 == 1 {
  12692. insutype = "310"
  12693. }
  12694. if len(insutypes) == 0 {
  12695. insutype = "310"
  12696. }
  12697. c.ServeSuccessJSON(map[string]interface{}{
  12698. "patient": patient,
  12699. "number": basNumber,
  12700. "insutype": insutype,
  12701. })
  12702. }
  12703. } else {
  12704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12705. return
  12706. }
  12707. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12708. var api string
  12709. 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 +
  12710. "&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
  12711. fmt.Println(api)
  12712. resp, requestErr := http.Get(api)
  12713. if requestErr != nil {
  12714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12715. return
  12716. }
  12717. body, ioErr := ioutil.ReadAll(resp.Body)
  12718. if ioErr != nil {
  12719. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12721. return
  12722. }
  12723. var respJSON map[string]interface{}
  12724. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12725. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12727. return
  12728. }
  12729. var res ResultTwo //1101结果
  12730. var res10265 ResultTwo10265 //1101结果
  12731. var card_info string //卡信息
  12732. token := respJSON["data"].(map[string]interface{})["token"].(string)
  12733. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12734. result, _ := json.Marshal(respJSON)
  12735. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12736. utils.ErrorLog("解析失败:%v", err)
  12737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12738. return
  12739. }
  12740. res.ErrMsg = res10265.ErrMsg
  12741. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12742. res.Infcode = infocode
  12743. res.Output = res10265.Output
  12744. res.InfRefmsgid = res10265.InfRefmsgid
  12745. if res.Infcode == 0 {
  12746. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12747. if err == gorm.ErrRecordNotFound {
  12748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12749. return
  12750. } else if err != nil {
  12751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12752. return
  12753. } else {
  12754. bas := strings.Split(card_info, "|")
  12755. basNumber := bas[2]
  12756. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12757. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12758. infoStr := string(Iinfos)
  12759. idetinfoStr := string(Idetinfos)
  12760. psn := &models.HisPsn{
  12761. PsnNo: res.Output.Baseinfo.PsnNo,
  12762. PatientId: patient.ID,
  12763. Certno: res.Output.Baseinfo.Certno,
  12764. Gend: res.Output.Baseinfo.Gend,
  12765. Naty: res.Output.Baseinfo.Naty,
  12766. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12767. PsnName: res.Output.Baseinfo.PsnName,
  12768. Idetinfo: idetinfoStr,
  12769. Insuinfo: infoStr,
  12770. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12771. CardInfo: card_info,
  12772. VerifyNumber: token,
  12773. }
  12774. service.CreateHisPsn(psn)
  12775. var rf []*ResultFive
  12776. json.Unmarshal([]byte(infoStr), &rf)
  12777. var insutypes []*ResultFive
  12778. var insutype string
  12779. var is390 int = 0
  12780. var is310 int = 0
  12781. for _, item := range rf {
  12782. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12783. insutypes = append(insutypes, item)
  12784. }
  12785. }
  12786. if len(insutypes) == 1 {
  12787. insutype = insutypes[0].Insutype
  12788. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12789. } else {
  12790. for _, i := range insutypes {
  12791. if i.Insutype == "390" {
  12792. is390 = 1
  12793. }
  12794. if i.Insutype == "310" {
  12795. is310 = 1
  12796. }
  12797. }
  12798. }
  12799. if is390 == 1 {
  12800. insutype = "390"
  12801. }
  12802. if is310 == 1 {
  12803. insutype = "310"
  12804. }
  12805. if len(insutypes) == 0 {
  12806. insutype = "310"
  12807. }
  12808. c.ServeSuccessJSON(map[string]interface{}{
  12809. "patient": patient,
  12810. "number": basNumber,
  12811. "insutype": insutype,
  12812. })
  12813. }
  12814. } else {
  12815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12816. return
  12817. }
  12818. } else if miConfig.MdtrtareaAdmvs == "450721" {
  12819. res := c.GetoleInfo()
  12820. if res.Infcode == 0 {
  12821. var result string
  12822. if res.Output.MdtrtCertType == "01" {
  12823. 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)
  12824. } else if res.Output.MdtrtCertType == "02" {
  12825. 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)
  12826. } else if res.Output.MdtrtCertType == "03" {
  12827. 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)
  12828. }
  12829. var dat map[string]interface{}
  12830. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12831. fmt.Println(dat)
  12832. } else {
  12833. fmt.Println(err)
  12834. }
  12835. userJSONBytes, _ := json.Marshal(dat)
  12836. var res2 ResultTwo
  12837. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12838. utils.ErrorLog("解析失败:%v", err)
  12839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12840. return
  12841. }
  12842. if res2.Infcode == 0 {
  12843. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  12844. if err == gorm.ErrRecordNotFound {
  12845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12846. return
  12847. } else if err != nil {
  12848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12849. return
  12850. } else {
  12851. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  12852. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  12853. infoStr := string(Iinfos)
  12854. idetinfoStr := string(Idetinfos)
  12855. var rf []*ResultFive
  12856. json.Unmarshal([]byte(infoStr), &rf)
  12857. var insutypes []*ResultFive
  12858. var insutype string
  12859. var is390 int = 0
  12860. var is310 int = 0
  12861. //var insuplc_admdvs string
  12862. for _, item := range rf {
  12863. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12864. insutypes = append(insutypes, item)
  12865. }
  12866. }
  12867. if len(insutypes) == 1 {
  12868. insutype = insutypes[0].Insutype
  12869. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12870. } else {
  12871. for _, i := range insutypes {
  12872. if i.Insutype == "390" {
  12873. is390 = 1
  12874. }
  12875. if i.Insutype == "310" {
  12876. is310 = 1
  12877. }
  12878. }
  12879. }
  12880. if is390 == 1 {
  12881. insutype = "390"
  12882. }
  12883. if is310 == 1 {
  12884. insutype = "310"
  12885. }
  12886. if len(insutypes) == 0 {
  12887. insutype = "310"
  12888. }
  12889. psn := &models.HisPsn{
  12890. PsnNo: res2.Output.Baseinfo.PsnNo,
  12891. PatientId: patient.ID,
  12892. Certno: res2.Output.Baseinfo.Certno,
  12893. Gend: res2.Output.Baseinfo.Gend,
  12894. Naty: res2.Output.Baseinfo.Naty,
  12895. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  12896. PsnName: res2.Output.Baseinfo.PsnName,
  12897. Idetinfo: idetinfoStr,
  12898. Insuinfo: infoStr,
  12899. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12900. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  12901. VerifyNumber: res.Output.EcToken,
  12902. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  12903. }
  12904. if res.Output.MdtrtCertType == "01" {
  12905. psn.VerifyNumber = res.Output.EcToken
  12906. //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)
  12907. } else if res.Output.MdtrtCertType == "02" {
  12908. psn.VerifyNumber = res.Output.MdtrtCertNo
  12909. //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)
  12910. } else if res.Output.MdtrtCertType == "03" {
  12911. psn.VerifyNumber = res.Output.MdtrtCertNo
  12912. //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)
  12913. }
  12914. var balc float64
  12915. for _, item := range rf {
  12916. if item.Insutype == insutype {
  12917. balc = item.Balc
  12918. }
  12919. }
  12920. service.CreateHisPsn(psn)
  12921. c.ServeSuccessJSON(map[string]interface{}{
  12922. "patient": patient,
  12923. "number": res.Output.CardNo,
  12924. "insutype": insutype,
  12925. "blac": balc,
  12926. "desc": idetinfoStr,
  12927. })
  12928. }
  12929. } else {
  12930. c.ServeSuccessJSON(map[string]interface{}{
  12931. "failed_code": -10,
  12932. "msg": res2.ErrMsg,
  12933. })
  12934. }
  12935. } else {
  12936. c.ServeSuccessJSON(map[string]interface{}{
  12937. "failed_code": -10,
  12938. "msg": res.ErrMsg,
  12939. })
  12940. }
  12941. } else if miConfig.MdtrtareaAdmvs == "341203" {
  12942. var api string
  12943. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  12944. "&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
  12945. fmt.Println(api)
  12946. resp, requestErr := http.Get(api)
  12947. if requestErr != nil {
  12948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12949. return
  12950. }
  12951. body, ioErr := ioutil.ReadAll(resp.Body)
  12952. if ioErr != nil {
  12953. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12955. return
  12956. }
  12957. var respJSON map[string]interface{}
  12958. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12959. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12961. return
  12962. }
  12963. var status string
  12964. status = respJSON["data"].(map[string]interface{})["status"].(string)
  12965. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  12966. //console.log()
  12967. fmt.Println("type===")
  12968. fmt.Println(card_type)
  12969. var token string
  12970. var res ResultTwo //1101结果
  12971. //var res10265 ResultTwoesultTwo10265 //1101结果
  12972. var card_info string //卡信息
  12973. var busi_card_info string
  12974. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  12975. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  12976. if status == "0" { //读卡成功
  12977. if card_type == "1" {
  12978. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12979. result, _ := json.Marshal(respJSON)
  12980. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12981. utils.ErrorLog("解析失败:%v", err)
  12982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12983. return
  12984. }
  12985. } else {
  12986. token = respJSON["data"].(map[string]interface{})["token"].(string)
  12987. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12988. result, _ := json.Marshal(respJSON)
  12989. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12990. utils.ErrorLog("解析失败:%v", err)
  12991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12992. return
  12993. }
  12994. }
  12995. if res.Infcode == 0 {
  12996. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12997. if err == gorm.ErrRecordNotFound {
  12998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12999. return
  13000. } else if err != nil {
  13001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13002. return
  13003. } else {
  13004. if card_type == "1" {
  13005. bas := strings.Split(card_info, "|")
  13006. basNumber := bas[2]
  13007. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13008. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13009. infoStr := string(Iinfos)
  13010. idetinfoStr := string(Idetinfos)
  13011. psn := &models.HisPsn{
  13012. PsnNo: res.Output.Baseinfo.PsnNo,
  13013. PatientId: patient.ID,
  13014. Certno: res.Output.Baseinfo.Certno,
  13015. Gend: res.Output.Baseinfo.Gend,
  13016. Naty: res.Output.Baseinfo.Naty,
  13017. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13018. PsnName: res.Output.Baseinfo.PsnName,
  13019. Idetinfo: idetinfoStr,
  13020. Insuinfo: infoStr,
  13021. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13022. CardInfo: card_info,
  13023. VerifyNumber: busi_card_info,
  13024. }
  13025. service.CreateHisPsn(psn)
  13026. var rf []*ResultFive
  13027. json.Unmarshal([]byte(infoStr), &rf)
  13028. var insutypes []*ResultFive
  13029. var insutype string
  13030. var is390 int = 0
  13031. var is310 int = 0
  13032. for _, item := range rf {
  13033. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13034. insutypes = append(insutypes, item)
  13035. }
  13036. }
  13037. if len(insutypes) == 1 {
  13038. insutype = insutypes[0].Insutype
  13039. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13040. } else {
  13041. for _, i := range insutypes {
  13042. if i.Insutype == "390" {
  13043. is390 = 1
  13044. }
  13045. if i.Insutype == "310" {
  13046. is310 = 1
  13047. }
  13048. }
  13049. }
  13050. if is390 == 1 {
  13051. insutype = "390"
  13052. }
  13053. if is310 == 1 {
  13054. insutype = "310"
  13055. }
  13056. if len(insutypes) == 0 {
  13057. insutype = "310"
  13058. }
  13059. c.ServeSuccessJSON(map[string]interface{}{
  13060. "patient": patient,
  13061. "number": basNumber,
  13062. "insutype": insutype,
  13063. })
  13064. } else {
  13065. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13066. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13067. infoStr := string(Iinfos)
  13068. idetinfoStr := string(Idetinfos)
  13069. psn := &models.HisPsn{
  13070. PsnNo: res.Output.Baseinfo.PsnNo,
  13071. PatientId: patient.ID,
  13072. Certno: res.Output.Baseinfo.Certno,
  13073. Gend: res.Output.Baseinfo.Gend,
  13074. Naty: res.Output.Baseinfo.Naty,
  13075. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13076. PsnName: res.Output.Baseinfo.PsnName,
  13077. Idetinfo: idetinfoStr,
  13078. Insuinfo: infoStr,
  13079. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13080. CardInfo: card_info,
  13081. VerifyNumber: token,
  13082. }
  13083. service.CreateHisPsn(psn)
  13084. c.ServeSuccessJSON(map[string]interface{}{
  13085. "patient": patient,
  13086. "number": token,
  13087. })
  13088. }
  13089. }
  13090. } else {
  13091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13092. return
  13093. }
  13094. } else { //读卡失败
  13095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13096. return
  13097. }
  13098. } else {
  13099. if initFlag == 0 {
  13100. c.TestGetBasBaseInit()
  13101. }
  13102. basStr := c.GetBasBaseInfo()
  13103. if len(basStr) == 0 {
  13104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13105. return
  13106. }
  13107. fmt.Println(basStr)
  13108. bas := strings.Split(basStr, "|")
  13109. basNumber := bas[1]
  13110. fmt.Println(basNumber)
  13111. card_sn := bas[3]
  13112. fmt.Println(card_sn)
  13113. cardNumber := bas[2]
  13114. fmt.Println(cardNumber)
  13115. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  13116. var result string
  13117. if bas[0][:2] == "44" {
  13118. 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)
  13119. } else {
  13120. 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)
  13121. }
  13122. var dat map[string]interface{}
  13123. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13124. fmt.Println(dat)
  13125. } else {
  13126. fmt.Println(err)
  13127. }
  13128. userJSONBytes, _ := json.Marshal(dat)
  13129. var res ResultTwo
  13130. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13131. utils.ErrorLog("解析失败:%v", err)
  13132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13133. return
  13134. }
  13135. if res.Infcode == 0 {
  13136. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  13137. if err == gorm.ErrRecordNotFound {
  13138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13139. return
  13140. } else if err != nil {
  13141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13142. return
  13143. } else {
  13144. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13145. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13146. infoStr := string(Iinfos)
  13147. idetinfoStr := string(Idetinfos)
  13148. var rf []*ResultFive
  13149. json.Unmarshal([]byte(infoStr), &rf)
  13150. var insutypes []*ResultFive
  13151. var insutype string
  13152. var is390 int = 0
  13153. var is310 int = 0
  13154. var insuplc_admdvs string
  13155. for _, item := range rf {
  13156. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13157. insutypes = append(insutypes, item)
  13158. }
  13159. }
  13160. if len(insutypes) == 1 {
  13161. insutype = insutypes[0].Insutype
  13162. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13163. } else {
  13164. for _, i := range insutypes {
  13165. if i.Insutype == "390" {
  13166. is390 = 1
  13167. }
  13168. if i.Insutype == "310" {
  13169. is310 = 1
  13170. }
  13171. }
  13172. }
  13173. if is390 == 1 {
  13174. insutype = "390"
  13175. }
  13176. if is310 == 1 {
  13177. insutype = "310"
  13178. }
  13179. if len(insutypes) == 0 {
  13180. insutype = "310"
  13181. }
  13182. for _, item := range rf {
  13183. if item.Insutype == insutype {
  13184. insuplc_admdvs = item.InsuplcAdmdvs
  13185. }
  13186. }
  13187. psn := &models.HisPsn{
  13188. PsnNo: res.Output.Baseinfo.PsnNo,
  13189. PatientId: patient.ID,
  13190. Certno: res.Output.Baseinfo.Certno,
  13191. Gend: res.Output.Baseinfo.Gend,
  13192. Naty: res.Output.Baseinfo.Naty,
  13193. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13194. PsnName: res.Output.Baseinfo.PsnName,
  13195. Idetinfo: idetinfoStr,
  13196. Insuinfo: infoStr,
  13197. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13198. CardInfo: basStr,
  13199. VerifyNumber: "",
  13200. InsuplcAdmdvs: insuplc_admdvs,
  13201. }
  13202. service.CreateHisPsn(psn)
  13203. c.ServeSuccessJSON(map[string]interface{}{
  13204. "patient": patient,
  13205. "number": basNumber,
  13206. })
  13207. }
  13208. } else {
  13209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13210. return
  13211. }
  13212. break
  13213. }
  13214. case 2:
  13215. if miConfig.MdtrtareaAdmvs == "430800" {
  13216. if initFlag == 0 {
  13217. c.TestGetHnBasBaseInit()
  13218. }
  13219. SFZStr := c.GetSFZBaseInfo()
  13220. if len(SFZStr) == 0 {
  13221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  13222. return
  13223. }
  13224. fmt.Println(SFZStr)
  13225. id_card_str := strings.Split(SFZStr, "^")
  13226. card_no := id_card_str[0]
  13227. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  13228. //name := id_card_str[1]
  13229. //name = ConvertToString(name, "gbk", "utf-8")
  13230. 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)
  13231. var dat map[string]interface{}
  13232. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13233. fmt.Println(dat)
  13234. } else {
  13235. fmt.Println(err)
  13236. }
  13237. userJSONBytes, _ := json.Marshal(dat)
  13238. var res ResultTwo
  13239. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13240. utils.ErrorLog("解析失败:%v", err)
  13241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13242. return
  13243. }
  13244. if res.Infcode == 0 {
  13245. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  13246. if err == gorm.ErrRecordNotFound {
  13247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13248. return
  13249. } else if err != nil {
  13250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13251. return
  13252. } else {
  13253. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13254. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13255. infoStr := string(Iinfos)
  13256. idetinfoStr := string(Idetinfos)
  13257. var rf []*ResultFive
  13258. json.Unmarshal([]byte(infoStr), &rf)
  13259. var insutypes []*ResultFive
  13260. var insutype string
  13261. var is390 int = 0
  13262. var is310 int = 0
  13263. for _, item := range rf {
  13264. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13265. insutypes = append(insutypes, item)
  13266. }
  13267. }
  13268. if len(insutypes) == 1 {
  13269. insutype = insutypes[0].Insutype
  13270. } else {
  13271. for _, i := range insutypes {
  13272. if i.Insutype == "390" {
  13273. is390 = 1
  13274. }
  13275. if i.Insutype == "310" {
  13276. is310 = 1
  13277. }
  13278. }
  13279. }
  13280. if is390 == 1 {
  13281. insutype = "390"
  13282. }
  13283. if is310 == 1 {
  13284. insutype = "310"
  13285. }
  13286. if len(insutypes) == 0 {
  13287. insutype = "310"
  13288. }
  13289. var InsuplcAdmdvs string
  13290. for _, item := range rf {
  13291. if item.Insutype == insutype {
  13292. InsuplcAdmdvs = item.InsuplcAdmdvs
  13293. }
  13294. }
  13295. psn := &models.HisPsn{
  13296. PsnNo: res.Output.Baseinfo.PsnNo,
  13297. PatientId: patient.ID,
  13298. Certno: res.Output.Baseinfo.Certno,
  13299. Gend: res.Output.Baseinfo.Gend,
  13300. Naty: res.Output.Baseinfo.Naty,
  13301. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13302. PsnName: res.Output.Baseinfo.PsnName,
  13303. Idetinfo: idetinfoStr,
  13304. Insuinfo: infoStr,
  13305. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13306. CardInfo: SFZStr,
  13307. VerifyNumber: "",
  13308. InsuplcAdmdvs: InsuplcAdmdvs,
  13309. }
  13310. service.CreateHisPsn(psn)
  13311. c.ServeSuccessJSON(map[string]interface{}{
  13312. "patient": patient,
  13313. "number": card_no,
  13314. "insutype": insutype,
  13315. })
  13316. }
  13317. } else {
  13318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13319. return
  13320. }
  13321. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13322. var res ResultTwo
  13323. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  13324. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13325. "&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)
  13326. resp, requestErr := http.Get(api)
  13327. if requestErr != nil {
  13328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13329. return
  13330. }
  13331. body, ioErr := ioutil.ReadAll(resp.Body)
  13332. if ioErr != nil {
  13333. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13335. return
  13336. }
  13337. var respJSON map[string]interface{}
  13338. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13339. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13341. return
  13342. }
  13343. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13344. result, _ := json.Marshal(respJSON)
  13345. fmt.Println("log")
  13346. fmt.Println(string(result))
  13347. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13348. utils.ErrorLog("解析失败:%v", err)
  13349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13350. return
  13351. }
  13352. if res.Infcode == 0 {
  13353. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13354. if err == gorm.ErrRecordNotFound {
  13355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13356. return
  13357. } else if err != nil {
  13358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13359. return
  13360. } else {
  13361. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13362. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13363. infoStr := string(Iinfos)
  13364. idetinfoStr := string(Idetinfos)
  13365. psn := &models.HisPsn{
  13366. PsnNo: res.Output.Baseinfo.PsnNo,
  13367. PatientId: patient.ID,
  13368. Certno: res.Output.Baseinfo.Certno,
  13369. Gend: res.Output.Baseinfo.Gend,
  13370. Naty: res.Output.Baseinfo.Naty,
  13371. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13372. PsnName: res.Output.Baseinfo.PsnName,
  13373. Idetinfo: idetinfoStr,
  13374. Insuinfo: infoStr,
  13375. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13376. }
  13377. service.CreateHisPsn(psn)
  13378. c.ServeSuccessJSON(map[string]interface{}{
  13379. "patient": patient,
  13380. "number": res.Output.Baseinfo.Certno,
  13381. })
  13382. }
  13383. } else {
  13384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13385. return
  13386. }
  13387. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13388. var res ResultTwo
  13389. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13390. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13391. "&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)
  13392. resp, requestErr := http.Get(api)
  13393. if requestErr != nil {
  13394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13395. return
  13396. }
  13397. body, ioErr := ioutil.ReadAll(resp.Body)
  13398. if ioErr != nil {
  13399. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13401. return
  13402. }
  13403. var respJSON map[string]interface{}
  13404. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13405. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13407. return
  13408. }
  13409. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13410. result, _ := json.Marshal(respJSON)
  13411. fmt.Println("log")
  13412. fmt.Println(string(result))
  13413. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13414. utils.ErrorLog("解析失败:%v", err)
  13415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13416. return
  13417. }
  13418. if res.Infcode == 0 {
  13419. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13420. if err == gorm.ErrRecordNotFound {
  13421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13422. return
  13423. } else if err != nil {
  13424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13425. return
  13426. } else {
  13427. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13428. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13429. infoStr := string(Iinfos)
  13430. idetinfoStr := string(Idetinfos)
  13431. psn := &models.HisPsn{
  13432. PsnNo: res.Output.Baseinfo.PsnNo,
  13433. PatientId: patient.ID,
  13434. Certno: res.Output.Baseinfo.Certno,
  13435. Gend: res.Output.Baseinfo.Gend,
  13436. Naty: res.Output.Baseinfo.Naty,
  13437. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13438. PsnName: res.Output.Baseinfo.PsnName,
  13439. Idetinfo: idetinfoStr,
  13440. Insuinfo: infoStr,
  13441. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13442. }
  13443. service.CreateHisPsn(psn)
  13444. c.ServeSuccessJSON(map[string]interface{}{
  13445. "patient": patient,
  13446. "number": res.Output.Baseinfo.Certno,
  13447. })
  13448. }
  13449. } else {
  13450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13451. return
  13452. }
  13453. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13454. var res ResultTwo
  13455. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13456. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13457. "&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)
  13458. resp, requestErr := http.Get(api)
  13459. if requestErr != nil {
  13460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13461. return
  13462. }
  13463. body, ioErr := ioutil.ReadAll(resp.Body)
  13464. if ioErr != nil {
  13465. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13467. return
  13468. }
  13469. var respJSON map[string]interface{}
  13470. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13471. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13473. return
  13474. }
  13475. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13476. result, _ := json.Marshal(respJSON)
  13477. fmt.Println("log")
  13478. fmt.Println(string(result))
  13479. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13480. utils.ErrorLog("解析失败:%v", err)
  13481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13482. return
  13483. }
  13484. if res.Infcode == 0 {
  13485. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13486. if err == gorm.ErrRecordNotFound {
  13487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13488. return
  13489. } else if err != nil {
  13490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13491. return
  13492. } else {
  13493. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13494. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13495. infoStr := string(Iinfos)
  13496. idetinfoStr := string(Idetinfos)
  13497. var rf []*ResultFive
  13498. json.Unmarshal([]byte(infoStr), &rf)
  13499. var insutypes []*ResultFive
  13500. var insutype string
  13501. var is390 int = 0
  13502. var is310 int = 0
  13503. for _, item := range rf {
  13504. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13505. insutypes = append(insutypes, item)
  13506. }
  13507. }
  13508. if len(insutypes) == 1 {
  13509. insutype = insutypes[0].Insutype
  13510. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13511. } else {
  13512. for _, i := range insutypes {
  13513. if i.Insutype == "390" {
  13514. is390 = 1
  13515. }
  13516. if i.Insutype == "310" {
  13517. is310 = 1
  13518. }
  13519. }
  13520. }
  13521. if is390 == 1 {
  13522. insutype = "390"
  13523. }
  13524. if is310 == 1 {
  13525. insutype = "310"
  13526. }
  13527. if len(insutypes) == 0 {
  13528. insutype = "390"
  13529. }
  13530. var insuplc_admdvs string
  13531. for _, item := range rf {
  13532. if item.Insutype == insutype {
  13533. insuplc_admdvs = item.InsuplcAdmdvs
  13534. }
  13535. }
  13536. psn := &models.HisPsn{
  13537. PsnNo: res.Output.Baseinfo.PsnNo,
  13538. PatientId: patient.ID,
  13539. Certno: res.Output.Baseinfo.Certno,
  13540. Gend: res.Output.Baseinfo.Gend,
  13541. Naty: res.Output.Baseinfo.Naty,
  13542. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13543. PsnName: res.Output.Baseinfo.PsnName,
  13544. Idetinfo: idetinfoStr,
  13545. Insuinfo: infoStr,
  13546. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13547. InsuplcAdmdvs: insuplc_admdvs,
  13548. }
  13549. service.CreateHisPsn(psn)
  13550. c.ServeSuccessJSON(map[string]interface{}{
  13551. "patient": patient,
  13552. "number": res.Output.Baseinfo.Certno,
  13553. })
  13554. }
  13555. } else {
  13556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13557. return
  13558. }
  13559. } else if miConfig.MdtrtareaAdmvs == "450721" {
  13560. res := c.GetoleInfo()
  13561. if res.Infcode == 0 {
  13562. var result string
  13563. if res.Output.MdtrtCertType == "01" {
  13564. 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)
  13565. } else if res.Output.MdtrtCertType == "02" {
  13566. 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)
  13567. } else if res.Output.MdtrtCertType == "03" {
  13568. 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)
  13569. }
  13570. var dat map[string]interface{}
  13571. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13572. fmt.Println(dat)
  13573. } else {
  13574. fmt.Println(err)
  13575. }
  13576. userJSONBytes, _ := json.Marshal(dat)
  13577. var res2 ResultTwo
  13578. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13579. utils.ErrorLog("解析失败:%v", err)
  13580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13581. return
  13582. }
  13583. if res2.Infcode == 0 {
  13584. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  13585. if err == gorm.ErrRecordNotFound {
  13586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13587. return
  13588. } else if err != nil {
  13589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13590. return
  13591. } else {
  13592. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  13593. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  13594. infoStr := string(Iinfos)
  13595. idetinfoStr := string(Idetinfos)
  13596. var rf []*ResultFive
  13597. json.Unmarshal([]byte(infoStr), &rf)
  13598. var insutypes []*ResultFive
  13599. var insutype string
  13600. var is390 int = 0
  13601. var is310 int = 0
  13602. //var insuplc_admdvs string
  13603. for _, item := range rf {
  13604. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13605. insutypes = append(insutypes, item)
  13606. }
  13607. }
  13608. if len(insutypes) == 1 {
  13609. insutype = insutypes[0].Insutype
  13610. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13611. } else {
  13612. for _, i := range insutypes {
  13613. if i.Insutype == "390" {
  13614. is390 = 1
  13615. }
  13616. if i.Insutype == "310" {
  13617. is310 = 1
  13618. }
  13619. }
  13620. }
  13621. if is390 == 1 {
  13622. insutype = "390"
  13623. }
  13624. if is310 == 1 {
  13625. insutype = "310"
  13626. }
  13627. if len(insutypes) == 0 {
  13628. insutype = "310"
  13629. }
  13630. psn := &models.HisPsn{
  13631. PsnNo: res2.Output.Baseinfo.PsnNo,
  13632. PatientId: patient.ID,
  13633. //Brdy: res2.Output.Baseinfo.Brdy,
  13634. Certno: res2.Output.Baseinfo.Certno,
  13635. Gend: res2.Output.Baseinfo.Gend,
  13636. Naty: res2.Output.Baseinfo.Naty,
  13637. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  13638. PsnName: res2.Output.Baseinfo.PsnName,
  13639. Idetinfo: idetinfoStr,
  13640. Insuinfo: infoStr,
  13641. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13642. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  13643. VerifyNumber: res.Output.EcToken,
  13644. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  13645. }
  13646. service.CreateHisPsn(psn)
  13647. var balc float64
  13648. for _, item := range rf {
  13649. if item.Insutype == insutype {
  13650. balc = item.Balc
  13651. }
  13652. }
  13653. c.ServeSuccessJSON(map[string]interface{}{
  13654. "patient": patient,
  13655. "number": res.Output.CardNo,
  13656. "insutype": insutype,
  13657. "blac": balc,
  13658. "desc": idetinfoStr,
  13659. })
  13660. }
  13661. } else {
  13662. c.ServeSuccessJSON(map[string]interface{}{
  13663. "failed_code": -10,
  13664. "msg": res2.ErrMsg,
  13665. })
  13666. }
  13667. } else {
  13668. c.ServeSuccessJSON(map[string]interface{}{
  13669. "failed_code": -10,
  13670. "msg": res.ErrMsg,
  13671. })
  13672. }
  13673. } else {
  13674. SFZStr := c.GetSFZBaseInfo()
  13675. id_card_str := strings.Split(SFZStr, "^")
  13676. id_card_number := id_card_str[0]
  13677. card_sn := ""
  13678. 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)
  13679. var dat map[string]interface{}
  13680. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13681. fmt.Println(dat)
  13682. } else {
  13683. fmt.Println(err)
  13684. }
  13685. userJSONBytes, _ := json.Marshal(dat)
  13686. var res ResultTwo
  13687. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13688. utils.ErrorLog("解析失败:%v", err)
  13689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13690. return
  13691. }
  13692. if res.Infcode == 0 {
  13693. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  13694. if err == gorm.ErrRecordNotFound {
  13695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13696. return
  13697. } else if err != nil {
  13698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13699. return
  13700. } else {
  13701. c.ServeSuccessJSON(map[string]interface{}{
  13702. "patient": patient,
  13703. "number": id_card_number,
  13704. })
  13705. }
  13706. } else {
  13707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13708. return
  13709. }
  13710. }
  13711. break
  13712. case 3:
  13713. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13714. var api string
  13715. if miConfig.MdtrtareaAdmvs == "320921" {
  13716. 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 +
  13717. "&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
  13718. fmt.Println(api)
  13719. } else {
  13720. 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 +
  13721. "&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)
  13722. }
  13723. resp, requestErr := http.Get(api)
  13724. if requestErr != nil {
  13725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13726. return
  13727. }
  13728. body, ioErr := ioutil.ReadAll(resp.Body)
  13729. if ioErr != nil {
  13730. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13732. return
  13733. }
  13734. var respJSON map[string]interface{}
  13735. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13738. return
  13739. }
  13740. var status string
  13741. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13742. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13743. var token string
  13744. var res ResultTwo //1101结果
  13745. var res10265 ResultTwo10265 //1101结果
  13746. var card_info string //卡信息
  13747. var busi_card_info string
  13748. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13749. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13750. if status == "0" { //读卡成功
  13751. if card_type == "1" {
  13752. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13753. result, _ := json.Marshal(respJSON)
  13754. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13755. utils.ErrorLog("解析失败:%v", err)
  13756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13757. return
  13758. }
  13759. res.ErrMsg = res10265.ErrMsg
  13760. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13761. res.Infcode = infocode
  13762. res.Output = res10265.Output
  13763. res.InfRefmsgid = res10265.InfRefmsgid
  13764. } else {
  13765. //var card_info string //卡信息
  13766. //var busi_card_info string
  13767. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13768. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13769. //fmt.Println(card_info)
  13770. //fmt.Println(busi_card_info)
  13771. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13772. result, _ := json.Marshal(respJSON)
  13773. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13774. utils.ErrorLog("解析失败:%v", err)
  13775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13776. return
  13777. }
  13778. res.ErrMsg = res10265.ErrMsg
  13779. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13780. res.Infcode = infocode
  13781. res.Output = res10265.Output
  13782. res.InfRefmsgid = res10265.InfRefmsgid
  13783. }
  13784. if res.Infcode == 0 {
  13785. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13786. if err == gorm.ErrRecordNotFound {
  13787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13788. return
  13789. } else if err != nil {
  13790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13791. return
  13792. } else {
  13793. if card_type == "1" {
  13794. bas := strings.Split(card_info, "|")
  13795. basNumber := bas[2]
  13796. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13797. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13798. infoStr := string(Iinfos)
  13799. idetinfoStr := string(Idetinfos)
  13800. psn := &models.HisPsn{
  13801. PsnNo: res.Output.Baseinfo.PsnNo,
  13802. PatientId: patient.ID,
  13803. Certno: res.Output.Baseinfo.Certno,
  13804. //Brdy: res.Output.Baseinfo.Brdy,
  13805. Gend: res.Output.Baseinfo.Gend,
  13806. Naty: res.Output.Baseinfo.Naty,
  13807. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13808. PsnName: res.Output.Baseinfo.PsnName,
  13809. Idetinfo: idetinfoStr,
  13810. Insuinfo: infoStr,
  13811. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13812. CardInfo: card_info,
  13813. VerifyNumber: busi_card_info,
  13814. }
  13815. service.CreateHisPsn(psn)
  13816. c.ServeSuccessJSON(map[string]interface{}{
  13817. "patient": patient,
  13818. "number": basNumber,
  13819. })
  13820. } else {
  13821. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13822. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13823. infoStr := string(Iinfos)
  13824. idetinfoStr := string(Idetinfos)
  13825. psn := &models.HisPsn{
  13826. PsnNo: res.Output.Baseinfo.PsnNo,
  13827. PatientId: patient.ID,
  13828. Certno: res.Output.Baseinfo.Certno,
  13829. Gend: res.Output.Baseinfo.Gend,
  13830. Naty: res.Output.Baseinfo.Naty,
  13831. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13832. PsnName: res.Output.Baseinfo.PsnName,
  13833. Idetinfo: idetinfoStr,
  13834. Insuinfo: infoStr,
  13835. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13836. CardInfo: card_info,
  13837. VerifyNumber: token,
  13838. }
  13839. service.CreateHisPsn(psn)
  13840. var rf []*ResultFive
  13841. json.Unmarshal([]byte(infoStr), &rf)
  13842. var insutypes []*ResultFive
  13843. var insutype string
  13844. var is390 int = 0
  13845. var is310 int = 0
  13846. for _, item := range rf {
  13847. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13848. insutypes = append(insutypes, item)
  13849. }
  13850. }
  13851. if len(insutypes) == 1 {
  13852. insutype = insutypes[0].Insutype
  13853. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13854. } else {
  13855. for _, i := range insutypes {
  13856. if i.Insutype == "390" {
  13857. is390 = 1
  13858. }
  13859. if i.Insutype == "310" {
  13860. is310 = 1
  13861. }
  13862. }
  13863. }
  13864. if is390 == 1 {
  13865. insutype = "390"
  13866. }
  13867. if is310 == 1 {
  13868. insutype = "310"
  13869. }
  13870. if len(insutypes) == 0 {
  13871. insutype = "310"
  13872. }
  13873. c.ServeSuccessJSON(map[string]interface{}{
  13874. "patient": patient,
  13875. "number": token,
  13876. "insutype": insutype,
  13877. })
  13878. }
  13879. }
  13880. } else {
  13881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13882. return
  13883. }
  13884. } else { //读卡失败
  13885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13886. return
  13887. }
  13888. }
  13889. break
  13890. case 4:
  13891. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13892. var api string
  13893. if miConfig.MdtrtareaAdmvs == "320921" {
  13894. 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 +
  13895. "&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
  13896. fmt.Println(api)
  13897. } else {
  13898. 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 +
  13899. "&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)
  13900. }
  13901. resp, requestErr := http.Get(api)
  13902. if requestErr != nil {
  13903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13904. return
  13905. }
  13906. body, ioErr := ioutil.ReadAll(resp.Body)
  13907. if ioErr != nil {
  13908. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13910. return
  13911. }
  13912. var respJSON map[string]interface{}
  13913. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13914. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13916. return
  13917. }
  13918. var status string
  13919. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13920. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13921. var token string
  13922. var res ResultTwo //1101结果
  13923. var res10265 ResultTwo10265 //1101结果
  13924. if status == "0" { //读卡成功
  13925. var card_info string //卡信息
  13926. var busi_card_info string
  13927. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13928. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13929. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13930. fmt.Println(card_info)
  13931. fmt.Println(busi_card_info)
  13932. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13933. result, _ := json.Marshal(respJSON)
  13934. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13935. utils.ErrorLog("解析失败:%v", err)
  13936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13937. return
  13938. }
  13939. res.ErrMsg = res10265.ErrMsg
  13940. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13941. res.Infcode = infocode
  13942. res.Output = res10265.Output
  13943. res.InfRefmsgid = res10265.InfRefmsgid
  13944. if res.Infcode == 0 {
  13945. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13946. if err == gorm.ErrRecordNotFound {
  13947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13948. return
  13949. } else if err != nil {
  13950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13951. return
  13952. } else {
  13953. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13954. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13955. infoStr := string(Iinfos)
  13956. idetinfoStr := string(Idetinfos)
  13957. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13958. psn := &models.HisPsn{
  13959. PsnNo: res.Output.Baseinfo.PsnNo,
  13960. PatientId: patient.ID,
  13961. Certno: res.Output.Baseinfo.Certno,
  13962. Brdy: b,
  13963. Age: float64(age),
  13964. //Brdy: res.Output.Baseinfo.Brdy,
  13965. Gend: res.Output.Baseinfo.Gend,
  13966. Naty: res.Output.Baseinfo.Naty,
  13967. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13968. PsnName: res.Output.Baseinfo.PsnName,
  13969. Idetinfo: idetinfoStr,
  13970. Insuinfo: infoStr,
  13971. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13972. CardInfo: card_info,
  13973. VerifyNumber: token,
  13974. }
  13975. var rf []*ResultFive
  13976. json.Unmarshal([]byte(infoStr), &rf)
  13977. var insutypes []*ResultFive
  13978. var insutype string
  13979. var is390 int = 0
  13980. var is310 int = 0
  13981. for _, item := range rf {
  13982. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13983. insutypes = append(insutypes, item)
  13984. }
  13985. }
  13986. if len(insutypes) == 1 {
  13987. insutype = insutypes[0].Insutype
  13988. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13989. } else {
  13990. for _, i := range insutypes {
  13991. if i.Insutype == "390" {
  13992. is390 = 1
  13993. }
  13994. if i.Insutype == "310" {
  13995. is310 = 1
  13996. }
  13997. }
  13998. }
  13999. if is390 == 1 {
  14000. insutype = "390"
  14001. }
  14002. if is310 == 1 {
  14003. insutype = "310"
  14004. }
  14005. if len(insutypes) == 0 {
  14006. insutype = "310"
  14007. }
  14008. service.CreateHisPsn(psn)
  14009. c.ServeSuccessJSON(map[string]interface{}{
  14010. "patient": patient,
  14011. "number": token,
  14012. "insutype": insutype,
  14013. })
  14014. }
  14015. } else {
  14016. c.ServeSuccessJSON(map[string]interface{}{
  14017. "failed_code": -10,
  14018. "msg": res.ErrMsg,
  14019. })
  14020. }
  14021. } else { //读卡失败
  14022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14023. return
  14024. }
  14025. } else if miConfig.MdtrtareaAdmvs == "341203" {
  14026. var api string
  14027. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14028. "&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
  14029. resp, requestErr := http.Get(api)
  14030. if requestErr != nil {
  14031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14032. return
  14033. }
  14034. body, ioErr := ioutil.ReadAll(resp.Body)
  14035. if ioErr != nil {
  14036. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14038. return
  14039. }
  14040. var respJSON map[string]interface{}
  14041. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14042. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14044. return
  14045. }
  14046. var status string
  14047. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14048. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14049. var token string
  14050. var res ResultTwo //1101结果
  14051. if status == "1" { //读卡成功
  14052. var card_info string //卡信息
  14053. var busi_card_info string
  14054. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14055. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14056. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14057. fmt.Println(card_info)
  14058. fmt.Println(busi_card_info)
  14059. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14060. result, _ := json.Marshal(respJSON)
  14061. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14062. utils.ErrorLog("解析失败:%v", err)
  14063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14064. return
  14065. }
  14066. if res.Infcode == 0 {
  14067. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14068. if err == gorm.ErrRecordNotFound {
  14069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14070. return
  14071. } else if err != nil {
  14072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14073. return
  14074. } else {
  14075. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14076. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14077. infoStr := string(Iinfos)
  14078. idetinfoStr := string(Idetinfos)
  14079. psn := &models.HisPsn{
  14080. PsnNo: res.Output.Baseinfo.PsnNo,
  14081. PatientId: patient.ID,
  14082. Certno: res.Output.Baseinfo.Certno,
  14083. Gend: res.Output.Baseinfo.Gend,
  14084. Naty: res.Output.Baseinfo.Naty,
  14085. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14086. PsnName: res.Output.Baseinfo.PsnName,
  14087. Idetinfo: idetinfoStr,
  14088. Insuinfo: infoStr,
  14089. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14090. CardInfo: card_info,
  14091. VerifyNumber: token,
  14092. }
  14093. var rf []*ResultFive
  14094. json.Unmarshal([]byte(infoStr), &rf)
  14095. var insutypes []*ResultFive
  14096. var insutype string
  14097. var is390 int = 0
  14098. var is310 int = 0
  14099. for _, item := range rf {
  14100. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14101. insutypes = append(insutypes, item)
  14102. }
  14103. }
  14104. if len(insutypes) == 1 {
  14105. insutype = insutypes[0].Insutype
  14106. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14107. } else {
  14108. for _, i := range insutypes {
  14109. if i.Insutype == "390" {
  14110. is390 = 1
  14111. }
  14112. if i.Insutype == "310" {
  14113. is310 = 1
  14114. }
  14115. }
  14116. }
  14117. if is390 == 1 {
  14118. insutype = "390"
  14119. }
  14120. if is310 == 1 {
  14121. insutype = "310"
  14122. }
  14123. if len(insutypes) == 0 {
  14124. insutype = "310"
  14125. }
  14126. service.CreateHisPsn(psn)
  14127. c.ServeSuccessJSON(map[string]interface{}{
  14128. "patient": patient,
  14129. "number": token,
  14130. "insutype": insutype,
  14131. })
  14132. }
  14133. } else {
  14134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14135. return
  14136. }
  14137. } else { //读卡失败
  14138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14139. return
  14140. }
  14141. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14142. //idNo := c.GetString("idNo")
  14143. //userName := c.GetString("userName")
  14144. //ecToken := c.GetString("ecToken")
  14145. //insuOrg := c.GetString("insuOrg")
  14146. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  14147. utils.ErrorLog("解析失败:%v", json_result)
  14148. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  14149. type ELeData struct {
  14150. Data struct {
  14151. IdNo string `json:"idNo"`
  14152. IdType string `json:"idType"`
  14153. UserName string `json:"userName"`
  14154. EcToken string `json:"ecToken"`
  14155. InsuOrg string `json:"insuOrg"`
  14156. Gender string `json:"gender"`
  14157. Birthday string `json:"birthday"`
  14158. Nationality string `json:"nationality"`
  14159. Email string `json:"email"`
  14160. Extra string `json:"extra"`
  14161. } `json:"data"`
  14162. Code int `json:"code"`
  14163. Message string `json:"message"`
  14164. }
  14165. var ele ELeData
  14166. err := json.Unmarshal([]byte(json_result), &ele)
  14167. if err != nil {
  14168. utils.ErrorLog("解析失败:%v", err)
  14169. }
  14170. token := ele.Data.EcToken
  14171. token = Remove0000(token)
  14172. 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)
  14173. saveLog(result2, requestLog2, "1101", "获取人员信息")
  14174. var res ResultTwo
  14175. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  14176. utils.ErrorLog("解析失败:%v", err)
  14177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14178. return
  14179. }
  14180. if res.Infcode == 0 {
  14181. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14182. if err == gorm.ErrRecordNotFound {
  14183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14184. return
  14185. } else if err != nil {
  14186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14187. return
  14188. } else {
  14189. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14190. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14191. infoStr := string(Iinfos)
  14192. idetinfoStr := string(Idetinfos)
  14193. psn := &models.HisPsn{
  14194. PsnNo: res.Output.Baseinfo.PsnNo,
  14195. PatientId: patient.ID,
  14196. Certno: res.Output.Baseinfo.Certno,
  14197. Gend: res.Output.Baseinfo.Gend,
  14198. Naty: res.Output.Baseinfo.Naty,
  14199. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14200. PsnName: res.Output.Baseinfo.PsnName,
  14201. Idetinfo: idetinfoStr,
  14202. Insuinfo: infoStr,
  14203. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14204. CardInfo: "",
  14205. Stage: "1",
  14206. VerifyNumber: token,
  14207. InsuplcAdmdvs: ele.Data.InsuOrg,
  14208. }
  14209. service.CreateHisPsn(psn)
  14210. var rf []*ResultFive
  14211. json.Unmarshal([]byte(infoStr), &rf)
  14212. var insutypes []*ResultFive
  14213. var insutype string
  14214. var is390 int = 0
  14215. var is310 int = 0
  14216. for _, item := range rf {
  14217. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14218. insutypes = append(insutypes, item)
  14219. }
  14220. }
  14221. if len(insutypes) == 1 {
  14222. insutype = insutypes[0].Insutype
  14223. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14224. } else {
  14225. for _, i := range insutypes {
  14226. if i.Insutype == "390" {
  14227. is390 = 1
  14228. }
  14229. if i.Insutype == "310" {
  14230. is310 = 1
  14231. }
  14232. }
  14233. }
  14234. if is390 == 1 {
  14235. insutype = "390"
  14236. }
  14237. if is310 == 1 {
  14238. insutype = "310"
  14239. }
  14240. if len(insutypes) == 0 {
  14241. insutype = "310"
  14242. }
  14243. c.ServeSuccessJSON(map[string]interface{}{
  14244. "patient": patient,
  14245. "number": token,
  14246. "insutype": insutype,
  14247. })
  14248. }
  14249. } else {
  14250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14251. return
  14252. }
  14253. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14254. //if initFlag == 0 {
  14255. //c.TestGetJiangXiBasBaseInit()
  14256. //}
  14257. //if initEleFlag == 0 {
  14258. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  14259. //}
  14260. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  14261. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  14262. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  14263. type ELeData struct {
  14264. Data struct {
  14265. IdNo string `json:"idNo"`
  14266. IdType string `json:"idType"`
  14267. UserName string `json:"userName"`
  14268. EcToken string `json:"ecToken"`
  14269. InsuOrg string `json:"insuOrg"`
  14270. Gender string `json:"gender"`
  14271. Birthday string `json:"birthday"`
  14272. Nationality string `json:"nationality"`
  14273. Email string `json:"email"`
  14274. Extra string `json:"extra"`
  14275. } `json:"data"`
  14276. Code int `json:"code"`
  14277. Message string `json:"message"`
  14278. }
  14279. var ele ELeData
  14280. err := json.Unmarshal([]byte(result), &ele)
  14281. if err != nil {
  14282. utils.ErrorLog("解析失败:%v", err)
  14283. }
  14284. token := ele.Data.EcToken
  14285. token = Remove0000(token)
  14286. 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)
  14287. saveLog(result2, requestLog2, "1101", "获取人员信息")
  14288. var res ResultTwo
  14289. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  14290. utils.ErrorLog("解析失败:%v", err)
  14291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14292. return
  14293. }
  14294. if res.Infcode == 0 {
  14295. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14296. if err == gorm.ErrRecordNotFound {
  14297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14298. return
  14299. } else if err != nil {
  14300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14301. return
  14302. } else {
  14303. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14304. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14305. infoStr := string(Iinfos)
  14306. idetinfoStr := string(Idetinfos)
  14307. psn := &models.HisPsn{
  14308. PsnNo: res.Output.Baseinfo.PsnNo,
  14309. PatientId: patient.ID,
  14310. Certno: res.Output.Baseinfo.Certno,
  14311. Gend: res.Output.Baseinfo.Gend,
  14312. Naty: res.Output.Baseinfo.Naty,
  14313. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14314. PsnName: res.Output.Baseinfo.PsnName,
  14315. Idetinfo: idetinfoStr,
  14316. Insuinfo: infoStr,
  14317. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14318. CardInfo: "",
  14319. VerifyNumber: token,
  14320. InsuplcAdmdvs: ele.Data.InsuOrg,
  14321. }
  14322. service.CreateHisPsn(psn)
  14323. var rf []*ResultFive
  14324. json.Unmarshal([]byte(infoStr), &rf)
  14325. var insutypes []*ResultFive
  14326. var insutype string
  14327. var is390 int = 0
  14328. var is310 int = 0
  14329. for _, item := range rf {
  14330. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14331. insutypes = append(insutypes, item)
  14332. }
  14333. }
  14334. if len(insutypes) == 1 {
  14335. insutype = insutypes[0].Insutype
  14336. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14337. } else {
  14338. for _, i := range insutypes {
  14339. if i.Insutype == "390" {
  14340. is390 = 1
  14341. }
  14342. if i.Insutype == "310" {
  14343. is310 = 1
  14344. }
  14345. }
  14346. }
  14347. if is390 == 1 {
  14348. insutype = "390"
  14349. }
  14350. if is310 == 1 {
  14351. insutype = "310"
  14352. }
  14353. if len(insutypes) == 0 {
  14354. insutype = "310"
  14355. }
  14356. c.ServeSuccessJSON(map[string]interface{}{
  14357. "patient": patient,
  14358. "number": token,
  14359. "insutype": insutype,
  14360. })
  14361. }
  14362. } else {
  14363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14364. return
  14365. }
  14366. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14367. //if initFlag == 0 {
  14368. c.TestGetJiangXiBasBaseInit()
  14369. //}
  14370. //if initEleFlag == 0 {
  14371. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  14372. //}
  14373. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  14374. type ELeData struct {
  14375. Data struct {
  14376. IdNo string `json:"idNo"`
  14377. IdType string `json:"idType"`
  14378. UserName string `json:"userName"`
  14379. EcToken string `json:"ecToken"`
  14380. InsuOrg string `json:"insuOrg"`
  14381. Gender string `json:"gender"`
  14382. Birthday string `json:"birthday"`
  14383. Nationality string `json:"nationality"`
  14384. Email string `json:"email"`
  14385. Extra string `json:"extra"`
  14386. } `json:"data"`
  14387. Code int `json:"code"`
  14388. Message string `json:"message"`
  14389. }
  14390. var ele ELeData
  14391. err := json.Unmarshal([]byte(json_result), &ele)
  14392. if err != nil {
  14393. utils.ErrorLog("解析失败:%v", err)
  14394. }
  14395. token := ele.Data.EcToken
  14396. token = Remove0000(token)
  14397. 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)
  14398. saveLog(result2, requestLog2, "1101", "获取人员信息")
  14399. var res ResultTwo
  14400. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  14401. utils.ErrorLog("解析失败:%v", err)
  14402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14403. return
  14404. }
  14405. if res.Infcode == 0 {
  14406. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14407. if err == gorm.ErrRecordNotFound {
  14408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14409. return
  14410. } else if err != nil {
  14411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14412. return
  14413. } else {
  14414. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14415. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14416. infoStr := string(Iinfos)
  14417. idetinfoStr := string(Idetinfos)
  14418. psn := &models.HisPsn{
  14419. PsnNo: res.Output.Baseinfo.PsnNo,
  14420. PatientId: patient.ID,
  14421. Certno: res.Output.Baseinfo.Certno,
  14422. Gend: res.Output.Baseinfo.Gend,
  14423. Naty: res.Output.Baseinfo.Naty,
  14424. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14425. PsnName: res.Output.Baseinfo.PsnName,
  14426. Idetinfo: idetinfoStr,
  14427. Insuinfo: infoStr,
  14428. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14429. CardInfo: "",
  14430. VerifyNumber: token,
  14431. }
  14432. service.CreateHisPsn(psn)
  14433. var rf []*ResultFive
  14434. json.Unmarshal([]byte(infoStr), &rf)
  14435. var insutypes []*ResultFive
  14436. var insutype string
  14437. var is390 int = 0
  14438. var is310 int = 0
  14439. for _, item := range rf {
  14440. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14441. insutypes = append(insutypes, item)
  14442. }
  14443. }
  14444. if len(insutypes) == 1 {
  14445. insutype = insutypes[0].Insutype
  14446. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14447. } else {
  14448. for _, i := range insutypes {
  14449. if i.Insutype == "390" {
  14450. is390 = 1
  14451. }
  14452. if i.Insutype == "310" {
  14453. is310 = 1
  14454. }
  14455. }
  14456. }
  14457. if is390 == 1 {
  14458. insutype = "390"
  14459. }
  14460. if is310 == 1 {
  14461. insutype = "310"
  14462. }
  14463. if len(insutypes) == 0 {
  14464. insutype = "310"
  14465. }
  14466. c.ServeSuccessJSON(map[string]interface{}{
  14467. "patient": patient,
  14468. "number": token,
  14469. "insutype": insutype,
  14470. })
  14471. }
  14472. } else {
  14473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14474. return
  14475. }
  14476. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14477. type ELeData struct {
  14478. Code string `json:"code"`
  14479. Data struct {
  14480. Aac002 string `json:"aac002"`
  14481. Aaz500 string `json:"aaz500"`
  14482. ActCardNo string `json:"actCardNo"`
  14483. Bab520 string `json:"bab520"`
  14484. Bkz543 string `json:"bkz543"`
  14485. BusinessType string `json:"businessType"`
  14486. CertfCodg string `json:"certfCodg"`
  14487. EcIndexNo string `json:"ecIndexNo"`
  14488. EcToken string `json:"ecToken"`
  14489. ID0000 string `json:"id0000"`
  14490. IDNo string `json:"idNo"`
  14491. IDType string `json:"idType"`
  14492. Idcode string `json:"idcode"`
  14493. IdentityToken string `json:"identity_token"`
  14494. InsuOrg string `json:"insuOrg"`
  14495. OfficeID string `json:"officeId"`
  14496. OfficeName string `json:"officeName"`
  14497. OperatorID string `json:"operatorId"`
  14498. OperatorName string `json:"operatorName"`
  14499. OrgID string `json:"orgId"`
  14500. UserName string `json:"userName"`
  14501. } `json:"data"`
  14502. Infno interface{} `json:"infno"`
  14503. Message string `json:"message"`
  14504. OrgID string `json:"orgId"`
  14505. TransType string `json:"transType"`
  14506. }
  14507. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  14508. outPutInfo = Remove0000(outPutInfo)
  14509. if len(outPutInfo) > 0 {
  14510. var ele ELeData
  14511. err := json.Unmarshal([]byte(outPutInfo), &ele)
  14512. if err != nil {
  14513. utils.ErrorLog("解析失败:%v", err)
  14514. }
  14515. token := ele.Data.EcToken
  14516. fmt.Println(inputInfo)
  14517. fmt.Println(outPutInfo)
  14518. 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)
  14519. saveLog(result, requestLog, "1101", "获取人员信息")
  14520. var dat map[string]interface{}
  14521. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14522. fmt.Println(dat)
  14523. } else {
  14524. fmt.Println(err)
  14525. }
  14526. userJSONBytes, _ := json.Marshal(dat)
  14527. var res ResultTwo
  14528. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14529. utils.ErrorLog("解析失败:%v", err)
  14530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14531. return
  14532. }
  14533. res.ErrMsg = errMsgLog
  14534. if res.Infcode == 0 {
  14535. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  14536. if err == gorm.ErrRecordNotFound {
  14537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14538. return
  14539. } else if err != nil {
  14540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14541. return
  14542. } else {
  14543. fmt.Println(res)
  14544. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14545. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14546. infoStr := string(Iinfos)
  14547. idetinfoStr := string(Idetinfos)
  14548. psn := &models.HisPsn{
  14549. PsnNo: res.Output.Baseinfo.PsnNo,
  14550. PatientId: patient.ID,
  14551. Certno: res.Output.Baseinfo.Certno,
  14552. Gend: res.Output.Baseinfo.Gend,
  14553. Naty: res.Output.Baseinfo.Naty,
  14554. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14555. PsnName: res.Output.Baseinfo.PsnName,
  14556. Idetinfo: idetinfoStr,
  14557. Insuinfo: infoStr,
  14558. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14559. CardInfo: outPutInfo,
  14560. VerifyNumber: token,
  14561. InsuplcAdmdvs: ele.Data.InsuOrg,
  14562. }
  14563. service.CreateHisPsn(psn)
  14564. var rf []*ResultFive
  14565. json.Unmarshal([]byte(infoStr), &rf)
  14566. var insutypes []*ResultFive
  14567. var insutype string
  14568. var is390 int = 0
  14569. var is310 int = 0
  14570. for _, item := range rf {
  14571. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14572. insutypes = append(insutypes, item)
  14573. }
  14574. }
  14575. if len(insutypes) == 1 {
  14576. insutype = insutypes[0].Insutype
  14577. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14578. } else {
  14579. for _, i := range insutypes {
  14580. if i.Insutype == "390" {
  14581. is390 = 1
  14582. }
  14583. if i.Insutype == "310" {
  14584. is310 = 1
  14585. }
  14586. }
  14587. }
  14588. if is390 == 1 {
  14589. insutype = "390"
  14590. }
  14591. if is310 == 1 {
  14592. insutype = "310"
  14593. }
  14594. if len(insutypes) == 0 {
  14595. insutype = "310"
  14596. }
  14597. c.ServeSuccessJSON(map[string]interface{}{
  14598. "patient": patient,
  14599. "number": token,
  14600. "insutype": insutype,
  14601. })
  14602. }
  14603. } else {
  14604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14605. return
  14606. }
  14607. }
  14608. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14609. var api string
  14610. 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 +
  14611. "&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
  14612. resp, requestErr := http.Get(api)
  14613. if requestErr != nil {
  14614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14615. return
  14616. }
  14617. body, ioErr := ioutil.ReadAll(resp.Body)
  14618. if ioErr != nil {
  14619. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14621. return
  14622. }
  14623. var respJSON map[string]interface{}
  14624. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14625. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14627. return
  14628. }
  14629. var status string
  14630. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14631. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14632. var token string
  14633. var res ResultTwo //1101结果
  14634. var res10265 ResultTwo10265 //1101结果
  14635. if status == "0" { //读卡成功
  14636. var card_info string //卡信息
  14637. var busi_card_info string
  14638. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14639. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14640. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14641. fmt.Println(card_info)
  14642. fmt.Println(busi_card_info)
  14643. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14644. result, _ := json.Marshal(respJSON)
  14645. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14646. utils.ErrorLog("解析失败:%v", err)
  14647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14648. return
  14649. }
  14650. res.ErrMsg = res10265.ErrMsg
  14651. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14652. res.Infcode = infocode
  14653. res.Output = res10265.Output
  14654. res.InfRefmsgid = res10265.InfRefmsgid
  14655. if res.Infcode == 0 {
  14656. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14657. if err == gorm.ErrRecordNotFound {
  14658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14659. return
  14660. } else if err != nil {
  14661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14662. return
  14663. } else {
  14664. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14665. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14666. infoStr := string(Iinfos)
  14667. idetinfoStr := string(Idetinfos)
  14668. psn := &models.HisPsn{
  14669. PsnNo: res.Output.Baseinfo.PsnNo,
  14670. PatientId: patient.ID,
  14671. Certno: res.Output.Baseinfo.Certno,
  14672. Gend: res.Output.Baseinfo.Gend,
  14673. Naty: res.Output.Baseinfo.Naty,
  14674. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14675. PsnName: res.Output.Baseinfo.PsnName,
  14676. Idetinfo: idetinfoStr,
  14677. Insuinfo: infoStr,
  14678. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14679. CardInfo: card_info,
  14680. VerifyNumber: token,
  14681. }
  14682. var rf []*ResultFive
  14683. json.Unmarshal([]byte(infoStr), &rf)
  14684. var insutypes []*ResultFive
  14685. var insutype string
  14686. var is390 int = 0
  14687. var is310 int = 0
  14688. for _, item := range rf {
  14689. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14690. insutypes = append(insutypes, item)
  14691. }
  14692. }
  14693. if len(insutypes) == 1 {
  14694. insutype = insutypes[0].Insutype
  14695. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14696. } else {
  14697. for _, i := range insutypes {
  14698. if i.Insutype == "390" {
  14699. is390 = 1
  14700. }
  14701. if i.Insutype == "310" {
  14702. is310 = 1
  14703. }
  14704. }
  14705. }
  14706. if is390 == 1 {
  14707. insutype = "390"
  14708. }
  14709. if is310 == 1 {
  14710. insutype = "310"
  14711. }
  14712. if len(insutypes) == 0 {
  14713. insutype = "310"
  14714. }
  14715. service.CreateHisPsn(psn)
  14716. c.ServeSuccessJSON(map[string]interface{}{
  14717. "patient": patient,
  14718. "number": token,
  14719. "insutype": insutype,
  14720. })
  14721. }
  14722. } else {
  14723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14724. return
  14725. }
  14726. } else { //读卡失败
  14727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14728. return
  14729. }
  14730. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14731. res := c.GetoleInfo()
  14732. if res.Infcode == 0 {
  14733. var result string
  14734. if res.Output.MdtrtCertType == "01" {
  14735. 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)
  14736. } else if res.Output.MdtrtCertType == "02" {
  14737. 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)
  14738. } else if res.Output.MdtrtCertType == "03" {
  14739. 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)
  14740. }
  14741. var dat map[string]interface{}
  14742. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14743. fmt.Println(dat)
  14744. } else {
  14745. fmt.Println(err)
  14746. }
  14747. userJSONBytes, _ := json.Marshal(dat)
  14748. var res2 ResultTwo
  14749. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14750. utils.ErrorLog("解析失败:%v", err)
  14751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14752. return
  14753. }
  14754. if res2.Infcode == 0 {
  14755. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14756. if err == gorm.ErrRecordNotFound {
  14757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14758. return
  14759. } else if err != nil {
  14760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14761. return
  14762. } else {
  14763. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14764. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14765. infoStr := string(Iinfos)
  14766. idetinfoStr := string(Idetinfos)
  14767. var rf []*ResultFive
  14768. json.Unmarshal([]byte(infoStr), &rf)
  14769. var insutypes []*ResultFive
  14770. var insutype string
  14771. var is390 int = 0
  14772. var is310 int = 0
  14773. //var insuplc_admdvs string
  14774. for _, item := range rf {
  14775. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14776. insutypes = append(insutypes, item)
  14777. }
  14778. }
  14779. if len(insutypes) == 1 {
  14780. insutype = insutypes[0].Insutype
  14781. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14782. } else {
  14783. for _, i := range insutypes {
  14784. if i.Insutype == "390" {
  14785. is390 = 1
  14786. }
  14787. if i.Insutype == "310" {
  14788. is310 = 1
  14789. }
  14790. }
  14791. }
  14792. if is390 == 1 {
  14793. insutype = "390"
  14794. }
  14795. if is310 == 1 {
  14796. insutype = "310"
  14797. }
  14798. if len(insutypes) == 0 {
  14799. insutype = "310"
  14800. }
  14801. psn := &models.HisPsn{
  14802. PsnNo: res2.Output.Baseinfo.PsnNo,
  14803. PatientId: patient.ID,
  14804. Certno: res2.Output.Baseinfo.Certno,
  14805. Gend: res2.Output.Baseinfo.Gend,
  14806. Naty: res2.Output.Baseinfo.Naty,
  14807. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14808. PsnName: res2.Output.Baseinfo.PsnName,
  14809. Idetinfo: idetinfoStr,
  14810. Insuinfo: infoStr,
  14811. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14812. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14813. VerifyNumber: res.Output.EcToken,
  14814. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14815. }
  14816. if res.Output.MdtrtCertType == "01" {
  14817. psn.VerifyNumber = res.Output.EcToken
  14818. //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)
  14819. } else if res.Output.MdtrtCertType == "02" {
  14820. psn.VerifyNumber = res.Output.CardNo
  14821. //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)
  14822. } else if res.Output.MdtrtCertType == "03" {
  14823. psn.VerifyNumber = res.Output.MdtrtCertNo
  14824. //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)
  14825. }
  14826. service.CreateHisPsn(psn)
  14827. var balc float64
  14828. for _, item := range rf {
  14829. if item.Insutype == insutype {
  14830. balc = item.Balc
  14831. }
  14832. }
  14833. c.ServeSuccessJSON(map[string]interface{}{
  14834. "patient": patient,
  14835. "number": res.Output.CardNo,
  14836. "insutype": insutype,
  14837. "blac": balc,
  14838. "desc": idetinfoStr,
  14839. })
  14840. }
  14841. } else {
  14842. c.ServeSuccessJSON(map[string]interface{}{
  14843. "failed_code": -10,
  14844. "msg": res2.ErrMsg,
  14845. })
  14846. }
  14847. } else {
  14848. c.ServeSuccessJSON(map[string]interface{}{
  14849. "failed_code": -10,
  14850. "msg": res.ErrMsg,
  14851. })
  14852. }
  14853. } else if miConfig.MdtrtareaAdmvs == "420902" {
  14854. var res ResultTwo
  14855. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  14856. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14857. "&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)
  14858. resp, requestErr := http.Get(api)
  14859. if requestErr != nil {
  14860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14861. return
  14862. }
  14863. body, ioErr := ioutil.ReadAll(resp.Body)
  14864. if ioErr != nil {
  14865. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14867. return
  14868. }
  14869. var respJSON map[string]interface{}
  14870. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14871. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14873. return
  14874. }
  14875. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14876. result, _ := json.Marshal(respJSON)
  14877. fmt.Println("log")
  14878. fmt.Println(string(result))
  14879. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14880. utils.ErrorLog("解析失败:%v", err)
  14881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14882. return
  14883. }
  14884. if res.Infcode == 0 {
  14885. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14886. if err == gorm.ErrRecordNotFound {
  14887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14888. return
  14889. } else if err != nil {
  14890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14891. return
  14892. } else {
  14893. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14894. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14895. infoStr := string(Iinfos)
  14896. idetinfoStr := string(Idetinfos)
  14897. var rf []*ResultFive
  14898. json.Unmarshal([]byte(infoStr), &rf)
  14899. var insutypes []*ResultFive
  14900. var insutype string
  14901. var is390 int = 0
  14902. var is310 int = 0
  14903. for _, item := range rf {
  14904. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14905. insutypes = append(insutypes, item)
  14906. }
  14907. }
  14908. if len(insutypes) == 1 {
  14909. insutype = insutypes[0].Insutype
  14910. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14911. } else {
  14912. for _, i := range insutypes {
  14913. if i.Insutype == "390" {
  14914. is390 = 1
  14915. }
  14916. if i.Insutype == "310" {
  14917. is310 = 1
  14918. }
  14919. }
  14920. }
  14921. if is390 == 1 {
  14922. insutype = "390"
  14923. }
  14924. if is310 == 1 {
  14925. insutype = "310"
  14926. }
  14927. if len(insutypes) == 0 {
  14928. insutype = "390"
  14929. }
  14930. var insuplc_admdvs string
  14931. for _, item := range rf {
  14932. if item.Insutype == insutype {
  14933. insuplc_admdvs = item.InsuplcAdmdvs
  14934. }
  14935. }
  14936. psn := &models.HisPsn{
  14937. PsnNo: res.Output.Baseinfo.PsnNo,
  14938. PatientId: patient.ID,
  14939. Certno: res.Output.Baseinfo.Certno,
  14940. Gend: res.Output.Baseinfo.Gend,
  14941. Naty: res.Output.Baseinfo.Naty,
  14942. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14943. PsnName: res.Output.Baseinfo.PsnName,
  14944. Idetinfo: idetinfoStr,
  14945. Insuinfo: infoStr,
  14946. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14947. InsuplcAdmdvs: insuplc_admdvs,
  14948. }
  14949. service.CreateHisPsn(psn)
  14950. c.ServeSuccessJSON(map[string]interface{}{
  14951. "patient": patient,
  14952. "number": res.Output.Baseinfo.Certno,
  14953. })
  14954. }
  14955. } else {
  14956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14957. return
  14958. }
  14959. } else {
  14960. type ELeData struct {
  14961. Code string `json:"code"`
  14962. Data struct {
  14963. Aac002 string `json:"aac002"`
  14964. Aaz500 string `json:"aaz500"`
  14965. ActCardNo string `json:"actCardNo"`
  14966. Bab520 string `json:"bab520"`
  14967. Bkz543 string `json:"bkz543"`
  14968. BusinessType string `json:"businessType"`
  14969. CertfCodg string `json:"certfCodg"`
  14970. EcIndexNo string `json:"ecIndexNo"`
  14971. EcToken string `json:"ecToken"`
  14972. ID0000 string `json:"id0000"`
  14973. IDNo string `json:"idNo"`
  14974. IDType string `json:"idType"`
  14975. Idcode string `json:"idcode"`
  14976. IdentityToken string `json:"identity_token"`
  14977. InsuOrg string `json:"insuOrg"`
  14978. OfficeID string `json:"officeId"`
  14979. OfficeName string `json:"officeName"`
  14980. OperatorID string `json:"operatorId"`
  14981. OperatorName string `json:"operatorName"`
  14982. OrgID string `json:"orgId"`
  14983. UserName string `json:"userName"`
  14984. } `json:"data"`
  14985. Infno interface{} `json:"infno"`
  14986. Message string `json:"message"`
  14987. OrgID string `json:"orgId"`
  14988. TransType string `json:"transType"`
  14989. }
  14990. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  14991. fmt.Println(result)
  14992. outPutInfo := Remove0000(result)
  14993. fmt.Println(outPutInfo)
  14994. if len(outPutInfo) > 0 {
  14995. var ele ELeData
  14996. err := json.Unmarshal([]byte(outPutInfo), &ele)
  14997. if err != nil {
  14998. utils.ErrorLog("解析失败:%v", err)
  14999. }
  15000. token := ele.Data.EcToken
  15001. fmt.Println(outPutInfo)
  15002. 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)
  15003. saveLog(result, requestLog, "1101", "获取人员信息")
  15004. var dat map[string]interface{}
  15005. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15006. fmt.Println(dat)
  15007. } else {
  15008. fmt.Println(err)
  15009. }
  15010. userJSONBytes, _ := json.Marshal(dat)
  15011. var res ResultTwo
  15012. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15013. utils.ErrorLog("解析失败:%v", err)
  15014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15015. return
  15016. }
  15017. if res.Infcode == 0 {
  15018. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  15019. if err == gorm.ErrRecordNotFound {
  15020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15021. return
  15022. } else if err != nil {
  15023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15024. return
  15025. } else {
  15026. fmt.Println(res)
  15027. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15028. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15029. infoStr := string(Iinfos)
  15030. idetinfoStr := string(Idetinfos)
  15031. psn := &models.HisPsn{
  15032. PsnNo: res.Output.Baseinfo.PsnNo,
  15033. PatientId: patient.ID,
  15034. Certno: res.Output.Baseinfo.Certno,
  15035. Gend: res.Output.Baseinfo.Gend,
  15036. Naty: res.Output.Baseinfo.Naty,
  15037. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15038. PsnName: res.Output.Baseinfo.PsnName,
  15039. Idetinfo: idetinfoStr,
  15040. Insuinfo: infoStr,
  15041. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15042. CardInfo: outPutInfo,
  15043. VerifyNumber: token,
  15044. InsuplcAdmdvs: ele.Data.InsuOrg,
  15045. }
  15046. service.CreateHisPsn(psn)
  15047. var rf []*ResultFive
  15048. json.Unmarshal([]byte(infoStr), &rf)
  15049. var insutypes []*ResultFive
  15050. var insutype string
  15051. var is390 int = 0
  15052. var is310 int = 0
  15053. for _, item := range rf {
  15054. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15055. insutypes = append(insutypes, item)
  15056. }
  15057. }
  15058. if len(insutypes) == 1 {
  15059. insutype = insutypes[0].Insutype
  15060. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15061. } else {
  15062. for _, i := range insutypes {
  15063. if i.Insutype == "390" {
  15064. is390 = 1
  15065. }
  15066. if i.Insutype == "310" {
  15067. is310 = 1
  15068. }
  15069. }
  15070. }
  15071. if is390 == 1 {
  15072. insutype = "390"
  15073. }
  15074. if is310 == 1 {
  15075. insutype = "310"
  15076. }
  15077. if len(insutypes) == 0 {
  15078. insutype = "310"
  15079. }
  15080. c.ServeSuccessJSON(map[string]interface{}{
  15081. "patient": patient,
  15082. "number": token,
  15083. "insutype": insutype,
  15084. })
  15085. }
  15086. } else {
  15087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15088. return
  15089. }
  15090. }
  15091. //fmt.Println(result)
  15092. //
  15093. //if initFlag == 0 {
  15094. // c.TestGetBasBaseInit()
  15095. //}
  15096. //token := c.GetEleBaseInfo()
  15097. //
  15098. //token = Remove0000(token)
  15099. //
  15100. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  15101. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  15102. ////
  15103. //var res ResultTwo
  15104. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  15105. // utils.ErrorLog("解析失败:%v", err)
  15106. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15107. // return
  15108. //}
  15109. //
  15110. //if res.Infcode == 0 {
  15111. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15112. // if err == gorm.ErrRecordNotFound {
  15113. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15114. // return
  15115. // } else if err != nil {
  15116. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15117. // return
  15118. //
  15119. // } else {
  15120. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15121. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15122. // infoStr := string(Iinfos)
  15123. // idetinfoStr := string(Idetinfos)
  15124. //
  15125. //
  15126. //
  15127. //
  15128. // var rf []*ResultFive
  15129. // json.Unmarshal([]byte(infoStr), &rf)
  15130. //
  15131. // var insutypes []*ResultFive
  15132. // var insutype string
  15133. // var is390 int = 0
  15134. // var is310 int = 0
  15135. // var insuplc_admdvs string
  15136. //
  15137. // for _, item := range rf {
  15138. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15139. // insutypes = append(insutypes, item)
  15140. // }
  15141. // }
  15142. //
  15143. // if len(insutypes) == 1 {
  15144. // insutype = insutypes[0].Insutype
  15145. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15146. // } else {
  15147. // for _, i := range insutypes {
  15148. // if i.Insutype == "390" {
  15149. // is390 = 1
  15150. // }
  15151. //
  15152. // if i.Insutype == "310" {
  15153. // is310 = 1
  15154. // }
  15155. // }
  15156. // }
  15157. // if is390 == 1 {
  15158. // insutype = "390"
  15159. // }
  15160. //
  15161. // if is310 == 1 {
  15162. // insutype = "310"
  15163. // }
  15164. // if len(insutypes) == 0 {
  15165. // insutype = "310"
  15166. // }
  15167. // for _, item := range rf {
  15168. // if item.Insutype == insutype {
  15169. // insuplc_admdvs = item.InsuplcAdmdvs
  15170. // }
  15171. // }
  15172. // psn := &models.HisPsn{
  15173. // PsnNo: res.Output.Baseinfo.PsnNo,
  15174. // Age: res.Output.Baseinfo.Age,
  15175. // PatientId: patient.ID,
  15176. // Certno: res.Output.Baseinfo.Certno,
  15177. // Brdy: res.Output.Baseinfo.Brdy,
  15178. // Gend: res.Output.Baseinfo.Gend,
  15179. // Naty: res.Output.Baseinfo.Naty,
  15180. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  15181. // PsnName: res.Output.Baseinfo.PsnName,
  15182. // Idetinfo: idetinfoStr,
  15183. // Insuinfo: infoStr,
  15184. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15185. // CardInfo: "",
  15186. // VerifyNumber: token,
  15187. // InsuplcAdmdvs: insuplc_admdvs,
  15188. // }
  15189. // service.CreateHisPsn(psn)
  15190. //
  15191. // c.ServeSuccessJSON(map[string]interface{}{
  15192. // "patient": patient,
  15193. // "number": token,
  15194. // })
  15195. // }
  15196. //} else {
  15197. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15198. // return
  15199. //}
  15200. }
  15201. break
  15202. case 5:
  15203. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15204. var api string
  15205. if miConfig.MdtrtareaAdmvs == "320921" {
  15206. 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 +
  15207. "&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
  15208. fmt.Println(api)
  15209. } else {
  15210. 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 +
  15211. "&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)
  15212. }
  15213. resp, requestErr := http.Get(api)
  15214. if requestErr != nil {
  15215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15216. return
  15217. }
  15218. body, ioErr := ioutil.ReadAll(resp.Body)
  15219. if ioErr != nil {
  15220. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15222. return
  15223. }
  15224. var respJSON map[string]interface{}
  15225. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15226. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15228. return
  15229. }
  15230. var status string
  15231. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15232. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15233. var token string
  15234. var res ResultTwo //1101结果
  15235. var res10265 ResultTwo10265 //1101结果
  15236. if status == "0" { //读卡成功
  15237. var card_info string //卡信息
  15238. //var busi_card_info string
  15239. var auth_info string
  15240. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15241. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15242. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15243. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  15244. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15245. result, _ := json.Marshal(respJSON)
  15246. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15247. utils.ErrorLog("解析失败:%v", err)
  15248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15249. return
  15250. }
  15251. res.ErrMsg = res10265.ErrMsg
  15252. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15253. res.Infcode = infocode
  15254. res.Output = res10265.Output
  15255. res.InfRefmsgid = res10265.InfRefmsgid
  15256. if res.Infcode == 0 {
  15257. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15258. if err == gorm.ErrRecordNotFound {
  15259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15260. return
  15261. } else if err != nil {
  15262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15263. return
  15264. } else {
  15265. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15266. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15267. infoStr := string(Iinfos)
  15268. idetinfoStr := string(Idetinfos)
  15269. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  15270. psn := &models.HisPsn{
  15271. PsnNo: res.Output.Baseinfo.PsnNo,
  15272. PatientId: patient.ID,
  15273. Certno: res.Output.Baseinfo.Certno,
  15274. Gend: res.Output.Baseinfo.Gend,
  15275. Brdy: b,
  15276. Age: float64(age),
  15277. Naty: res.Output.Baseinfo.Naty,
  15278. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15279. PsnName: res.Output.Baseinfo.PsnName,
  15280. Idetinfo: idetinfoStr,
  15281. Insuinfo: infoStr,
  15282. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15283. CardInfo: card_info,
  15284. VerifyNumber: token,
  15285. AuthInfo: auth_info,
  15286. }
  15287. var rf []*ResultFive
  15288. json.Unmarshal([]byte(infoStr), &rf)
  15289. var insutypes []*ResultFive
  15290. var insutype string
  15291. var is390 int = 0
  15292. var is310 int = 0
  15293. for _, item := range rf {
  15294. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15295. insutypes = append(insutypes, item)
  15296. }
  15297. }
  15298. if len(insutypes) == 1 {
  15299. insutype = insutypes[0].Insutype
  15300. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15301. } else {
  15302. for _, i := range insutypes {
  15303. if i.Insutype == "390" {
  15304. is390 = 1
  15305. }
  15306. if i.Insutype == "310" {
  15307. is310 = 1
  15308. }
  15309. }
  15310. }
  15311. if is390 == 1 {
  15312. insutype = "390"
  15313. }
  15314. if is310 == 1 {
  15315. insutype = "310"
  15316. }
  15317. if len(insutypes) == 0 {
  15318. insutype = "310"
  15319. }
  15320. service.CreateHisPsn(psn)
  15321. c.ServeSuccessJSON(map[string]interface{}{
  15322. "patient": patient,
  15323. "number": token,
  15324. "insutype": insutype,
  15325. })
  15326. }
  15327. } else {
  15328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15329. return
  15330. }
  15331. } else { //读卡失败
  15332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15333. return
  15334. }
  15335. }
  15336. break
  15337. }
  15338. }
  15339. var initFlag int64 = 0
  15340. var initEleFlag int64 = 0
  15341. func (c *HisApiController) TestGetBasBaseInit() {
  15342. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15343. Iinit := DllDef.MustFindProc("Init")
  15344. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15345. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  15346. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  15347. if ret != 0 {
  15348. fmt.Println("SSCard的报错原因:", err)
  15349. fmt.Println("SSCard的运算结果为:", ret)
  15350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15351. return
  15352. }
  15353. result := int(ret)
  15354. fmt.Println("SSCard的运算结果为1:", result)
  15355. initFlag = 1
  15356. return
  15357. }
  15358. func (c *HisApiController) HandleJiangXiReadCard() {
  15359. fmt.Println("~~~~~~")
  15360. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15361. admin_user_id, _ := c.GetInt64("admin_user_id")
  15362. id_card_type, _ := c.GetInt64("id_card_type")
  15363. //certificates, _ := c.GetInt64("certificates")
  15364. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  15365. if initFlag == 0 {
  15366. c.TestGetJiangXiBasBaseInit()
  15367. }
  15368. basStr := c.GetBasBaseInfo()
  15369. if len(basStr) == 0 {
  15370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15371. return
  15372. }
  15373. fmt.Println(basStr)
  15374. bas := strings.Split(basStr, "|")
  15375. basNumber := bas[1]
  15376. fmt.Println(basNumber)
  15377. card_sn := bas[3]
  15378. fmt.Println(card_sn)
  15379. 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, "")
  15380. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  15381. var dat map[string]interface{}
  15382. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15383. fmt.Println(dat)
  15384. } else {
  15385. fmt.Println(err)
  15386. }
  15387. userJSONBytes, _ := json.Marshal(dat)
  15388. var res ResultTwo
  15389. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15390. utils.ErrorLog("解析失败:%v", err)
  15391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15392. return
  15393. }
  15394. if res.Infcode == 0 {
  15395. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  15396. if err == gorm.ErrRecordNotFound {
  15397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15398. return
  15399. } else if err != nil {
  15400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15401. return
  15402. } else {
  15403. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15404. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15405. infoStr := string(Iinfos)
  15406. idetinfoStr := string(Idetinfos)
  15407. psn := &models.HisPsn{
  15408. PsnNo: res.Output.Baseinfo.PsnNo,
  15409. PatientId: patient.ID,
  15410. Certno: res.Output.Baseinfo.Certno,
  15411. Gend: res.Output.Baseinfo.Gend,
  15412. Naty: res.Output.Baseinfo.Naty,
  15413. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15414. PsnName: res.Output.Baseinfo.PsnName,
  15415. Idetinfo: idetinfoStr,
  15416. Insuinfo: infoStr,
  15417. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15418. CardInfo: basStr,
  15419. VerifyNumber: "",
  15420. }
  15421. service.CreateHisPsn(psn)
  15422. c.ServeSuccessJSON(map[string]interface{}{
  15423. "patient": patient,
  15424. "number": basNumber,
  15425. })
  15426. }
  15427. } else {
  15428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15429. return
  15430. }
  15431. }
  15432. func (c *HisApiController) TestGetHnBasBaseInit() {
  15433. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15434. Iinit := DllDef.MustFindProc("Init")
  15435. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15436. //http://10.77.211.236/CSB/hsa-fsi-1303
  15437. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  15438. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  15439. // 调用 Init 函数
  15440. 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"))))
  15441. //if ret != 0 {
  15442. fmt.Println("SSCard的报错原因:", err)
  15443. fmt.Println("SSCard的运算结果为:", ret)
  15444. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15445. // return
  15446. //}
  15447. result := int(ret)
  15448. fmt.Println("SSCard的运算结果为1:", result)
  15449. initFlag = 1
  15450. return
  15451. }
  15452. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  15453. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15454. Iinit := DllDef.MustFindProc("Init")
  15455. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15456. //http://10.77.211.236/CSB/hsa-fsi-1303
  15457. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360302"))
  15458. if ret != 0 {
  15459. fmt.Println("SSCard的报错原因:", err)
  15460. fmt.Println("SSCard的运算结果为:", ret)
  15461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15462. return
  15463. }
  15464. result := int(ret)
  15465. fmt.Println("SSCard的运算结果为1:", result)
  15466. initFlag = 1
  15467. return
  15468. }
  15469. func (c *HisApiController) GetSFZBaseInfo() string {
  15470. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15471. readCard := DllDef.MustFindProc("ReadSFZ")
  15472. if readCard == nil {
  15473. fmt.Println("readcard is nil")
  15474. readCard = DllDef.MustFindProc("ReadSFZ")
  15475. }
  15476. str := make([]byte, 8096)
  15477. str1 := make([]byte, 8096)
  15478. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  15479. fmt.Println(r)
  15480. return Remove0000(string(str))
  15481. }
  15482. func (c *HisApiController) GetEleBaseInfo() string {
  15483. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15484. readCard := DllDef.MustFindProc("GetQRBase")
  15485. fmt.Println(readCard)
  15486. if readCard == nil {
  15487. fmt.Println("readcard is nil")
  15488. readCard = DllDef.MustFindProc("GetQRBase")
  15489. }
  15490. str := make([]byte, 1024)
  15491. str1 := make([]byte, 1024)
  15492. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  15493. fmt.Println(ret2)
  15494. fmt.Println(string(str1))
  15495. fmt.Println(string(str))
  15496. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  15497. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  15498. if ret2 != 0 {
  15499. return ""
  15500. }
  15501. return string(str)
  15502. }
  15503. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  15504. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  15505. readCard := DllDef.MustFindProc("NationEcTrans")
  15506. fmt.Println(readCard)
  15507. fmt.Println("!!!!!")
  15508. pBusiCardInfo := make([]byte, 2048)
  15509. input := make(map[string]interface{})
  15510. inputData := make(map[string]interface{})
  15511. inputData["orgId"] = code
  15512. inputData["businessType"] = "01101"
  15513. inputData["operatorId"] = "1"
  15514. inputData["operatorName"] = "admin"
  15515. inputData["officeId"] = "001"
  15516. inputData["officeName"] = "血透室"
  15517. inputData["deviceType"] = ""
  15518. input["data"] = inputData
  15519. input["orgId"] = code
  15520. input["transType"] = "ec.query"
  15521. bytesData, _ := json.Marshal(input)
  15522. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  15523. fmt.Println(ret2)
  15524. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  15525. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  15526. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  15527. }
  15528. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  15529. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  15530. readCard := DllDef.MustFindProc("NationEcTrans")
  15531. fmt.Println(readCard)
  15532. fmt.Println("!!!!!")
  15533. pBusiCardInfo := make([]byte, 2048)
  15534. input := make(map[string]interface{})
  15535. inputData := make(map[string]interface{})
  15536. inputData["orgId"] = code
  15537. inputData["businessType"] = "01101"
  15538. inputData["operatorId"] = "9"
  15539. inputData["operatorName"] = "admin"
  15540. inputData["officeId"] = "001"
  15541. inputData["officeName"] = "血透室"
  15542. inputData["deviceType"] = ""
  15543. input["data"] = inputData
  15544. input["orgId"] = code
  15545. input["transType"] = "ec.query"
  15546. bytesData, _ := json.Marshal(input)
  15547. 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])))
  15548. fmt.Println(ret2)
  15549. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  15550. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  15551. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  15552. }
  15553. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  15554. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  15555. readCard := DllDef.MustFindProc("NationEcTrans")
  15556. fmt.Println(readCard)
  15557. fmt.Println("!!!!!")
  15558. pBusiCardInfo := make([]byte, 2048)
  15559. input := make(map[string]interface{})
  15560. inputData := make(map[string]interface{})
  15561. inputData["orgId"] = code
  15562. inputData["businessType"] = "01301"
  15563. inputData["operatorId"] = "9"
  15564. inputData["operatorName"] = "admin"
  15565. inputData["officeId"] = "001"
  15566. inputData["officeName"] = "血透室"
  15567. inputData["deviceType"] = ""
  15568. input["data"] = inputData
  15569. input["orgId"] = code
  15570. input["transType"] = "ec.query"
  15571. bytesData, _ := json.Marshal(input)
  15572. 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])))
  15573. fmt.Println(ret2)
  15574. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  15575. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  15576. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  15577. }
  15578. func GetJxEleBaseInfo(org_id int64) string {
  15579. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15580. readCard := DllDef.MustFindProc("NationEcTrans")
  15581. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  15582. if readCard == nil {
  15583. fmt.Println("readcard is nil")
  15584. readCard = DllDef.MustFindProc("NationEcTrans")
  15585. }
  15586. str1 := make([]byte, 1024)
  15587. data := make(map[string]interface{})
  15588. inputData := make(map[string]interface{})
  15589. inputData["orgId"] = miConfig.Code
  15590. inputData["businessType"] = "01101"
  15591. inputData["operatorId"] = "test001"
  15592. inputData["operatorName"] = "cn"
  15593. inputData["officeId"] = "32760"
  15594. inputData["officeName"] = "waike"
  15595. inputData["deviceType"] = ""
  15596. data["data"] = inputData
  15597. data["transType"] = "ec.query"
  15598. data["extra "] = ""
  15599. data["orgId"] = miConfig.Code
  15600. bytesData, _ := json.Marshal(data)
  15601. //bytesData, _ := json.Marshal(data)
  15602. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  15603. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  15604. fmt.Println(ret2)
  15605. fmt.Println(string(str1))
  15606. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  15607. if ret2 != 0 {
  15608. return ""
  15609. }
  15610. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  15611. }
  15612. //func GetJxEleBaseInfoTWO(org_id int64) string {
  15613. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  15614. // readCard := DllDef.MustFindProc("NationEcTrans")
  15615. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  15616. //
  15617. // if readCard == nil {
  15618. // fmt.Println("readcard is nil")
  15619. // readCard = DllDef.MustFindProc("NationEcTrans")
  15620. // }
  15621. // str1 := make([]byte, 1024)
  15622. //
  15623. // data := make(map[string]interface{})
  15624. //
  15625. // inputData := make(map[string]interface{})
  15626. // inputData["orgId"] = miConfig.Code
  15627. // inputData["businessType"] = "01101"
  15628. // inputData["operatorId"] = "test001"
  15629. // inputData["operatorName"] = "cn"
  15630. // inputData["officeId"] = "32760"
  15631. // inputData["officeName"] = "waike"
  15632. // inputData["deviceType"] = ""
  15633. //
  15634. // data["data"] = inputData
  15635. // data["transType"] = "ec.query"
  15636. // data["extra "] = ""
  15637. // data["orgId"] = miConfig.Code
  15638. // bytesData, _ := json.Marshal(data)
  15639. // //bytesData, _ := json.Marshal(data)
  15640. //
  15641. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  15642. //
  15643. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  15644. // fmt.Println(ret2)
  15645. // fmt.Println(string(str1))
  15646. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  15647. //
  15648. // if ret2 != 0 {
  15649. // return ""
  15650. // }
  15651. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  15652. //}
  15653. func GetJxEleBaseInitInfo(org_id int64) string {
  15654. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15655. readCard := DllDef.MustFindProc("NationEcTrans")
  15656. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  15657. if readCard == nil {
  15658. fmt.Println("readcard is nil")
  15659. readCard = DllDef.MustFindProc("NationEcTrans")
  15660. }
  15661. str1 := make([]byte, 2048)
  15662. data := make(map[string]interface{})
  15663. inputData := make(map[string]interface{})
  15664. inputData["orgId"] = miConfig.Code
  15665. inputData["businessType"] = "01101"
  15666. inputData["operatorId"] = "1"
  15667. inputData["operatorName"] = "huangchuang"
  15668. inputData["officeId"] = "101"
  15669. inputData["officeName"] = "xuetou"
  15670. inputData["deviceType"] = ""
  15671. data["data"] = inputData
  15672. data["transType"] = "ec.query"
  15673. data["orgId"] = miConfig.Code
  15674. bytesData, _ := json.Marshal(data)
  15675. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  15676. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  15677. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  15678. fmt.Println(ret2)
  15679. fmt.Println(string(str1))
  15680. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  15681. if ret2 != 0 {
  15682. return ""
  15683. }
  15684. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  15685. initEleFlag = 1
  15686. }
  15687. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  15688. }
  15689. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  15690. // // 构建命令
  15691. // cmd := exec.Command("python", "b.py")
  15692. //
  15693. // // 执行命令并等待完成
  15694. // output, err := cmd.CombinedOutput()
  15695. // if err != nil {
  15696. // fmt.Println("Error executing Python script:", err)
  15697. // return
  15698. // }
  15699. //
  15700. // // 打印Python脚本的输出
  15701. // fmt.Println(string(output))
  15702. //}
  15703. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  15704. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  15705. readCard := DllDef.MustFindProc("gxyb_call")
  15706. if readCard == nil {
  15707. fmt.Println("readcard is nil")
  15708. readCard = DllDef.MustFindProc("gxyb_call")
  15709. }
  15710. str := make([]byte, 1024)
  15711. str1 := make([]byte, 1024)
  15712. //data := make(map[string]interface{})
  15713. currentTime := time.Now()
  15714. // 格式化时间为 "YYYYMMDDHH24MISS"
  15715. formattedTime := currentTime.Format("20060102150405")
  15716. inputData := make(map[string]interface{})
  15717. inputData2 := make(map[string]interface{})
  15718. inputData["transNo"] = "1401"
  15719. inputData["transType"] = "passwordCheck"
  15720. inputData["timestamp"] = formattedTime
  15721. inputData2["fixmedinsCode"] = code
  15722. inputData2["psnNo"] = ""
  15723. inputData["data"] = inputData2
  15724. jsonBytes, err := json.Marshal(inputData)
  15725. if err != nil {
  15726. fmt.Println("Error encoding map to JSON:", err)
  15727. }
  15728. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  15729. fmt.Println(string(str1))
  15730. fmt.Println(string(str))
  15731. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  15732. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  15733. if ret2 != 0 {
  15734. return ""
  15735. }
  15736. return string(str)
  15737. }
  15738. func (c *HisApiController) GetoleInfo() Response {
  15739. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  15740. defer ole.CoUninitialize()
  15741. // Replace with the ProgID or CLSID of your COM object
  15742. progID := "YinHai.XJ.Actual.Interface.New"
  15743. // Create COM object
  15744. unknown, err := oleutil.CreateObject(progID)
  15745. if err != nil {
  15746. fmt.Println("Unable to create COM object:", err)
  15747. }
  15748. defer unknown.Release()
  15749. // Query for the IDispatch interface
  15750. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  15751. if err != nil {
  15752. fmt.Println("Unable to get IDispatch interface:", err)
  15753. }
  15754. defer dispatch.Release()
  15755. // Prepare parameters
  15756. transNo := "1401"
  15757. transType := "passwordCheck"
  15758. timestamp := time.Now().Unix()
  15759. fixmedinsCode := "H45072101171"
  15760. psnNo := ""
  15761. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  15762. result2 := ""
  15763. // Call COM object's method using the IDispatch interface
  15764. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  15765. fmt.Println(resulr)
  15766. fmt.Println(result2)
  15767. if err != nil {
  15768. fmt.Println("调用COM对象方法失败:", err)
  15769. }
  15770. var response Response
  15771. err2 := json.Unmarshal([]byte(result2), &response)
  15772. if err2 != nil {
  15773. fmt.Println("解析JSON失败:", err)
  15774. }
  15775. return response
  15776. }
  15777. func (c *HisApiController) GetBasBaseInfo() string {
  15778. DllDef := syscall.MustLoadDLL("SSCard.dll")
  15779. readCard := DllDef.MustFindProc("ReadCardBas")
  15780. if readCard == nil {
  15781. fmt.Println("readcard is nil")
  15782. readCard = DllDef.MustFindProc("ReadCardBas")
  15783. }
  15784. str := make([]byte, 1024)
  15785. str1 := make([]byte, 1024)
  15786. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  15787. fmt.Println(string(str1))
  15788. fmt.Println(string(str))
  15789. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  15790. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  15791. if ret2 != 0 {
  15792. return ""
  15793. }
  15794. return string(str)
  15795. }
  15796. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  15797. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  15798. readCard := DllDef.MustFindProc("read_cardinfo")
  15799. if readCard == nil {
  15800. fmt.Println("readcard is nil")
  15801. readCard = DllDef.MustFindProc("read_cardinfo")
  15802. }
  15803. str := make([]byte, 1024) //卡号
  15804. str1 := make([]byte, 1024) //卡识别码
  15805. str2 := make([]byte, 1024) //身份证号
  15806. str3 := make([]byte, 1024) //姓名
  15807. str4 := make([]byte, 1024) //错误信息
  15808. 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])))
  15809. fmt.Println(string(str1))
  15810. fmt.Println(string(str))
  15811. fmt.Println(string(str2))
  15812. fmt.Println(string(str3))
  15813. fmt.Println(string(str4))
  15814. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  15815. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  15816. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  15817. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  15818. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  15819. if ret2 != 0 {
  15820. return "", "", "", "", ""
  15821. }
  15822. return string(str), string(str1), string(str2), string(str3), string(str4)
  15823. }
  15824. type CustomFundPay struct {
  15825. FundPayType string `json:"fund_pay_type"`
  15826. FundPayamt float64 `json:"fund_payamt"`
  15827. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15828. }
  15829. //func (c *HisApiController) GetBatchSettleList() {
  15830. // start_time_str := c.GetString("start_time")
  15831. // //end_time_str := c.GetString("end_time")
  15832. // admin_user_id, _ := c.GetInt64("admin_user_id")
  15833. //
  15834. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  15835. //
  15836. // for _, item := range orders {
  15837. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  15838. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  15839. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  15840. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  15841. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  15842. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  15843. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15844. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  15845. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  15846. //
  15847. // if order.ID == 0 {
  15848. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  15849. // return
  15850. // }
  15851. //
  15852. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  15853. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  15854. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  15855. // //fmt.Println(count)
  15856. // //var zero string
  15857. // //number := count + 1
  15858. // //if number >= 1000 {
  15859. // // zero = "0000" + strconv.FormatInt(number, 10)
  15860. // //} else if number >= 10000 {
  15861. // // zero = "000" + strconv.FormatInt(number, 10)
  15862. // //} else if number >= 100000 {
  15863. // // zero = "00" + strconv.FormatInt(number, 10)
  15864. // //} else if number >= 1000000 {
  15865. // // zero = "0" + strconv.FormatInt(number, 10)
  15866. // //} else {
  15867. // // zero = strconv.FormatInt(number, 10)
  15868. // //}
  15869. // //fmt.Println(zero)
  15870. //
  15871. // struct4101 := service.Struct4101{
  15872. // PsnNo: order.PsnNo,
  15873. // MdtrtId: order.MdtrtId,
  15874. // SetlId: order.SetlId,
  15875. // PsnName: order.PsnName,
  15876. // Gend: order.Gend,
  15877. // Brdy: his.Brdy,
  15878. // Age: his.Age,
  15879. // Naty: order.Naty,
  15880. // PatnCertType: "01",
  15881. // Certno: order.Certno,
  15882. // Prfs: "90",
  15883. // ConerName: roles[0].UserName,
  15884. // PatnRlts: "99",
  15885. // ConerAddr: miConfig.OrgName,
  15886. // ConerTel: admin.Mobile,
  15887. // HiType: order.Insutype,
  15888. // Insuplc: miConfig.InsuplcAdmdvs,
  15889. // MaindiagFlag: "1",
  15890. // BillCode: order.SetlId,
  15891. // BillNo: order.SetlId,
  15892. // BizSn: order.Number,
  15893. // PsnSelfPay: order.PsnPartAmt,
  15894. // PsnOwnPay: order.PsnPartAmt,
  15895. // AcctPay: order.AcctPay,
  15896. // PsnCashpay: order.PsnCashPay,
  15897. // HiPaymtd: "1",
  15898. // Hsorg: miConfig.InsuplcAdmdvs,
  15899. // HsorgOpter: miConfig.InsuplcAdmdvs,
  15900. // MedinsFillPsn: curRoles.UserName,
  15901. // MedinsFillDept: miConfig.OrgName,
  15902. // IptMedType: "2",
  15903. // }
  15904. // struct4101.SetlBegnDate = order.SetlTime
  15905. // struct4101.SetlEndDate = order.SetlTime
  15906. // time_arr := strings.Split(order.SetlTime, " ")
  15907. // struct4101.AdmTime = time_arr[0]
  15908. // struct4101.AdmEndTime = time_arr[0]
  15909. //
  15910. // var rf []CustomFundPay
  15911. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  15912. //
  15913. // var tempFunPays []service.CustomStruct
  15914. // for _, item := range rf {
  15915. // var tempFunPay service.CustomStruct
  15916. // tempFunPay.FundPayamt = item.FundPayamt
  15917. // tempFunPay.FundPayType = item.FundPayType
  15918. // tempFunPays = append(tempFunPays, tempFunPay)
  15919. // }
  15920. // struct4101.CustomStruct = tempFunPays
  15921. //
  15922. // var tempDiaginfos []service.DiaginfoStructTwo
  15923. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  15924. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  15925. //
  15926. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  15927. // var config []*models.HisXtDiagnoseConfig
  15928. // for _, item := range diagnosis_ids {
  15929. // id, _ := strconv.ParseInt(item, 10, 64)
  15930. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  15931. // config = append(config, &diagnosisConfig)
  15932. // }
  15933. //
  15934. // for index, item := range config {
  15935. // if index == 0 {
  15936. // var tempDiaginfo service.DiaginfoStructTwo
  15937. // tempDiaginfo.DiagCode = item.CountryCode
  15938. // tempDiaginfo.DiagName = item.CountryContentName
  15939. // tempDiaginfo.DiagType = "1"
  15940. // tempDiaginfo.MaindiagFlag = "1"
  15941. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  15942. // } else {
  15943. // var tempDiaginfo service.DiaginfoStructTwo
  15944. // tempDiaginfo.DiagCode = item.CountryCode
  15945. // tempDiaginfo.DiagName = item.CountryContentName
  15946. // tempDiaginfo.DiagType = "1"
  15947. // tempDiaginfo.MaindiagFlag = "0"
  15948. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  15949. // }
  15950. // }
  15951. // struct4101.Diseinfo = tempDiaginfos
  15952. //
  15953. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  15954. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  15955. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  15956. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  15957. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  15958. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  15959. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  15960. //
  15961. // var iteminfo service.IteminfoStruct
  15962. //
  15963. // var bedCostTotal float64 = 0 //床位总费
  15964. // var bedCostSelfTotal float64 = 0 //床位自费
  15965. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  15966. //
  15967. // var operationCostTotal float64 = 0 //手术费
  15968. // var operationCostSelfTotal float64 = 0 //手术费
  15969. // var operationCostPartSelfTotal float64 = 0 //手术费
  15970. //
  15971. // var otherCostTotal float64 = 0 //其他费用
  15972. // var otherCostSelfTotal float64 = 0 //其他费用
  15973. // var otherCostPartSelfTotal float64 = 0 //其他费用
  15974. //
  15975. // var materialCostTotal float64 = 0 //材料费
  15976. // var materialCostSelfTotal float64 = 0 //材料费
  15977. // var materialCostPartSelfTotal float64 = 0 //材料费
  15978. //
  15979. // var westernMedicineCostTotal float64 = 0 //西药费
  15980. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  15981. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  15982. //
  15983. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  15984. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  15985. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  15986. //
  15987. // var checkCostTotal float64 = 0 //检查费
  15988. // var checkCostSelfTotal float64 = 0 //检查费
  15989. // var checkCostPartSelfTotal float64 = 0 //检查费
  15990. //
  15991. // var laboratoryCostTotal float64 = 0 //化验费
  15992. // var laboratoryCostSelfTotal float64 = 0 //化验费
  15993. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  15994. //
  15995. // var treatCostTotal float64 = 0 //治疗费用
  15996. // var treatCostSelfTotal float64 = 0 //治疗费用
  15997. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  15998. //
  15999. // decimal.DivisionPrecision = 2
  16000. //
  16001. // var bed_fulamt_ownpay_amt float64 = 0
  16002. // var operation_fulamt_ownpay_amt float64 = 0
  16003. // var other_fulamt_ownpay_amt float64 = 0
  16004. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  16005. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  16006. // var check_fulamt_ownpay_amt float64 = 0
  16007. // var material_fulamt_ownpay_amt float64 = 0
  16008. // var laboratory_fulamt_ownpay_amt float64 = 0
  16009. // var treat_fulamt_ownpay_amt float64 = 0
  16010. //
  16011. // var bed_claa_sunmfee float64 = 0
  16012. // var bed_clab_amt float64 = 0
  16013. // var bed_other_amt float64 = 0
  16014. //
  16015. // var operation_claa_sunmfee float64 = 0
  16016. // var operation_clab_amt float64 = 0
  16017. // var operation_other_amt float64 = 0
  16018. //
  16019. // var other_claa_sunmfee float64 = 0
  16020. // var other_clab_amt float64 = 0
  16021. // var other_other_amt float64 = 0
  16022. //
  16023. // var westernMedicine_claa_sunmfee float64 = 0
  16024. // var westernMedicine_clab_amt float64 = 0
  16025. // var westernMedicine_other_amt float64 = 0
  16026. //
  16027. // var chineseTraditional_claa_sunmfee float64 = 0
  16028. // var chineseTraditional_clab_amt float64 = 0
  16029. // var chineseTraditional_other_amt float64 = 0
  16030. //
  16031. // var check_claa_sunmfee float64 = 0
  16032. // var check_clab_amt float64 = 0
  16033. // var check_other_amt float64 = 0
  16034. //
  16035. // var material_claa_sunmfee float64 = 0
  16036. // var material_clab_amt float64 = 0
  16037. // var material_other_amt float64 = 0
  16038. //
  16039. // var laboratory_claa_sunmfee float64 = 0
  16040. // var laboratory_clab_amt float64 = 0
  16041. // var laboratory_other_amt float64 = 0
  16042. //
  16043. // var treat_claa_sunmfee float64 = 0
  16044. // var treat_clab_amt float64 = 0
  16045. // var treat_other_amt float64 = 0
  16046. //
  16047. // for _, item := range order.HisOrderInfo {
  16048. // if item.MedChrgitmType == "01" { //床位费
  16049. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16050. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16051. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16052. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16053. // if item.ChrgitmLv == "1" {
  16054. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16055. // }
  16056. // if item.ChrgitmLv == "2" {
  16057. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16058. //
  16059. // }
  16060. // if item.ChrgitmLv == "3" {
  16061. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16062. // }
  16063. //
  16064. // }
  16065. //
  16066. // if item.MedChrgitmType == "03" { //检查费
  16067. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16068. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16069. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16070. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16071. // if item.ChrgitmLv == "1" {
  16072. //
  16073. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16074. //
  16075. // }
  16076. // if item.ChrgitmLv == "2" {
  16077. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16078. //
  16079. // }
  16080. // if item.ChrgitmLv == "3" {
  16081. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16082. // }
  16083. // }
  16084. //
  16085. // if item.MedChrgitmType == "04" { //化验费
  16086. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16087. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16088. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16089. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16090. // if item.ChrgitmLv == "1" {
  16091. //
  16092. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16093. //
  16094. // }
  16095. // if item.ChrgitmLv == "2" {
  16096. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16097. //
  16098. // }
  16099. // if item.ChrgitmLv == "3" {
  16100. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16101. // }
  16102. // }
  16103. //
  16104. // if item.MedChrgitmType == "05" { //治疗费
  16105. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16106. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16107. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16108. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16109. // if item.ChrgitmLv == "1" {
  16110. //
  16111. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16112. //
  16113. // }
  16114. // if item.ChrgitmLv == "2" {
  16115. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16116. //
  16117. // }
  16118. // if item.ChrgitmLv == "3" {
  16119. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16120. // }
  16121. // }
  16122. //
  16123. // if item.MedChrgitmType == "06" { //手术费
  16124. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16125. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16126. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16127. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16128. //
  16129. // if item.ChrgitmLv == "1" {
  16130. //
  16131. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16132. //
  16133. // }
  16134. // if item.ChrgitmLv == "2" {
  16135. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16136. //
  16137. // }
  16138. // if item.ChrgitmLv == "3" {
  16139. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16140. // }
  16141. // }
  16142. //
  16143. // if item.MedChrgitmType == "08" { //材料费
  16144. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16145. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16146. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16147. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16148. // if item.ChrgitmLv == "1" {
  16149. //
  16150. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16151. //
  16152. // }
  16153. // if item.ChrgitmLv == "2" {
  16154. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16155. //
  16156. // }
  16157. // if item.ChrgitmLv == "3" {
  16158. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16159. // }
  16160. // }
  16161. //
  16162. // if item.MedChrgitmType == "09" { //西药费
  16163. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16164. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16165. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16166. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16167. // if item.ChrgitmLv == "1" {
  16168. //
  16169. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16170. //
  16171. // }
  16172. // if item.ChrgitmLv == "2" {
  16173. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16174. //
  16175. // }
  16176. // if item.ChrgitmLv == "3" {
  16177. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16178. // }
  16179. // }
  16180. //
  16181. // if item.MedChrgitmType == "11" { //中成费
  16182. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16183. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16184. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16185. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16186. // if item.ChrgitmLv == "1" {
  16187. //
  16188. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16189. //
  16190. // }
  16191. // if item.ChrgitmLv == "2" {
  16192. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16193. //
  16194. // }
  16195. // if item.ChrgitmLv == "3" {
  16196. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16197. // }
  16198. // }
  16199. //
  16200. // if item.MedChrgitmType == "14" { //其他费
  16201. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16202. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16203. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16204. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16205. // if item.ChrgitmLv == "1" {
  16206. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16207. //
  16208. // }
  16209. // if item.ChrgitmLv == "2" {
  16210. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16211. //
  16212. // }
  16213. // if item.ChrgitmLv == "3" {
  16214. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16215. // }
  16216. // }
  16217. //
  16218. // }
  16219. //
  16220. // var iteminfoStructs []service.IteminfoStruct
  16221. //
  16222. // if bedCostTotal != 0 {
  16223. // iteminfo.MedChrgitm = "01"
  16224. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  16225. // iteminfo.Amt = bedCostTotal
  16226. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  16227. // iteminfo.ClabAmt = bed_clab_amt
  16228. // iteminfo.OthAmt = bed_other_amt
  16229. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16230. // }
  16231. //
  16232. // if checkCostTotal != 0 {
  16233. // iteminfo.MedChrgitm = "03"
  16234. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  16235. // iteminfo.Amt = checkCostTotal
  16236. // iteminfo.ClaaSumfee = check_claa_sunmfee
  16237. // iteminfo.ClabAmt = check_clab_amt
  16238. // iteminfo.OthAmt = check_other_amt
  16239. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16240. //
  16241. // }
  16242. //
  16243. // if laboratoryCostTotal != 0 {
  16244. // iteminfo.MedChrgitm = "04"
  16245. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  16246. // iteminfo.Amt = laboratoryCostTotal
  16247. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  16248. // iteminfo.ClabAmt = laboratory_clab_amt
  16249. // iteminfo.OthAmt = laboratory_other_amt
  16250. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16251. //
  16252. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16253. //
  16254. // }
  16255. //
  16256. // if treatCostTotal != 0 {
  16257. // iteminfo.MedChrgitm = "05"
  16258. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  16259. // iteminfo.Amt = treatCostTotal
  16260. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  16261. // iteminfo.ClabAmt = treat_clab_amt
  16262. // iteminfo.OthAmt = treat_other_amt
  16263. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16264. // //(struct4101.IteminfoStruct, iteminfo)
  16265. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16266. // }
  16267. //
  16268. // if operationCostTotal != 0 {
  16269. // iteminfo.MedChrgitm = "06"
  16270. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  16271. // iteminfo.Amt = operationCostTotal
  16272. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  16273. // iteminfo.ClabAmt = operation_clab_amt
  16274. // iteminfo.OthAmt = operation_other_amt
  16275. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16276. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16277. // }
  16278. //
  16279. // if materialCostTotal != 0 {
  16280. // iteminfo.MedChrgitm = "08"
  16281. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  16282. // iteminfo.Amt = materialCostTotal
  16283. // iteminfo.ClaaSumfee = material_claa_sunmfee
  16284. // iteminfo.ClabAmt = material_clab_amt
  16285. // iteminfo.OthAmt = material_other_amt
  16286. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16287. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16288. // }
  16289. //
  16290. // if westernMedicineCostTotal != 0 {
  16291. // iteminfo.MedChrgitm = "09"
  16292. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  16293. // iteminfo.Amt = westernMedicineCostTotal
  16294. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  16295. // iteminfo.ClabAmt = westernMedicine_clab_amt
  16296. // iteminfo.OthAmt = westernMedicine_other_amt
  16297. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16298. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16299. //
  16300. // }
  16301. // if chineseTraditionalMedicineCostTotal != 0 {
  16302. // iteminfo.MedChrgitm = "11"
  16303. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  16304. // iteminfo.Amt = westernMedicineCostTotal
  16305. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  16306. // iteminfo.ClabAmt = westernMedicine_clab_amt
  16307. // iteminfo.OthAmt = westernMedicine_other_amt
  16308. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16309. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16310. //
  16311. // }
  16312. // if otherCostTotal != 0 {
  16313. // iteminfo.MedChrgitm = "14"
  16314. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  16315. // iteminfo.Amt = otherCostTotal
  16316. // iteminfo.ClaaSumfee = other_claa_sunmfee
  16317. // iteminfo.ClabAmt = other_clab_amt
  16318. // iteminfo.OthAmt = other_other_amt
  16319. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16320. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  16321. //
  16322. // }
  16323. // struct4101.IteminfoStruct = iteminfoStructs
  16324. // struct4101.Ntly = "中国"
  16325. // struct4101.AdmCaty = "A03.06"
  16326. //
  16327. // struct4101.DoctorName = doctor.UserName
  16328. // struct4101.DoctorCode = doctor.DoctorNumber
  16329. //
  16330. // var res ResultSeventeen
  16331. //
  16332. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16333. // struct4101.BillCode = order.Number
  16334. // struct4101.BillNo = order.SetlId
  16335. // var resOther ResultSeventeenOther
  16336. // var pp models.PublicParams
  16337. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16338. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16339. // pp.FixmedinsName = miConfig.OrgName
  16340. // pp.FixmedinsCode = miConfig.Code
  16341. // pp.RequestUrl = miConfig.Url
  16342. // pp.Cainfo = miConfig.Cainfo
  16343. // pp.SecretKey = miConfig.SecretKey
  16344. // pp.AccessKey = miConfig.AccessKey
  16345. // pp.OpterName = curRoles.UserName
  16346. //
  16347. // client := &http.Client{}
  16348. // var req *http.Request
  16349. // data := make(map[string]interface{})
  16350. // data["struct4101"] = struct4101
  16351. // data["pp"] = pp
  16352. // bytesData, _ := json.Marshal(data)
  16353. // if miConfig.MdtrtareaAdmvs == "320921" {
  16354. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  16355. // } else {
  16356. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  16357. // }
  16358. // resp, _ := client.Do(req)
  16359. // defer resp.Body.Close()
  16360. // body, ioErr := ioutil.ReadAll(resp.Body)
  16361. // if ioErr != nil {
  16362. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16363. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16364. // return
  16365. // }
  16366. // var respJSON map[string]interface{}
  16367. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16368. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16369. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16370. // return
  16371. // }
  16372. //
  16373. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16374. // userJSONBytes, _ := json.Marshal(respJSON)
  16375. // fmt.Println("log")
  16376. // fmt.Println(string(userJSONBytes))
  16377. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  16378. // utils.ErrorLog("解析失败:%v", err)
  16379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16380. // return
  16381. // }
  16382. // res.InfRefmsgid = resOther.InfRefmsgid
  16383. // res.Output = resOther.Output
  16384. // res.ErrMsg = resOther.ErrMsg
  16385. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  16386. // res.Infcode = infocode
  16387. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  16388. //
  16389. // var pp models.PublicParams
  16390. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16391. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16392. // pp.FixmedinsName = miConfig.OrgName
  16393. // pp.FixmedinsCode = miConfig.Code
  16394. // pp.RequestUrl = miConfig.Url
  16395. // pp.Cainfo = miConfig.Cainfo
  16396. // pp.SecretKey = miConfig.SecretKey
  16397. // pp.AccessKey = miConfig.AccessKey
  16398. // pp.OpterName = curRoles.UserName
  16399. // result, _ := service.Jxyb4101(struct4101, pp)
  16400. // var dat map[string]interface{}
  16401. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16402. // fmt.Println(dat)
  16403. // } else {
  16404. // fmt.Println(err)
  16405. // }
  16406. // userJSONBytes, _ := json.Marshal(dat)
  16407. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16408. // utils.ErrorLog("解析失败:%v", err)
  16409. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16410. // return
  16411. // }
  16412. //
  16413. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  16414. // var pp models.PublicParams
  16415. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16416. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16417. // pp.FixmedinsName = miConfig.OrgName
  16418. // pp.FixmedinsCode = miConfig.Code
  16419. // pp.RequestUrl = miConfig.Url
  16420. // pp.Cainfo = miConfig.Cainfo
  16421. // pp.SecretKey = miConfig.SecretKey
  16422. // pp.AccessKey = miConfig.AccessKey
  16423. // pp.OpterName = curRoles.UserName
  16424. // result, _ := service.Hnyb4101(struct4101, pp)
  16425. // var dat map[string]interface{}
  16426. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16427. // fmt.Println(dat)
  16428. // } else {
  16429. // fmt.Println(err)
  16430. // }
  16431. // userJSONBytes, _ := json.Marshal(dat)
  16432. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16433. // utils.ErrorLog("解析失败:%v", err)
  16434. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16435. // return
  16436. // }
  16437. //
  16438. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  16439. // var resOther ResultSeventeenOther
  16440. //
  16441. // var pp models.PublicParams
  16442. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16443. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16444. // pp.FixmedinsName = miConfig.OrgName
  16445. // pp.FixmedinsCode = miConfig.Code
  16446. // pp.RequestUrl = miConfig.Url
  16447. // pp.Cainfo = miConfig.Cainfo
  16448. // pp.SecretKey = miConfig.SecretKey
  16449. // pp.AccessKey = miConfig.AccessKey
  16450. // pp.OpterName = curRoles.UserName
  16451. // client := &http.Client{}
  16452. // var req *http.Request
  16453. // data := make(map[string]interface{})
  16454. // data["struct4101"] = struct4101
  16455. // data["pp"] = pp
  16456. // bytesData, _ := json.Marshal(data)
  16457. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  16458. // resp, _ := client.Do(req)
  16459. // defer resp.Body.Close()
  16460. // body, ioErr := ioutil.ReadAll(resp.Body)
  16461. // if ioErr != nil {
  16462. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16463. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16464. // return
  16465. // }
  16466. // var respJSON map[string]interface{}
  16467. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16468. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16469. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16470. // return
  16471. // }
  16472. //
  16473. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16474. // userJSONBytes, _ := json.Marshal(respJSON)
  16475. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  16476. // utils.ErrorLog("解析失败:%v", err)
  16477. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16478. // return
  16479. // }
  16480. // res.InfRefmsgid = resOther.InfRefmsgid
  16481. // res.Output = resOther.Output
  16482. // res.ErrMsg = resOther.ErrMsg
  16483. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  16484. // res.Infcode = infocode
  16485. //
  16486. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  16487. // var pp models.PublicParams
  16488. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16489. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16490. // pp.FixmedinsName = miConfig.OrgName
  16491. // pp.FixmedinsCode = miConfig.Code
  16492. // pp.RequestUrl = miConfig.Url
  16493. // pp.Cainfo = miConfig.Cainfo
  16494. // pp.SecretKey = miConfig.SecretKey
  16495. // pp.AccessKey = miConfig.AccessKey
  16496. // pp.OpterName = curRoles.UserName
  16497. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  16498. // fmt.Println(requestLog)
  16499. // fmt.Println(errMsgLog)
  16500. //
  16501. // saveLog(result, requestLog, "4101a", "上传清单")
  16502. //
  16503. // var dat map[string]interface{}
  16504. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16505. // fmt.Println(dat)
  16506. // } else {
  16507. // fmt.Println(err)
  16508. // }
  16509. // userJSONBytes, _ := json.Marshal(dat)
  16510. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16511. // utils.ErrorLog("解析失败:%v", err)
  16512. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16513. // return
  16514. // }
  16515. //
  16516. // } else {
  16517. //
  16518. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  16519. // var dat map[string]interface{}
  16520. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16521. // fmt.Println(dat)
  16522. // } else {
  16523. // fmt.Println(err)
  16524. // }
  16525. // userJSONBytes, _ := json.Marshal(dat)
  16526. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16527. // utils.ErrorLog("解析失败:%v", err)
  16528. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16529. // return
  16530. // }
  16531. // }
  16532. //
  16533. // if res.Infcode != 0 {
  16534. // adminUser := c.GetAdminUserInfo()
  16535. // errlog := &models.HisOrderError{
  16536. // UserOrgId: adminUser.CurrentOrgId,
  16537. // Ctime: time.Now().Unix(),
  16538. // Mtime: time.Now().Unix(),
  16539. // ErrMsg: res.ErrMsg,
  16540. // Status: 1,
  16541. // PatientId: order.ID,
  16542. // Stage: 10265,
  16543. // }
  16544. // service.CreateErrMsgLog(errlog)
  16545. // continue
  16546. // } else {
  16547. // //order.FaPiaoNumber = zero
  16548. // //order.FaPiaoCode = last_order.FaPiaoCode
  16549. // //service.UpdateOrder(order)
  16550. // hisFundSettleListResult := &models.HisFundSettleListResult{
  16551. // Number: res.Output.SetlListId,
  16552. // Status: 1,
  16553. // Ctime: time.Now().Unix(),
  16554. // Mtime: time.Now().Unix(),
  16555. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16556. // IsUpload: 1,
  16557. // OrderId: order.ID,
  16558. // }
  16559. // service.CreateUploadRecord(hisFundSettleListResult)
  16560. // c.ServeSuccessJSON(map[string]interface{}{
  16561. // "msg": "上传成功",
  16562. // "result": hisFundSettleListResult,
  16563. // })
  16564. // continue
  16565. // }
  16566. // }
  16567. //}
  16568. func (c *HisApiController) GetbatchSettleList() {
  16569. //order_id, _ := c.GetInt64("order_id")
  16570. admin_user_id, _ := c.GetInt64("admin_user_id")
  16571. orders, _ := service.GetAllHisOrderTwo10485()
  16572. for _, item := range orders {
  16573. order, _ := service.GetHisOrderByIDTwo(item.ID)
  16574. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  16575. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  16576. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  16577. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  16578. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  16579. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16580. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  16581. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  16582. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  16583. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  16584. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  16585. //fmt.Println(count)
  16586. //var zero string
  16587. //number := count + 1
  16588. //if number >= 1000 {
  16589. // zero = "0000" + strconv.FormatInt(number, 10)
  16590. //} else if number >= 10000 {
  16591. // zero = "000" + strconv.FormatInt(number, 10)
  16592. //} else if number >= 100000 {
  16593. // zero = "00" + strconv.FormatInt(number, 10)
  16594. //} else if number >= 1000000 {
  16595. // zero = "0" + strconv.FormatInt(number, 10)
  16596. //} else {
  16597. // zero = strconv.FormatInt(number, 10)
  16598. //}
  16599. //fmt.Println(zero)
  16600. struct4101 := service.Struct4101{
  16601. PsnNo: order.PsnNo,
  16602. MdtrtId: order.MdtrtId,
  16603. SetlId: order.SetlId,
  16604. PsnName: order.PsnName,
  16605. Gend: order.Gend,
  16606. Brdy: his.Brdy,
  16607. Age: his.Age,
  16608. Naty: order.Naty,
  16609. PatnCertType: "01",
  16610. Certno: order.Certno,
  16611. Prfs: "90",
  16612. ConerName: roles[0].UserName,
  16613. PatnRlts: "99",
  16614. ConerAddr: miConfig.OrgName,
  16615. ConerTel: admin.Mobile,
  16616. HiType: order.Insutype,
  16617. Insuplc: miConfig.InsuplcAdmdvs,
  16618. MaindiagFlag: "1",
  16619. BillCode: order.SetlId,
  16620. BillNo: order.SetlId,
  16621. BizSn: order.Number,
  16622. PsnSelfPay: order.PsnPartAmt,
  16623. PsnOwnPay: order.PsnPartAmt,
  16624. AcctPay: order.AcctPay,
  16625. PsnCashpay: order.PsnCashPay,
  16626. HiPaymtd: "1",
  16627. Hsorg: miConfig.InsuplcAdmdvs,
  16628. HsorgOpter: miConfig.InsuplcAdmdvs,
  16629. MedinsFillPsn: curRoles.UserName,
  16630. MedinsFillDept: miConfig.OrgName,
  16631. IptMedType: "2",
  16632. }
  16633. struct4101.SetlBegnDate = order.SetlTime
  16634. struct4101.SetlEndDate = order.SetlTime
  16635. time_arr := strings.Split(order.SetlTime, " ")
  16636. struct4101.AdmTime = time_arr[0]
  16637. struct4101.AdmEndTime = time_arr[0]
  16638. //var rf []CustomFundPay
  16639. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  16640. //
  16641. //var tempFunPays []service.CustomStruct
  16642. //for _, item := range rf {
  16643. // var tempFunPay service.CustomStruct
  16644. // tempFunPay.FundPayamt = item.FundPayamt
  16645. // tempFunPay.FundPayType = item.FundPayType
  16646. // tempFunPays = append(tempFunPays, tempFunPay)
  16647. //}
  16648. //struct4101.CustomStruct = tempFunPays
  16649. var tempDiaginfos []service.DiaginfoStructTwo
  16650. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  16651. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  16652. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  16653. var config []*models.HisXtDiagnoseConfig
  16654. for _, item := range diagnosis_ids {
  16655. id, _ := strconv.ParseInt(item, 10, 64)
  16656. diagnosisConfig, _ := service.FindDiagnoseById(id)
  16657. config = append(config, &diagnosisConfig)
  16658. }
  16659. for index, item := range config {
  16660. if index == 0 {
  16661. var tempDiaginfo service.DiaginfoStructTwo
  16662. tempDiaginfo.DiagCode = item.CountryCode
  16663. tempDiaginfo.DiagName = item.CountryContentName
  16664. tempDiaginfo.DiagType = "1"
  16665. tempDiaginfo.MaindiagFlag = "1"
  16666. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  16667. } else {
  16668. var tempDiaginfo service.DiaginfoStructTwo
  16669. tempDiaginfo.DiagCode = item.CountryCode
  16670. tempDiaginfo.DiagName = item.CountryContentName
  16671. tempDiaginfo.DiagType = "1"
  16672. tempDiaginfo.MaindiagFlag = "0"
  16673. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  16674. }
  16675. }
  16676. struct4101.Diseinfo = tempDiaginfos
  16677. sickConfigTwo, _ := service.FindSickById(his.SickType)
  16678. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  16679. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  16680. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  16681. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  16682. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  16683. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  16684. var iteminfo service.IteminfoStruct
  16685. var bedCostTotal float64 = 0 //床位总费
  16686. var bedCostSelfTotal float64 = 0 //床位自费
  16687. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  16688. var operationCostTotal float64 = 0 //手术费
  16689. var operationCostSelfTotal float64 = 0 //手术费
  16690. var operationCostPartSelfTotal float64 = 0 //手术费
  16691. var otherCostTotal float64 = 0 //其他费用
  16692. var otherCostSelfTotal float64 = 0 //其他费用
  16693. var otherCostPartSelfTotal float64 = 0 //其他费用
  16694. var materialCostTotal float64 = 0 //材料费
  16695. var materialCostSelfTotal float64 = 0 //材料费
  16696. var materialCostPartSelfTotal float64 = 0 //材料费
  16697. var westernMedicineCostTotal float64 = 0 //西药费
  16698. var westernMedicineCostSelfTotal float64 = 0 //西药费
  16699. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  16700. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  16701. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  16702. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  16703. var checkCostTotal float64 = 0 //检查费
  16704. var checkCostSelfTotal float64 = 0 //检查费
  16705. var checkCostPartSelfTotal float64 = 0 //检查费
  16706. var laboratoryCostTotal float64 = 0 //化验费
  16707. var laboratoryCostSelfTotal float64 = 0 //化验费
  16708. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  16709. var treatCostTotal float64 = 0 //治疗费用
  16710. var treatCostSelfTotal float64 = 0 //治疗费用
  16711. var treatCostPartSelfTotal float64 = 0 //治疗费用
  16712. decimal.DivisionPrecision = 2
  16713. var bed_fulamt_ownpay_amt float64 = 0
  16714. var operation_fulamt_ownpay_amt float64 = 0
  16715. var other_fulamt_ownpay_amt float64 = 0
  16716. var westernMedicine_fulamt_ownpay_amt float64 = 0
  16717. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  16718. var check_fulamt_ownpay_amt float64 = 0
  16719. var material_fulamt_ownpay_amt float64 = 0
  16720. var laboratory_fulamt_ownpay_amt float64 = 0
  16721. var treat_fulamt_ownpay_amt float64 = 0
  16722. var bed_claa_sunmfee float64 = 0
  16723. var bed_clab_amt float64 = 0
  16724. var bed_other_amt float64 = 0
  16725. var operation_claa_sunmfee float64 = 0
  16726. var operation_clab_amt float64 = 0
  16727. var operation_other_amt float64 = 0
  16728. var other_claa_sunmfee float64 = 0
  16729. var other_clab_amt float64 = 0
  16730. var other_other_amt float64 = 0
  16731. var westernMedicine_claa_sunmfee float64 = 0
  16732. var westernMedicine_clab_amt float64 = 0
  16733. var westernMedicine_other_amt float64 = 0
  16734. var chineseTraditional_claa_sunmfee float64 = 0
  16735. var chineseTraditional_clab_amt float64 = 0
  16736. var chineseTraditional_other_amt float64 = 0
  16737. var check_claa_sunmfee float64 = 0
  16738. var check_clab_amt float64 = 0
  16739. var check_other_amt float64 = 0
  16740. var material_claa_sunmfee float64 = 0
  16741. var material_clab_amt float64 = 0
  16742. var material_other_amt float64 = 0
  16743. var laboratory_claa_sunmfee float64 = 0
  16744. var laboratory_clab_amt float64 = 0
  16745. var laboratory_other_amt float64 = 0
  16746. var treat_claa_sunmfee float64 = 0
  16747. var treat_clab_amt float64 = 0
  16748. var treat_other_amt float64 = 0
  16749. for _, item := range order.HisOrderInfo {
  16750. if item.MedChrgitmType == "01" { //床位费
  16751. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16752. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16753. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16754. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16755. if item.ChrgitmLv == "1" {
  16756. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16757. }
  16758. if item.ChrgitmLv == "2" {
  16759. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16760. }
  16761. if item.ChrgitmLv == "3" {
  16762. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16763. }
  16764. }
  16765. if item.MedChrgitmType == "03" { //检查费
  16766. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16767. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16768. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16769. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16770. if item.ChrgitmLv == "1" {
  16771. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16772. }
  16773. if item.ChrgitmLv == "2" {
  16774. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16775. }
  16776. if item.ChrgitmLv == "3" {
  16777. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16778. }
  16779. }
  16780. if item.MedChrgitmType == "04" { //化验费
  16781. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16782. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16783. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16784. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16785. if item.ChrgitmLv == "1" {
  16786. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16787. }
  16788. if item.ChrgitmLv == "2" {
  16789. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16790. }
  16791. if item.ChrgitmLv == "3" {
  16792. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16793. }
  16794. }
  16795. if item.MedChrgitmType == "05" { //治疗费
  16796. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16797. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16798. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16799. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16800. if item.ChrgitmLv == "1" {
  16801. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16802. }
  16803. if item.ChrgitmLv == "2" {
  16804. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16805. }
  16806. if item.ChrgitmLv == "3" {
  16807. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16808. }
  16809. }
  16810. if item.MedChrgitmType == "06" { //手术费
  16811. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16812. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16813. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16814. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16815. if item.ChrgitmLv == "1" {
  16816. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16817. }
  16818. if item.ChrgitmLv == "2" {
  16819. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16820. }
  16821. if item.ChrgitmLv == "3" {
  16822. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16823. }
  16824. }
  16825. if item.MedChrgitmType == "08" { //材料费
  16826. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16827. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16828. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16829. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16830. if item.ChrgitmLv == "1" {
  16831. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16832. }
  16833. if item.ChrgitmLv == "2" {
  16834. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16835. }
  16836. if item.ChrgitmLv == "3" {
  16837. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16838. }
  16839. }
  16840. if item.MedChrgitmType == "09" { //西药费
  16841. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16842. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16843. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16844. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16845. if item.ChrgitmLv == "1" {
  16846. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16847. }
  16848. if item.ChrgitmLv == "2" {
  16849. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16850. }
  16851. if item.ChrgitmLv == "3" {
  16852. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16853. }
  16854. }
  16855. if item.MedChrgitmType == "11" { //中成费
  16856. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16857. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16858. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16859. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16860. if item.ChrgitmLv == "1" {
  16861. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16862. }
  16863. if item.ChrgitmLv == "2" {
  16864. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16865. }
  16866. if item.ChrgitmLv == "3" {
  16867. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16868. }
  16869. }
  16870. if item.MedChrgitmType == "14" { //其他费
  16871. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16872. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16873. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16874. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16875. if item.ChrgitmLv == "1" {
  16876. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16877. }
  16878. if item.ChrgitmLv == "2" {
  16879. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16880. }
  16881. if item.ChrgitmLv == "3" {
  16882. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16883. }
  16884. }
  16885. }
  16886. var iteminfoStructs []service.IteminfoStruct
  16887. if bedCostTotal != 0 {
  16888. iteminfo.MedChrgitm = "01"
  16889. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  16890. iteminfo.Amt = bedCostTotal
  16891. iteminfo.ClaaSumfee = bed_claa_sunmfee
  16892. iteminfo.ClabAmt = bed_clab_amt
  16893. iteminfo.OthAmt = bed_other_amt
  16894. iteminfoStructs = append(iteminfoStructs, iteminfo)
  16895. }
  16896. if checkCostTotal != 0 {
  16897. iteminfo.MedChrgitm = "03"
  16898. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  16899. iteminfo.Amt = checkCostTotal
  16900. iteminfo.ClaaSumfee = check_claa_sunmfee
  16901. iteminfo.ClabAmt = check_clab_amt
  16902. iteminfo.OthAmt = check_other_amt
  16903. iteminfoStructs = append(iteminfoStructs, iteminfo)
  16904. }
  16905. if laboratoryCostTotal != 0 {
  16906. iteminfo.MedChrgitm = "04"
  16907. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  16908. iteminfo.Amt = laboratoryCostTotal
  16909. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  16910. iteminfo.ClabAmt = laboratory_clab_amt
  16911. iteminfo.OthAmt = laboratory_other_amt
  16912. iteminfoStructs = append(iteminfoStructs, iteminfo)
  16913. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16914. }
  16915. if treatCostTotal != 0 {
  16916. iteminfo.MedChrgitm = "05"
  16917. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  16918. iteminfo.Amt = treatCostTotal
  16919. iteminfo.ClaaSumfee = treat_claa_sunmfee
  16920. iteminfo.ClabAmt = treat_clab_amt
  16921. iteminfo.OthAmt = treat_other_amt
  16922. iteminfoStructs = append(iteminfoStructs, iteminfo)
  16923. //(struct4101.IteminfoStruct, iteminfo)
  16924. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16925. }
  16926. if operationCostTotal != 0 {
  16927. iteminfo.MedChrgitm = "06"
  16928. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  16929. iteminfo.Amt = operationCostTotal
  16930. iteminfo.ClaaSumfee = operation_claa_sunmfee
  16931. iteminfo.ClabAmt = operation_clab_amt
  16932. iteminfo.OthAmt = operation_other_amt
  16933. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16934. iteminfoStructs = append(iteminfoStructs, iteminfo)
  16935. }
  16936. if materialCostTotal != 0 {
  16937. iteminfo.MedChrgitm = "08"
  16938. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  16939. iteminfo.Amt = materialCostTotal
  16940. iteminfo.ClaaSumfee = material_claa_sunmfee
  16941. iteminfo.ClabAmt = material_clab_amt
  16942. iteminfo.OthAmt = material_other_amt
  16943. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16944. iteminfoStructs = append(iteminfoStructs, iteminfo)
  16945. }
  16946. if westernMedicineCostTotal != 0 {
  16947. iteminfo.MedChrgitm = "09"
  16948. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  16949. iteminfo.Amt = westernMedicineCostTotal
  16950. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  16951. iteminfo.ClabAmt = westernMedicine_clab_amt
  16952. iteminfo.OthAmt = westernMedicine_other_amt
  16953. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16954. iteminfoStructs = append(iteminfoStructs, iteminfo)
  16955. }
  16956. if chineseTraditionalMedicineCostTotal != 0 {
  16957. iteminfo.MedChrgitm = "11"
  16958. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  16959. iteminfo.Amt = westernMedicineCostTotal
  16960. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  16961. iteminfo.ClabAmt = westernMedicine_clab_amt
  16962. iteminfo.OthAmt = westernMedicine_other_amt
  16963. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16964. iteminfoStructs = append(iteminfoStructs, iteminfo)
  16965. }
  16966. if otherCostTotal != 0 {
  16967. iteminfo.MedChrgitm = "14"
  16968. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  16969. iteminfo.Amt = otherCostTotal
  16970. iteminfo.ClaaSumfee = other_claa_sunmfee
  16971. iteminfo.ClabAmt = other_clab_amt
  16972. iteminfo.OthAmt = other_other_amt
  16973. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  16974. iteminfoStructs = append(iteminfoStructs, iteminfo)
  16975. }
  16976. struct4101.IteminfoStruct = iteminfoStructs
  16977. struct4101.Ntly = "中国"
  16978. struct4101.AdmCaty = "A03.06"
  16979. struct4101.DoctorName = doctor.UserName
  16980. struct4101.DoctorCode = doctor.DoctorNumber
  16981. var res ResultSeventeen
  16982. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16983. struct4101.BillCode = order.Number
  16984. struct4101.BillNo = order.SetlId
  16985. var resOther ResultSeventeenOther
  16986. var pp models.PublicParams
  16987. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16988. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16989. pp.FixmedinsName = miConfig.OrgName
  16990. pp.FixmedinsCode = miConfig.Code
  16991. pp.RequestUrl = miConfig.Url
  16992. pp.Cainfo = miConfig.Cainfo
  16993. pp.SecretKey = miConfig.SecretKey
  16994. pp.AccessKey = miConfig.AccessKey
  16995. pp.OpterName = curRoles.UserName
  16996. client := &http.Client{}
  16997. var req *http.Request
  16998. data := make(map[string]interface{})
  16999. data["struct4101"] = struct4101
  17000. data["pp"] = pp
  17001. bytesData, _ := json.Marshal(data)
  17002. if miConfig.MdtrtareaAdmvs == "320921" {
  17003. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  17004. } else {
  17005. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  17006. }
  17007. resp, _ := client.Do(req)
  17008. defer resp.Body.Close()
  17009. body, ioErr := ioutil.ReadAll(resp.Body)
  17010. if ioErr != nil {
  17011. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17013. return
  17014. }
  17015. var respJSON map[string]interface{}
  17016. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17017. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17019. return
  17020. }
  17021. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17022. userJSONBytes, _ := json.Marshal(respJSON)
  17023. fmt.Println("log")
  17024. fmt.Println(string(userJSONBytes))
  17025. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  17026. utils.ErrorLog("解析失败:%v", err)
  17027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17028. return
  17029. }
  17030. res.InfRefmsgid = resOther.InfRefmsgid
  17031. res.Output = resOther.Output
  17032. res.ErrMsg = resOther.ErrMsg
  17033. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  17034. res.Infcode = infocode
  17035. } else if miConfig.MdtrtareaAdmvs == "360302" {
  17036. var pp models.PublicParams
  17037. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  17038. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17039. pp.FixmedinsName = miConfig.OrgName
  17040. pp.FixmedinsCode = miConfig.Code
  17041. pp.RequestUrl = miConfig.Url
  17042. pp.Cainfo = miConfig.Cainfo
  17043. pp.SecretKey = miConfig.SecretKey
  17044. pp.AccessKey = miConfig.AccessKey
  17045. pp.OpterName = curRoles.UserName
  17046. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  17047. result, _ := service.Jxyb4101(struct4101, pp)
  17048. var dat map[string]interface{}
  17049. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17050. fmt.Println(dat)
  17051. } else {
  17052. fmt.Println(err)
  17053. }
  17054. userJSONBytes, _ := json.Marshal(dat)
  17055. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17056. utils.ErrorLog("解析失败:%v", err)
  17057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17058. return
  17059. }
  17060. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17061. var pp models.PublicParams
  17062. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17063. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17064. pp.FixmedinsName = miConfig.OrgName
  17065. pp.FixmedinsCode = miConfig.Code
  17066. pp.RequestUrl = miConfig.Url
  17067. pp.Cainfo = miConfig.Cainfo
  17068. pp.SecretKey = miConfig.SecretKey
  17069. pp.AccessKey = miConfig.AccessKey
  17070. pp.OpterName = curRoles.UserName
  17071. result, _ := service.Hnyb4101(struct4101, pp)
  17072. var dat map[string]interface{}
  17073. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17074. fmt.Println(dat)
  17075. } else {
  17076. fmt.Println(err)
  17077. }
  17078. userJSONBytes, _ := json.Marshal(dat)
  17079. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17080. utils.ErrorLog("解析失败:%v", err)
  17081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17082. return
  17083. }
  17084. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17085. var resOther ResultSeventeenOther
  17086. var pp models.PublicParams
  17087. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17088. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17089. pp.FixmedinsName = miConfig.OrgName
  17090. pp.FixmedinsCode = miConfig.Code
  17091. pp.RequestUrl = miConfig.Url
  17092. pp.Cainfo = miConfig.Cainfo
  17093. pp.SecretKey = miConfig.SecretKey
  17094. pp.AccessKey = miConfig.AccessKey
  17095. pp.OpterName = curRoles.UserName
  17096. client := &http.Client{}
  17097. var req *http.Request
  17098. data := make(map[string]interface{})
  17099. data["struct4101"] = struct4101
  17100. data["pp"] = pp
  17101. bytesData, _ := json.Marshal(data)
  17102. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  17103. resp, _ := client.Do(req)
  17104. defer resp.Body.Close()
  17105. body, ioErr := ioutil.ReadAll(resp.Body)
  17106. if ioErr != nil {
  17107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17109. return
  17110. }
  17111. var respJSON map[string]interface{}
  17112. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17115. return
  17116. }
  17117. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17118. userJSONBytes, _ := json.Marshal(respJSON)
  17119. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  17120. utils.ErrorLog("解析失败:%v", err)
  17121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17122. return
  17123. }
  17124. res.InfRefmsgid = resOther.InfRefmsgid
  17125. res.Output = resOther.Output
  17126. res.ErrMsg = resOther.ErrMsg
  17127. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  17128. res.Infcode = infocode
  17129. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17130. var pp models.PublicParams
  17131. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17132. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17133. pp.FixmedinsName = miConfig.OrgName
  17134. pp.FixmedinsCode = miConfig.Code
  17135. pp.RequestUrl = miConfig.Url
  17136. pp.Cainfo = miConfig.Cainfo
  17137. pp.SecretKey = miConfig.SecretKey
  17138. pp.AccessKey = miConfig.AccessKey
  17139. pp.OpterName = curRoles.UserName
  17140. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  17141. fmt.Println(requestLog)
  17142. fmt.Println(errMsgLog)
  17143. saveLog(result, requestLog, "4101a", "上传清单")
  17144. var dat map[string]interface{}
  17145. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17146. fmt.Println(dat)
  17147. } else {
  17148. fmt.Println(err)
  17149. }
  17150. userJSONBytes, _ := json.Marshal(dat)
  17151. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17152. utils.ErrorLog("解析失败:%v", err)
  17153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17154. return
  17155. }
  17156. } else if miConfig.MdtrtareaAdmvs == "441799" {
  17157. var pp models.PublicParams
  17158. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17159. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17160. pp.FixmedinsName = miConfig.OrgName
  17161. pp.FixmedinsCode = miConfig.Code
  17162. pp.RequestUrl = miConfig.Url
  17163. pp.Cainfo = miConfig.Cainfo
  17164. pp.SecretKey = miConfig.SecretKey
  17165. pp.AccessKey = miConfig.AccessKey
  17166. pp.OpterName = curRoles.UserName
  17167. client := &http.Client{}
  17168. var req *http.Request
  17169. data := make(map[string]interface{})
  17170. data["struct4101"] = struct4101
  17171. data["pp"] = pp
  17172. bytesData, _ := json.Marshal(data)
  17173. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  17174. resp, _ := client.Do(req)
  17175. defer resp.Body.Close()
  17176. body, ioErr := ioutil.ReadAll(resp.Body)
  17177. if ioErr != nil {
  17178. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17180. return
  17181. }
  17182. var respJSON map[string]interface{}
  17183. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17184. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17186. return
  17187. }
  17188. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17189. userJSONBytes, _ := json.Marshal(respJSON)
  17190. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17191. utils.ErrorLog("解析失败:%v", err)
  17192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17193. return
  17194. }
  17195. } else {
  17196. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  17197. var dat map[string]interface{}
  17198. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17199. fmt.Println(dat)
  17200. } else {
  17201. fmt.Println(err)
  17202. }
  17203. userJSONBytes, _ := json.Marshal(dat)
  17204. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17205. utils.ErrorLog("解析失败:%v", err)
  17206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17207. return
  17208. }
  17209. }
  17210. if res.Infcode != 0 {
  17211. errlog := &models.HisOrderError{
  17212. UserOrgId: order.UserOrgId,
  17213. Ctime: time.Now().Unix(),
  17214. Mtime: time.Now().Unix(),
  17215. ErrMsg: res.ErrMsg + "解析失败",
  17216. Status: 1,
  17217. PatientId: order.ID,
  17218. Stage: 10485,
  17219. }
  17220. service.CreateErrMsgLog(errlog)
  17221. continue
  17222. //c.ServeSuccessJSON(map[string]interface{}{
  17223. // "failed_code": -10,
  17224. // "msg": res.ErrMsg,
  17225. //})
  17226. } else {
  17227. //order.FaPiaoNumber = zero
  17228. //order.FaPiaoCode = last_order.FaPiaoCode
  17229. //service.UpdateOrder(order)
  17230. hisFundSettleListResult := &models.HisFundSettleListResult{
  17231. Number: res.Output.SetlListId,
  17232. Status: 1,
  17233. Ctime: time.Now().Unix(),
  17234. Mtime: time.Now().Unix(),
  17235. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17236. IsUpload: 1,
  17237. OrderId: order.ID,
  17238. }
  17239. service.CreateUploadRecord(hisFundSettleListResult)
  17240. continue
  17241. }
  17242. }
  17243. }
  17244. func (c *HisApiController) GetSettleList() {
  17245. order_id, _ := c.GetInt64("order_id")
  17246. admin_user_id, _ := c.GetInt64("admin_user_id")
  17247. order, _ := service.GetHisOrderByIDTwo(order_id)
  17248. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17249. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  17250. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17251. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17252. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17253. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17254. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  17255. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  17256. if order.ID == 0 {
  17257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  17258. return
  17259. }
  17260. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17261. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17262. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  17263. //fmt.Println(count)
  17264. //var zero string
  17265. //number := count + 1
  17266. //if number >= 1000 {
  17267. // zero = "0000" + strconv.FormatInt(number, 10)
  17268. //} else if number >= 10000 {
  17269. // zero = "000" + strconv.FormatInt(number, 10)
  17270. //} else if number >= 100000 {
  17271. // zero = "00" + strconv.FormatInt(number, 10)
  17272. //} else if number >= 1000000 {
  17273. // zero = "0" + strconv.FormatInt(number, 10)
  17274. //} else {
  17275. // zero = strconv.FormatInt(number, 10)
  17276. //}
  17277. //fmt.Println(zero)
  17278. struct4101 := service.Struct4101{
  17279. PsnNo: order.PsnNo,
  17280. MdtrtId: order.MdtrtId,
  17281. SetlId: order.SetlId,
  17282. PsnName: order.PsnName,
  17283. Gend: order.Gend,
  17284. Brdy: his.Brdy,
  17285. Age: his.Age,
  17286. Naty: order.Naty,
  17287. PatnCertType: "01",
  17288. Certno: order.Certno,
  17289. Prfs: "90",
  17290. ConerName: roles[0].UserName,
  17291. PatnRlts: "99",
  17292. ConerAddr: miConfig.OrgName,
  17293. ConerTel: admin.Mobile,
  17294. HiType: order.Insutype,
  17295. Insuplc: miConfig.InsuplcAdmdvs,
  17296. MaindiagFlag: "1",
  17297. BillCode: order.SetlId,
  17298. BillNo: order.SetlId,
  17299. BizSn: order.Number,
  17300. PsnSelfPay: order.PsnPartAmt,
  17301. PsnOwnPay: order.PsnPartAmt,
  17302. AcctPay: order.AcctPay,
  17303. PsnCashpay: order.PsnCashPay,
  17304. HiPaymtd: "1",
  17305. Hsorg: miConfig.InsuplcAdmdvs,
  17306. HsorgOpter: miConfig.InsuplcAdmdvs,
  17307. MedinsFillPsn: curRoles.UserName,
  17308. MedinsFillDept: miConfig.OrgName,
  17309. IptMedType: "2",
  17310. }
  17311. struct4101.SetlBegnDate = order.SetlTime
  17312. struct4101.SetlEndDate = order.SetlTime
  17313. time_arr := strings.Split(order.SetlTime, " ")
  17314. struct4101.AdmTime = time_arr[0]
  17315. struct4101.AdmEndTime = time_arr[0]
  17316. //
  17317. //var rf []CustomFundPay
  17318. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  17319. //
  17320. //var tempFunPays []service.CustomStruct
  17321. //for _, item := range rf {
  17322. // var tempFunPay service.CustomStruct
  17323. // tempFunPay.FundPayamt = item.FundPayamt
  17324. // tempFunPay.FundPayType = item.FundPayType
  17325. // tempFunPays = append(tempFunPays, tempFunPay)
  17326. //}
  17327. //struct4101.CustomStruct = tempFunPays
  17328. var tempDiaginfos []service.DiaginfoStructTwo
  17329. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  17330. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  17331. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  17332. var config []*models.HisXtDiagnoseConfig
  17333. for _, item := range diagnosis_ids {
  17334. id, _ := strconv.ParseInt(item, 10, 64)
  17335. diagnosisConfig, _ := service.FindDiagnoseById(id)
  17336. config = append(config, &diagnosisConfig)
  17337. }
  17338. if miConfig.Code == "H15049901371" {
  17339. //for _, item := range config {
  17340. // if item.ID == 138 {
  17341. diagnosisConfig, _ := service.FindDiagnoseById(138)
  17342. var tempDiaginfo service.DiaginfoStructTwo
  17343. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  17344. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  17345. tempDiaginfo.DiagType = "1"
  17346. tempDiaginfo.MaindiagFlag = "1"
  17347. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17348. //}
  17349. //}
  17350. for _, item := range config {
  17351. if item.ID != 138 {
  17352. var tempDiaginfo service.DiaginfoStructTwo
  17353. tempDiaginfo.DiagCode = item.CountryCode
  17354. tempDiaginfo.DiagName = item.CountryContentName
  17355. tempDiaginfo.DiagType = "1"
  17356. tempDiaginfo.MaindiagFlag = "0"
  17357. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17358. }
  17359. }
  17360. } else {
  17361. for index, item := range config {
  17362. if index == 0 {
  17363. var tempDiaginfo service.DiaginfoStructTwo
  17364. tempDiaginfo.DiagCode = item.CountryCode
  17365. tempDiaginfo.DiagName = item.CountryContentName
  17366. tempDiaginfo.DiagType = "1"
  17367. tempDiaginfo.MaindiagFlag = "1"
  17368. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17369. } else {
  17370. var tempDiaginfo service.DiaginfoStructTwo
  17371. tempDiaginfo.DiagCode = item.CountryCode
  17372. tempDiaginfo.DiagName = item.CountryContentName
  17373. tempDiaginfo.DiagType = "1"
  17374. tempDiaginfo.MaindiagFlag = "0"
  17375. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  17376. }
  17377. }
  17378. }
  17379. struct4101.Diseinfo = tempDiaginfos
  17380. sickConfigTwo, _ := service.FindSickById(his.SickType)
  17381. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  17382. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  17383. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  17384. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  17385. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  17386. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  17387. var iteminfo service.IteminfoStruct
  17388. var bedCostTotal float64 = 0 //床位总费
  17389. var bedCostSelfTotal float64 = 0 //床位自费
  17390. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  17391. var operationCostTotal float64 = 0 //手术费
  17392. var operationCostSelfTotal float64 = 0 //手术费
  17393. var operationCostPartSelfTotal float64 = 0 //手术费
  17394. var otherCostTotal float64 = 0 //其他费用
  17395. var otherCostSelfTotal float64 = 0 //其他费用
  17396. var otherCostPartSelfTotal float64 = 0 //其他费用
  17397. var materialCostTotal float64 = 0 //材料费
  17398. var materialCostSelfTotal float64 = 0 //材料费
  17399. var materialCostPartSelfTotal float64 = 0 //材料费
  17400. var westernMedicineCostTotal float64 = 0 //西药费
  17401. var westernMedicineCostSelfTotal float64 = 0 //西药费
  17402. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  17403. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  17404. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  17405. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  17406. var checkCostTotal float64 = 0 //检查费
  17407. var checkCostSelfTotal float64 = 0 //检查费
  17408. var checkCostPartSelfTotal float64 = 0 //检查费
  17409. var laboratoryCostTotal float64 = 0 //化验费
  17410. var laboratoryCostSelfTotal float64 = 0 //化验费
  17411. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  17412. var treatCostTotal float64 = 0 //治疗费用
  17413. var treatCostSelfTotal float64 = 0 //治疗费用
  17414. var treatCostPartSelfTotal float64 = 0 //治疗费用
  17415. decimal.DivisionPrecision = 2
  17416. var bed_fulamt_ownpay_amt float64 = 0
  17417. var operation_fulamt_ownpay_amt float64 = 0
  17418. var other_fulamt_ownpay_amt float64 = 0
  17419. var westernMedicine_fulamt_ownpay_amt float64 = 0
  17420. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  17421. var check_fulamt_ownpay_amt float64 = 0
  17422. var material_fulamt_ownpay_amt float64 = 0
  17423. var laboratory_fulamt_ownpay_amt float64 = 0
  17424. var treat_fulamt_ownpay_amt float64 = 0
  17425. var bed_claa_sunmfee float64 = 0
  17426. var bed_clab_amt float64 = 0
  17427. var bed_other_amt float64 = 0
  17428. var operation_claa_sunmfee float64 = 0
  17429. var operation_clab_amt float64 = 0
  17430. var operation_other_amt float64 = 0
  17431. var other_claa_sunmfee float64 = 0
  17432. var other_clab_amt float64 = 0
  17433. var other_other_amt float64 = 0
  17434. var westernMedicine_claa_sunmfee float64 = 0
  17435. var westernMedicine_clab_amt float64 = 0
  17436. var westernMedicine_other_amt float64 = 0
  17437. var chineseTraditional_claa_sunmfee float64 = 0
  17438. var chineseTraditional_clab_amt float64 = 0
  17439. var chineseTraditional_other_amt float64 = 0
  17440. var check_claa_sunmfee float64 = 0
  17441. var check_clab_amt float64 = 0
  17442. var check_other_amt float64 = 0
  17443. var material_claa_sunmfee float64 = 0
  17444. var material_clab_amt float64 = 0
  17445. var material_other_amt float64 = 0
  17446. var laboratory_claa_sunmfee float64 = 0
  17447. var laboratory_clab_amt float64 = 0
  17448. var laboratory_other_amt float64 = 0
  17449. var treat_claa_sunmfee float64 = 0
  17450. var treat_clab_amt float64 = 0
  17451. var treat_other_amt float64 = 0
  17452. for _, item := range order.HisOrderInfo {
  17453. if item.MedChrgitmType == "01" { //床位费
  17454. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17455. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17456. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17457. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17458. if item.ChrgitmLv == "1" {
  17459. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17460. }
  17461. if item.ChrgitmLv == "2" {
  17462. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17463. }
  17464. if item.ChrgitmLv == "3" {
  17465. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17466. }
  17467. }
  17468. if item.MedChrgitmType == "03" { //检查费
  17469. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17470. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17471. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17472. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17473. if item.ChrgitmLv == "1" {
  17474. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17475. }
  17476. if item.ChrgitmLv == "2" {
  17477. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17478. }
  17479. if item.ChrgitmLv == "3" {
  17480. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17481. }
  17482. }
  17483. if item.MedChrgitmType == "04" { //化验费
  17484. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17485. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17486. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17487. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17488. if item.ChrgitmLv == "1" {
  17489. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17490. }
  17491. if item.ChrgitmLv == "2" {
  17492. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17493. }
  17494. if item.ChrgitmLv == "3" {
  17495. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17496. }
  17497. }
  17498. if item.MedChrgitmType == "05" { //治疗费
  17499. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17500. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17501. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17502. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17503. if item.ChrgitmLv == "1" {
  17504. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17505. }
  17506. if item.ChrgitmLv == "2" {
  17507. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17508. }
  17509. if item.ChrgitmLv == "3" {
  17510. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17511. }
  17512. }
  17513. if item.MedChrgitmType == "06" { //手术费
  17514. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17515. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17516. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17517. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17518. if item.ChrgitmLv == "1" {
  17519. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17520. }
  17521. if item.ChrgitmLv == "2" {
  17522. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17523. }
  17524. if item.ChrgitmLv == "3" {
  17525. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17526. }
  17527. }
  17528. if item.MedChrgitmType == "08" { //材料费
  17529. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17530. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17531. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17532. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17533. if item.ChrgitmLv == "1" {
  17534. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17535. }
  17536. if item.ChrgitmLv == "2" {
  17537. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17538. }
  17539. if item.ChrgitmLv == "3" {
  17540. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17541. }
  17542. }
  17543. if item.MedChrgitmType == "09" { //西药费
  17544. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17545. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17546. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17547. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17548. if item.ChrgitmLv == "1" {
  17549. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17550. }
  17551. if item.ChrgitmLv == "2" {
  17552. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17553. }
  17554. if item.ChrgitmLv == "3" {
  17555. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17556. }
  17557. }
  17558. if item.MedChrgitmType == "11" { //中成费
  17559. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17560. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17561. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17562. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17563. if item.ChrgitmLv == "1" {
  17564. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17565. }
  17566. if item.ChrgitmLv == "2" {
  17567. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17568. }
  17569. if item.ChrgitmLv == "3" {
  17570. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17571. }
  17572. }
  17573. if item.MedChrgitmType == "14" { //其他费
  17574. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17575. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17576. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17577. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  17578. if item.ChrgitmLv == "1" {
  17579. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  17580. }
  17581. if item.ChrgitmLv == "2" {
  17582. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  17583. }
  17584. if item.ChrgitmLv == "3" {
  17585. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  17586. }
  17587. }
  17588. }
  17589. var iteminfoStructs []service.IteminfoStruct
  17590. if bedCostTotal != 0 {
  17591. iteminfo.MedChrgitm = "01"
  17592. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17593. iteminfo.Amt = bedCostTotal
  17594. iteminfo.ClaaSumfee = bed_claa_sunmfee
  17595. iteminfo.ClabAmt = bed_clab_amt
  17596. iteminfo.OthAmt = bed_other_amt
  17597. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17598. }
  17599. if checkCostTotal != 0 {
  17600. iteminfo.MedChrgitm = "03"
  17601. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  17602. iteminfo.Amt = checkCostTotal
  17603. iteminfo.ClaaSumfee = check_claa_sunmfee
  17604. iteminfo.ClabAmt = check_clab_amt
  17605. iteminfo.OthAmt = check_other_amt
  17606. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17607. }
  17608. if laboratoryCostTotal != 0 {
  17609. iteminfo.MedChrgitm = "04"
  17610. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  17611. iteminfo.Amt = laboratoryCostTotal
  17612. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  17613. iteminfo.ClabAmt = laboratory_clab_amt
  17614. iteminfo.OthAmt = laboratory_other_amt
  17615. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17616. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17617. }
  17618. if treatCostTotal != 0 {
  17619. iteminfo.MedChrgitm = "05"
  17620. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  17621. iteminfo.Amt = treatCostTotal
  17622. iteminfo.ClaaSumfee = treat_claa_sunmfee
  17623. iteminfo.ClabAmt = treat_clab_amt
  17624. iteminfo.OthAmt = treat_other_amt
  17625. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17626. //(struct4101.IteminfoStruct, iteminfo)
  17627. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17628. }
  17629. if operationCostTotal != 0 {
  17630. iteminfo.MedChrgitm = "06"
  17631. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  17632. iteminfo.Amt = operationCostTotal
  17633. iteminfo.ClaaSumfee = operation_claa_sunmfee
  17634. iteminfo.ClabAmt = operation_clab_amt
  17635. iteminfo.OthAmt = operation_other_amt
  17636. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17637. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17638. }
  17639. if materialCostTotal != 0 {
  17640. iteminfo.MedChrgitm = "08"
  17641. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  17642. iteminfo.Amt = materialCostTotal
  17643. iteminfo.ClaaSumfee = material_claa_sunmfee
  17644. iteminfo.ClabAmt = material_clab_amt
  17645. iteminfo.OthAmt = material_other_amt
  17646. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17647. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17648. }
  17649. if westernMedicineCostTotal != 0 {
  17650. iteminfo.MedChrgitm = "09"
  17651. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  17652. iteminfo.Amt = westernMedicineCostTotal
  17653. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  17654. iteminfo.ClabAmt = westernMedicine_clab_amt
  17655. iteminfo.OthAmt = westernMedicine_other_amt
  17656. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17657. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17658. }
  17659. if chineseTraditionalMedicineCostTotal != 0 {
  17660. iteminfo.MedChrgitm = "11"
  17661. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  17662. iteminfo.Amt = westernMedicineCostTotal
  17663. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  17664. iteminfo.ClabAmt = westernMedicine_clab_amt
  17665. iteminfo.OthAmt = westernMedicine_other_amt
  17666. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17667. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17668. }
  17669. if otherCostTotal != 0 {
  17670. iteminfo.MedChrgitm = "14"
  17671. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  17672. iteminfo.Amt = otherCostTotal
  17673. iteminfo.ClaaSumfee = other_claa_sunmfee
  17674. iteminfo.ClabAmt = other_clab_amt
  17675. iteminfo.OthAmt = other_other_amt
  17676. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  17677. iteminfoStructs = append(iteminfoStructs, iteminfo)
  17678. }
  17679. struct4101.IteminfoStruct = iteminfoStructs
  17680. struct4101.Ntly = "中国"
  17681. struct4101.AdmCaty = "A03.06"
  17682. struct4101.DoctorName = doctor.UserName
  17683. struct4101.DoctorCode = doctor.DoctorNumber
  17684. var res ResultSeventeen
  17685. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17686. struct4101.BillCode = order.Number
  17687. struct4101.BillNo = order.SetlId
  17688. var resOther ResultSeventeenOther
  17689. var pp models.PublicParams
  17690. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17691. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17692. pp.FixmedinsName = miConfig.OrgName
  17693. pp.FixmedinsCode = miConfig.Code
  17694. pp.RequestUrl = miConfig.Url
  17695. pp.Cainfo = miConfig.Cainfo
  17696. pp.SecretKey = miConfig.SecretKey
  17697. pp.AccessKey = miConfig.AccessKey
  17698. pp.OpterName = curRoles.UserName
  17699. client := &http.Client{}
  17700. var req *http.Request
  17701. data := make(map[string]interface{})
  17702. data["struct4101"] = struct4101
  17703. data["pp"] = pp
  17704. bytesData, _ := json.Marshal(data)
  17705. if miConfig.MdtrtareaAdmvs == "320921" {
  17706. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  17707. } else {
  17708. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  17709. }
  17710. resp, _ := client.Do(req)
  17711. defer resp.Body.Close()
  17712. body, ioErr := ioutil.ReadAll(resp.Body)
  17713. if ioErr != nil {
  17714. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17716. return
  17717. }
  17718. var respJSON map[string]interface{}
  17719. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17722. return
  17723. }
  17724. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17725. userJSONBytes, _ := json.Marshal(respJSON)
  17726. fmt.Println("log")
  17727. fmt.Println(string(userJSONBytes))
  17728. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  17729. utils.ErrorLog("解析失败:%v", err)
  17730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17731. return
  17732. }
  17733. res.InfRefmsgid = resOther.InfRefmsgid
  17734. res.Output = resOther.Output
  17735. res.ErrMsg = resOther.ErrMsg
  17736. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  17737. res.Infcode = infocode
  17738. } else if miConfig.MdtrtareaAdmvs == "360302" {
  17739. var pp models.PublicParams
  17740. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  17741. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17742. pp.FixmedinsName = miConfig.OrgName
  17743. pp.FixmedinsCode = miConfig.Code
  17744. pp.RequestUrl = miConfig.Url
  17745. pp.Cainfo = miConfig.Cainfo
  17746. pp.SecretKey = miConfig.SecretKey
  17747. pp.AccessKey = miConfig.AccessKey
  17748. pp.OpterName = curRoles.UserName
  17749. result, _ := service.Jxyb4101(struct4101, pp)
  17750. var dat map[string]interface{}
  17751. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17752. fmt.Println(dat)
  17753. } else {
  17754. fmt.Println(err)
  17755. }
  17756. userJSONBytes, _ := json.Marshal(dat)
  17757. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17758. utils.ErrorLog("解析失败:%v", err)
  17759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17760. return
  17761. }
  17762. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17763. var pp models.PublicParams
  17764. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17765. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17766. pp.FixmedinsName = miConfig.OrgName
  17767. pp.FixmedinsCode = miConfig.Code
  17768. pp.RequestUrl = miConfig.Url
  17769. pp.Cainfo = miConfig.Cainfo
  17770. pp.SecretKey = miConfig.SecretKey
  17771. pp.AccessKey = miConfig.AccessKey
  17772. pp.OpterName = curRoles.UserName
  17773. result, _ := service.Hnyb4101(struct4101, pp)
  17774. var dat map[string]interface{}
  17775. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17776. fmt.Println(dat)
  17777. } else {
  17778. fmt.Println(err)
  17779. }
  17780. userJSONBytes, _ := json.Marshal(dat)
  17781. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17782. utils.ErrorLog("解析失败:%v", err)
  17783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17784. return
  17785. }
  17786. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17787. var resOther ResultSeventeenOther
  17788. var pp models.PublicParams
  17789. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17790. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17791. pp.FixmedinsName = miConfig.OrgName
  17792. pp.FixmedinsCode = miConfig.Code
  17793. pp.RequestUrl = miConfig.Url
  17794. pp.Cainfo = miConfig.Cainfo
  17795. pp.SecretKey = miConfig.SecretKey
  17796. pp.AccessKey = miConfig.AccessKey
  17797. pp.OpterName = curRoles.UserName
  17798. client := &http.Client{}
  17799. var req *http.Request
  17800. data := make(map[string]interface{})
  17801. data["struct4101"] = struct4101
  17802. data["pp"] = pp
  17803. bytesData, _ := json.Marshal(data)
  17804. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  17805. resp, _ := client.Do(req)
  17806. defer resp.Body.Close()
  17807. body, ioErr := ioutil.ReadAll(resp.Body)
  17808. if ioErr != nil {
  17809. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17811. return
  17812. }
  17813. var respJSON map[string]interface{}
  17814. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17815. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17817. return
  17818. }
  17819. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17820. userJSONBytes, _ := json.Marshal(respJSON)
  17821. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  17822. utils.ErrorLog("解析失败:%v", err)
  17823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17824. return
  17825. }
  17826. res.InfRefmsgid = resOther.InfRefmsgid
  17827. res.Output = resOther.Output
  17828. res.ErrMsg = resOther.ErrMsg
  17829. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  17830. res.Infcode = infocode
  17831. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17832. var pp models.PublicParams
  17833. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17834. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17835. pp.FixmedinsName = miConfig.OrgName
  17836. pp.FixmedinsCode = miConfig.Code
  17837. pp.RequestUrl = miConfig.Url
  17838. pp.Cainfo = miConfig.Cainfo
  17839. pp.SecretKey = miConfig.SecretKey
  17840. pp.AccessKey = miConfig.AccessKey
  17841. pp.OpterName = curRoles.UserName
  17842. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  17843. fmt.Println(requestLog)
  17844. fmt.Println(errMsgLog)
  17845. saveLog(result, requestLog, "4101a", "上传清单")
  17846. var dat map[string]interface{}
  17847. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17848. fmt.Println(dat)
  17849. } else {
  17850. fmt.Println(err)
  17851. }
  17852. userJSONBytes, _ := json.Marshal(dat)
  17853. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17854. utils.ErrorLog("解析失败:%v", err)
  17855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17856. return
  17857. }
  17858. } else if miConfig.MdtrtareaAdmvs == "441799" {
  17859. var pp models.PublicParams
  17860. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  17861. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  17862. pp.FixmedinsName = miConfig.OrgName
  17863. pp.FixmedinsCode = miConfig.Code
  17864. pp.RequestUrl = miConfig.Url
  17865. pp.Cainfo = miConfig.Cainfo
  17866. pp.SecretKey = miConfig.SecretKey
  17867. pp.AccessKey = miConfig.AccessKey
  17868. pp.OpterName = curRoles.UserName
  17869. client := &http.Client{}
  17870. var req *http.Request
  17871. data := make(map[string]interface{})
  17872. data["struct4101"] = struct4101
  17873. data["pp"] = pp
  17874. bytesData, _ := json.Marshal(data)
  17875. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  17876. resp, _ := client.Do(req)
  17877. defer resp.Body.Close()
  17878. body, ioErr := ioutil.ReadAll(resp.Body)
  17879. if ioErr != nil {
  17880. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17882. return
  17883. }
  17884. var respJSON map[string]interface{}
  17885. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17886. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17888. return
  17889. }
  17890. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17891. userJSONBytes, _ := json.Marshal(respJSON)
  17892. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17893. utils.ErrorLog("解析失败:%v", err)
  17894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17895. return
  17896. }
  17897. } else {
  17898. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  17899. var dat map[string]interface{}
  17900. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17901. fmt.Println(dat)
  17902. } else {
  17903. fmt.Println(err)
  17904. }
  17905. userJSONBytes, _ := json.Marshal(dat)
  17906. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17907. utils.ErrorLog("解析失败:%v", err)
  17908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17909. return
  17910. }
  17911. }
  17912. if res.Infcode != 0 {
  17913. c.ServeSuccessJSON(map[string]interface{}{
  17914. "failed_code": -10,
  17915. "msg": res.ErrMsg,
  17916. })
  17917. return
  17918. } else {
  17919. //order.FaPiaoNumber = zero
  17920. //order.FaPiaoCode = last_order.FaPiaoCode
  17921. //service.UpdateOrder(order)
  17922. hisFundSettleListResult := &models.HisFundSettleListResult{
  17923. Number: res.Output.SetlListId,
  17924. Status: 1,
  17925. Ctime: time.Now().Unix(),
  17926. Mtime: time.Now().Unix(),
  17927. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17928. IsUpload: 1,
  17929. OrderId: order_id,
  17930. }
  17931. service.CreateUploadRecord(hisFundSettleListResult)
  17932. c.ServeSuccessJSON(map[string]interface{}{
  17933. "msg": "上传成功",
  17934. "result": hisFundSettleListResult,
  17935. })
  17936. return
  17937. }
  17938. }
  17939. func (c *HisApiController) GetSettleListHospital() {
  17940. order_id, _ := c.GetInt64("order_id")
  17941. admin_user_id, _ := c.GetInt64("admin_user_id")
  17942. order, _ := service.GetHisOrderByIDTwo(order_id)
  17943. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  17944. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  17945. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  17946. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17947. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  17948. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17949. if order.ID == 0 {
  17950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  17951. return
  17952. }
  17953. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  17954. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  17955. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  17956. fmt.Println(count)
  17957. var zero string
  17958. number := count + 1
  17959. if number >= 1000 {
  17960. zero = "0000" + strconv.FormatInt(number, 10)
  17961. } else if number >= 10000 {
  17962. zero = "000" + strconv.FormatInt(number, 10)
  17963. } else if number >= 100000 {
  17964. zero = "00" + strconv.FormatInt(number, 10)
  17965. } else if number >= 1000000 {
  17966. zero = "0" + strconv.FormatInt(number, 10)
  17967. } else {
  17968. zero = strconv.FormatInt(number, 10)
  17969. }
  17970. fmt.Println(zero)
  17971. struct4101 := service.Struct4101{
  17972. PsnNo: order.PsnNo,
  17973. MdtrtId: order.MdtrtId,
  17974. SetlId: order.SetlId,
  17975. PsnName: order.PsnName,
  17976. Gend: order.Gend,
  17977. Brdy: his.Brdy,
  17978. Age: int64(order.Age),
  17979. Naty: order.Naty,
  17980. PatnCertType: "01",
  17981. Certno: order.Certno,
  17982. Prfs: "90",
  17983. ConerName: roles[0].UserName,
  17984. PatnRlts: "99",
  17985. ConerAddr: miConfig.OrgName,
  17986. ConerTel: admin.Mobile,
  17987. HiType: order.Insutype,
  17988. Insuplc: miConfig.InsuplcAdmdvs,
  17989. MaindiagFlag: "1",
  17990. BillCode: order.SetlId,
  17991. BillNo: order.SetlId,
  17992. BizSn: order.Number,
  17993. PsnSelfPay: order.PsnPartAmt,
  17994. PsnOwnPay: order.PsnPartAmt,
  17995. AcctPay: order.AcctPay,
  17996. PsnCashpay: order.PsnCashPay,
  17997. HiPaymtd: "1",
  17998. Hsorg: miConfig.InsuplcAdmdvs,
  17999. HsorgOpter: miConfig.InsuplcAdmdvs,
  18000. MedinsFillPsn: curRoles.UserName,
  18001. MedinsFillDept: depart.Name,
  18002. IptMedType: "2",
  18003. AdmTime: his.InHosptialTime,
  18004. AdmEndTime: his.OutHosptialTime,
  18005. }
  18006. struct4101.SetlBegnDate = order.SetlTime
  18007. struct4101.SetlEndDate = order.SetlTime
  18008. //var rf []CustomFundPay
  18009. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  18010. //
  18011. //var tempFunPays []service.CustomStruct
  18012. //for _, item := range rf {
  18013. // var tempFunPay service.CustomStruct
  18014. // tempFunPay.FundPayamt = item.FundPayamt
  18015. // tempFunPay.FundPayType = item.FundPayType
  18016. // tempFunPays = append(tempFunPays, tempFunPay)
  18017. //}
  18018. //struct4101.CustomStruct = tempFunPays
  18019. var tempDiaginfos []service.DiaginfoStructTwo
  18020. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18021. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18022. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  18023. //for _, item := range infos {
  18024. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  18025. //}
  18026. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  18027. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  18028. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18029. fmt.Println(diagnosis_ids_arr)
  18030. if order.UserOrgId == 10210 {
  18031. var diagnosis_ids_arr_two []int64
  18032. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  18033. var config []*models.HisXtDiagnoseConfig
  18034. for _, id := range diagnosis_ids_arr_two {
  18035. //id, _ := strconv.ParseInt(item, 10, 64)
  18036. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18037. if diagnosisConfig.ID > 0 {
  18038. config = append(config, &diagnosisConfig)
  18039. }
  18040. }
  18041. for index, item := range config {
  18042. if item.ID > 0 {
  18043. if index == 0 {
  18044. var tempDiaginfo service.DiaginfoStructTwo
  18045. tempDiaginfo.DiagCode = item.CountryCode
  18046. tempDiaginfo.DiagName = item.CountryContentName
  18047. tempDiaginfo.DiagType = "1"
  18048. tempDiaginfo.MaindiagFlag = "1"
  18049. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18050. } else {
  18051. var tempDiaginfo service.DiaginfoStructTwo
  18052. tempDiaginfo.DiagCode = item.CountryCode
  18053. tempDiaginfo.DiagName = item.CountryContentName
  18054. tempDiaginfo.DiagType = "1"
  18055. tempDiaginfo.MaindiagFlag = "0"
  18056. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18057. }
  18058. }
  18059. }
  18060. struct4101.Diseinfo = tempDiaginfos
  18061. } else {
  18062. var config []*models.HisXtDiagnoseConfig
  18063. for _, item := range diagnosis_ids_arr {
  18064. id, _ := strconv.ParseInt(item, 10, 64)
  18065. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18066. if diagnosisConfig.ID > 0 {
  18067. config = append(config, &diagnosisConfig)
  18068. }
  18069. }
  18070. for index, item := range config {
  18071. if item.ID > 0 {
  18072. if index == 0 {
  18073. var tempDiaginfo service.DiaginfoStructTwo
  18074. tempDiaginfo.DiagCode = item.CountryCode
  18075. tempDiaginfo.DiagName = item.CountryContentName
  18076. tempDiaginfo.DiagType = "1"
  18077. tempDiaginfo.MaindiagFlag = "1"
  18078. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18079. } else {
  18080. var tempDiaginfo service.DiaginfoStructTwo
  18081. tempDiaginfo.DiagCode = item.CountryCode
  18082. tempDiaginfo.DiagName = item.CountryContentName
  18083. tempDiaginfo.DiagType = "1"
  18084. tempDiaginfo.MaindiagFlag = "0"
  18085. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18086. }
  18087. }
  18088. }
  18089. struct4101.Diseinfo = tempDiaginfos
  18090. }
  18091. sickConfigTwo, _ := service.FindSickById(his.SickType)
  18092. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18093. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18094. tempOpspdiseinfo2.OprnOprtCode = ""
  18095. tempOpspdiseinfo2.OprnOprtName = ""
  18096. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18097. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18098. var iteminfo service.IteminfoStruct
  18099. var bedCostTotal float64 = 0 //床位总费
  18100. var bedCostSelfTotal float64 = 0 //床位自费
  18101. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18102. var operationCostTotal float64 = 0 //手术费
  18103. var operationCostSelfTotal float64 = 0 //手术费
  18104. var operationCostPartSelfTotal float64 = 0 //手术费
  18105. var otherCostTotal float64 = 0 //其他费用
  18106. var otherCostSelfTotal float64 = 0 //其他费用
  18107. var otherCostPartSelfTotal float64 = 0 //其他费用
  18108. var materialCostTotal float64 = 0 //材料费
  18109. var materialCostSelfTotal float64 = 0 //材料费
  18110. var materialCostPartSelfTotal float64 = 0 //材料费
  18111. var westernMedicineCostTotal float64 = 0 //西药费
  18112. var westernMedicineCostSelfTotal float64 = 0 //西药费
  18113. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18114. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18115. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18116. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18117. var checkCostTotal float64 = 0 //检查费
  18118. var checkCostSelfTotal float64 = 0 //检查费
  18119. var checkCostPartSelfTotal float64 = 0 //检查费
  18120. var laboratoryCostTotal float64 = 0 //化验费
  18121. var laboratoryCostSelfTotal float64 = 0 //化验费
  18122. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18123. var treatCostTotal float64 = 0 //治疗费用
  18124. var treatCostSelfTotal float64 = 0 //治疗费用
  18125. var treatCostPartSelfTotal float64 = 0 //治疗费用
  18126. decimal.DivisionPrecision = 2
  18127. var bed_fulamt_ownpay_amt float64 = 0
  18128. var operation_fulamt_ownpay_amt float64 = 0
  18129. var other_fulamt_ownpay_amt float64 = 0
  18130. var westernMedicine_fulamt_ownpay_amt float64 = 0
  18131. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18132. var check_fulamt_ownpay_amt float64 = 0
  18133. var material_fulamt_ownpay_amt float64 = 0
  18134. var laboratory_fulamt_ownpay_amt float64 = 0
  18135. var treat_fulamt_ownpay_amt float64 = 0
  18136. var bed_claa_sunmfee float64 = 0
  18137. var bed_clab_amt float64 = 0
  18138. var bed_other_amt float64 = 0
  18139. var operation_claa_sunmfee float64 = 0
  18140. var operation_clab_amt float64 = 0
  18141. var operation_other_amt float64 = 0
  18142. var other_claa_sunmfee float64 = 0
  18143. var other_clab_amt float64 = 0
  18144. var other_other_amt float64 = 0
  18145. var westernMedicine_claa_sunmfee float64 = 0
  18146. var westernMedicine_clab_amt float64 = 0
  18147. var westernMedicine_other_amt float64 = 0
  18148. var chineseTraditional_claa_sunmfee float64 = 0
  18149. var chineseTraditional_clab_amt float64 = 0
  18150. var chineseTraditional_other_amt float64 = 0
  18151. var check_claa_sunmfee float64 = 0
  18152. var check_clab_amt float64 = 0
  18153. var check_other_amt float64 = 0
  18154. var material_claa_sunmfee float64 = 0
  18155. var material_clab_amt float64 = 0
  18156. var material_other_amt float64 = 0
  18157. var laboratory_claa_sunmfee float64 = 0
  18158. var laboratory_clab_amt float64 = 0
  18159. var laboratory_other_amt float64 = 0
  18160. var treat_claa_sunmfee float64 = 0
  18161. var treat_clab_amt float64 = 0
  18162. var treat_other_amt float64 = 0
  18163. for _, item := range order.HisOrderInfo {
  18164. if item.MedChrgitmType == "01" { //床位费
  18165. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18166. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18167. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18168. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18169. if item.ChrgitmLv == "1" {
  18170. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18171. }
  18172. if item.ChrgitmLv == "2" {
  18173. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18174. }
  18175. if item.ChrgitmLv == "3" {
  18176. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18177. }
  18178. }
  18179. if item.MedChrgitmType == "03" { //检查费
  18180. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18181. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18182. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18183. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18184. if item.ChrgitmLv == "1" {
  18185. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18186. }
  18187. if item.ChrgitmLv == "2" {
  18188. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18189. }
  18190. if item.ChrgitmLv == "3" {
  18191. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18192. }
  18193. }
  18194. if item.MedChrgitmType == "04" { //化验费
  18195. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18196. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18197. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18198. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18199. if item.ChrgitmLv == "1" {
  18200. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18201. }
  18202. if item.ChrgitmLv == "2" {
  18203. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18204. }
  18205. if item.ChrgitmLv == "3" {
  18206. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18207. }
  18208. }
  18209. if item.MedChrgitmType == "05" { //治疗费
  18210. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18211. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18212. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18213. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18214. if item.ChrgitmLv == "1" {
  18215. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18216. }
  18217. if item.ChrgitmLv == "2" {
  18218. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18219. }
  18220. if item.ChrgitmLv == "3" {
  18221. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18222. }
  18223. }
  18224. if item.MedChrgitmType == "06" { //手术费
  18225. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18226. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18227. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18228. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18229. if item.ChrgitmLv == "1" {
  18230. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18231. }
  18232. if item.ChrgitmLv == "2" {
  18233. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18234. }
  18235. if item.ChrgitmLv == "3" {
  18236. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18237. }
  18238. }
  18239. if item.MedChrgitmType == "08" { //材料费
  18240. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18241. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18242. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18243. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18244. if item.ChrgitmLv == "1" {
  18245. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18246. }
  18247. if item.ChrgitmLv == "2" {
  18248. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18249. }
  18250. if item.ChrgitmLv == "3" {
  18251. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18252. }
  18253. }
  18254. if item.MedChrgitmType == "09" { //西药费
  18255. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18256. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18257. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18258. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18259. if item.ChrgitmLv == "1" {
  18260. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18261. }
  18262. if item.ChrgitmLv == "2" {
  18263. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18264. }
  18265. if item.ChrgitmLv == "3" {
  18266. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18267. }
  18268. }
  18269. if item.MedChrgitmType == "11" { //中成费
  18270. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18271. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18272. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18273. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18274. if item.ChrgitmLv == "1" {
  18275. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18276. }
  18277. if item.ChrgitmLv == "2" {
  18278. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18279. }
  18280. if item.ChrgitmLv == "3" {
  18281. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18282. }
  18283. }
  18284. if item.MedChrgitmType == "14" { //其他费
  18285. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18286. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18287. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18288. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18289. if item.ChrgitmLv == "1" {
  18290. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18291. }
  18292. if item.ChrgitmLv == "2" {
  18293. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18294. }
  18295. if item.ChrgitmLv == "3" {
  18296. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18297. }
  18298. }
  18299. }
  18300. var iteminfoStructs []service.IteminfoStruct
  18301. if bedCostTotal != 0 {
  18302. iteminfo.MedChrgitm = "01"
  18303. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18304. iteminfo.Amt = bedCostTotal
  18305. iteminfo.ClaaSumfee = bed_claa_sunmfee
  18306. iteminfo.ClabAmt = bed_clab_amt
  18307. iteminfo.OthAmt = bed_other_amt
  18308. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18309. }
  18310. if checkCostTotal != 0 {
  18311. iteminfo.MedChrgitm = "03"
  18312. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  18313. iteminfo.Amt = checkCostTotal
  18314. iteminfo.ClaaSumfee = check_claa_sunmfee
  18315. iteminfo.ClabAmt = check_clab_amt
  18316. iteminfo.OthAmt = check_other_amt
  18317. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18318. }
  18319. if laboratoryCostTotal != 0 {
  18320. iteminfo.MedChrgitm = "04"
  18321. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  18322. iteminfo.Amt = laboratoryCostTotal
  18323. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  18324. iteminfo.ClabAmt = laboratory_clab_amt
  18325. iteminfo.OthAmt = laboratory_other_amt
  18326. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18327. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18328. }
  18329. if treatCostTotal != 0 {
  18330. iteminfo.MedChrgitm = "05"
  18331. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  18332. iteminfo.Amt = treatCostTotal
  18333. iteminfo.ClaaSumfee = treat_claa_sunmfee
  18334. iteminfo.ClabAmt = treat_clab_amt
  18335. iteminfo.OthAmt = treat_other_amt
  18336. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18337. //(struct4101.IteminfoStruct, iteminfo)
  18338. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18339. }
  18340. if operationCostTotal != 0 {
  18341. iteminfo.MedChrgitm = "06"
  18342. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  18343. iteminfo.Amt = operationCostTotal
  18344. iteminfo.ClaaSumfee = operation_claa_sunmfee
  18345. iteminfo.ClabAmt = operation_clab_amt
  18346. iteminfo.OthAmt = operation_other_amt
  18347. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18348. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18349. }
  18350. if materialCostTotal != 0 {
  18351. iteminfo.MedChrgitm = "08"
  18352. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  18353. iteminfo.Amt = materialCostTotal
  18354. iteminfo.ClaaSumfee = material_claa_sunmfee
  18355. iteminfo.ClabAmt = material_clab_amt
  18356. iteminfo.OthAmt = material_other_amt
  18357. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18358. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18359. }
  18360. if westernMedicineCostTotal != 0 {
  18361. iteminfo.MedChrgitm = "09"
  18362. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18363. iteminfo.Amt = westernMedicineCostTotal
  18364. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18365. iteminfo.ClabAmt = westernMedicine_clab_amt
  18366. iteminfo.OthAmt = westernMedicine_other_amt
  18367. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18368. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18369. }
  18370. if chineseTraditionalMedicineCostTotal != 0 {
  18371. iteminfo.MedChrgitm = "11"
  18372. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  18373. iteminfo.Amt = westernMedicineCostTotal
  18374. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  18375. iteminfo.ClabAmt = westernMedicine_clab_amt
  18376. iteminfo.OthAmt = westernMedicine_other_amt
  18377. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18378. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18379. }
  18380. if otherCostTotal != 0 {
  18381. iteminfo.MedChrgitm = "14"
  18382. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  18383. iteminfo.Amt = otherCostTotal
  18384. iteminfo.ClaaSumfee = other_claa_sunmfee
  18385. iteminfo.ClabAmt = other_clab_amt
  18386. iteminfo.OthAmt = other_other_amt
  18387. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  18388. iteminfoStructs = append(iteminfoStructs, iteminfo)
  18389. }
  18390. struct4101.IteminfoStruct = iteminfoStructs
  18391. struct4101.Ntly = "中国"
  18392. struct4101.AdmCaty = "A03.06"
  18393. var resOther ResultSeventeenOther
  18394. var res ResultSeventeen
  18395. if miConfig.MdtrtareaAdmvs == "150499" {
  18396. var pp models.PublicParams
  18397. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  18398. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18399. pp.FixmedinsName = miConfig.OrgName
  18400. pp.FixmedinsCode = miConfig.Code
  18401. pp.RequestUrl = miConfig.Url
  18402. pp.Cainfo = miConfig.Cainfo
  18403. pp.SecretKey = miConfig.SecretKey
  18404. pp.AccessKey = miConfig.AccessKey
  18405. pp.OpterName = curRoles.UserName
  18406. client := &http.Client{}
  18407. var req *http.Request
  18408. data := make(map[string]interface{})
  18409. data["struct4101"] = struct4101
  18410. data["pp"] = pp
  18411. bytesData, _ := json.Marshal(data)
  18412. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  18413. resp, _ := client.Do(req)
  18414. defer resp.Body.Close()
  18415. body, ioErr := ioutil.ReadAll(resp.Body)
  18416. if ioErr != nil {
  18417. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18419. return
  18420. }
  18421. var respJSON map[string]interface{}
  18422. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18423. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18425. return
  18426. }
  18427. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18428. userJSONBytes, _ := json.Marshal(respJSON)
  18429. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  18430. utils.ErrorLog("解析失败:%v", err)
  18431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18432. return
  18433. }
  18434. res.InfRefmsgid = resOther.InfRefmsgid
  18435. res.Output = resOther.Output
  18436. res.ErrMsg = resOther.ErrMsg
  18437. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  18438. res.Infcode = infocode
  18439. } else if miConfig.MdtrtareaAdmvs == "360302" {
  18440. var pp models.PublicParams
  18441. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  18442. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  18443. pp.FixmedinsName = miConfig.OrgName
  18444. pp.FixmedinsCode = miConfig.Code
  18445. pp.RequestUrl = miConfig.Url
  18446. pp.Cainfo = miConfig.Cainfo
  18447. pp.SecretKey = miConfig.SecretKey
  18448. pp.AccessKey = miConfig.AccessKey
  18449. pp.OpterName = curRoles.UserName
  18450. result, _ := service.Jxyb4101(struct4101, pp)
  18451. var dat map[string]interface{}
  18452. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18453. fmt.Println(dat)
  18454. } else {
  18455. fmt.Println(err)
  18456. }
  18457. userJSONBytes, _ := json.Marshal(dat)
  18458. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18459. utils.ErrorLog("解析失败:%v", err)
  18460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18461. return
  18462. }
  18463. } else {
  18464. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  18465. var dat map[string]interface{}
  18466. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18467. fmt.Println(dat)
  18468. } else {
  18469. fmt.Println(err)
  18470. }
  18471. userJSONBytes, _ := json.Marshal(dat)
  18472. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18473. utils.ErrorLog("解析失败:%v", err)
  18474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18475. return
  18476. }
  18477. }
  18478. if res.Infcode != 0 {
  18479. c.ServeSuccessJSON(map[string]interface{}{
  18480. "failed_code": -10,
  18481. "msg": res.ErrMsg,
  18482. })
  18483. return
  18484. } else {
  18485. if miConfig.MdtrtareaAdmvs != "150499" {
  18486. order.FaPiaoNumber = zero
  18487. order.FaPiaoCode = last_order.FaPiaoCode
  18488. service.UpdateOrder(order)
  18489. }
  18490. hisFundSettleListResult := &models.HisFundSettleListResult{
  18491. Number: res.Output.SetlListId,
  18492. Status: 1,
  18493. Ctime: time.Now().Unix(),
  18494. Mtime: time.Now().Unix(),
  18495. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18496. IsUpload: 1,
  18497. OrderId: order_id,
  18498. }
  18499. service.CreateUploadRecord(hisFundSettleListResult)
  18500. c.ServeSuccessJSON(map[string]interface{}{
  18501. "msg": "上传成功",
  18502. "result": hisFundSettleListResult,
  18503. })
  18504. return
  18505. }
  18506. }
  18507. //func (c *HisApiController) GetBatchSettleList() {
  18508. // orders, _ := service.GetAllHisOrder(10106)
  18509. // for _, item := range orders {
  18510. // order_id := item.ID
  18511. // order, _ := service.GetHisOrderByIDTwo(order_id)
  18512. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18513. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18514. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18515. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  18516. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18517. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18518. //
  18519. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18520. //
  18521. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18522. //
  18523. // if order.ID == 0 {
  18524. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  18525. // return
  18526. // }
  18527. // if his.BalanceAccountsType == 2 {
  18528. // continue
  18529. // }
  18530. // struct4101 := service.Struct4101{
  18531. // PsnNo: order.PsnNo,
  18532. // MdtrtId: order.MdtrtId,
  18533. // SetlId: order.SetlId,
  18534. // PsnName: order.PsnName,
  18535. // Gend: order.Gend,
  18536. // Brdy: his.Brdy,
  18537. // Age: his.Age,
  18538. // Naty: order.Naty,
  18539. // PatnCertType: "01",
  18540. // Certno: order.Certno,
  18541. // Prfs: "90",
  18542. // ConerName: roles[0].UserName,
  18543. // PatnRlts: "99",
  18544. // ConerAddr: miConfig.OrgName,
  18545. // ConerTel: admin.Mobile,
  18546. // HiType: order.Insutype,
  18547. // Insuplc: his.InsuplcAdmdvs,
  18548. // MaindiagFlag: "1",
  18549. // BillCode: order.SetlId,
  18550. // BillNo: order.SetlId,
  18551. // BizSn: order.Number,
  18552. // PsnSelfPay: order.PsnPartAmt,
  18553. // PsnOwnPay: order.PsnPartAmt,
  18554. // AcctPay: order.AcctPay,
  18555. // PsnCashpay: order.PsnCashPay,
  18556. // HiPaymtd: "1",
  18557. // Hsorg: his.InsuplcAdmdvs,
  18558. // HsorgOpter: his.InsuplcAdmdvs,
  18559. // MedinsFillPsn: curRoles.UserName,
  18560. // MedinsFillDept: depart.Name,
  18561. // IptMedType: "2",
  18562. // }
  18563. // struct4101.SetlBegnDate = order.SetlTime
  18564. // struct4101.SetlEndDate = order.SetlTime
  18565. // //if order.SettleType == 1 {
  18566. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  18567. // // dateStr := t.Format("2006-01-02")
  18568. // // struct4101.SetlBegnDate = dateStr
  18569. // // struct4101.SetlEndDate = dateStr
  18570. // //} else {
  18571. // // t := time.Unix(int64(order.SettleStartTime), 0)
  18572. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  18573. // // dateStartStr := t.Format("2006-01-02")
  18574. // // dateEndStr := t2.Format("2006-01-02")
  18575. // // struct4101.SetlBegnDate = dateStartStr
  18576. // // struct4101.SetlEndDate = dateEndStr
  18577. // //}
  18578. //
  18579. // var rf []CustomFundPay
  18580. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  18581. //
  18582. // var tempFunPays []service.CustomStruct
  18583. // var tempFunPay610100 service.CustomStruct
  18584. //
  18585. // for _, item := range rf {
  18586. // if item.FundPayType == "610100" {
  18587. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  18588. // tempFunPay610100.FundPayType = item.FundPayType
  18589. // } else {
  18590. // var tempFunPay service.CustomStruct
  18591. // tempFunPay.FundPayamt = item.FundPayamt
  18592. // tempFunPay.FundPayType = item.FundPayType
  18593. // tempFunPays = append(tempFunPays, tempFunPay)
  18594. // }
  18595. // }
  18596. // tempFunPays = append(tempFunPays, tempFunPay610100)
  18597. // struct4101.CustomStruct = tempFunPays
  18598. //
  18599. // var tempDiaginfos []service.DiaginfoStructTwo
  18600. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18601. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18602. //
  18603. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18604. // var config []*models.HisXtDiagnoseConfig
  18605. // for _, item := range diagnosis_ids {
  18606. // id, _ := strconv.ParseInt(item, 10, 64)
  18607. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  18608. // config = append(config, &diagnosisConfig)
  18609. // }
  18610. //
  18611. // for index, item := range config {
  18612. // if index == 0 {
  18613. // var tempDiaginfo service.DiaginfoStructTwo
  18614. // tempDiaginfo.DiagCode = item.CountryCode
  18615. // tempDiaginfo.DiagName = item.CountryContentName
  18616. // tempDiaginfo.DiagType = "1"
  18617. // tempDiaginfo.MaindiagFlag = "1"
  18618. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18619. // } else {
  18620. //
  18621. // var tempDiaginfo service.DiaginfoStructTwo
  18622. // tempDiaginfo.DiagCode = item.CountryCode
  18623. // tempDiaginfo.DiagName = item.CountryContentName
  18624. // tempDiaginfo.DiagType = "2"
  18625. // tempDiaginfo.MaindiagFlag = "0"
  18626. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18627. // }
  18628. // }
  18629. // struct4101.Diseinfo = tempDiaginfos
  18630. //
  18631. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  18632. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18633. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18634. // tempOpspdiseinfo2.OprnOprtCode = ""
  18635. // tempOpspdiseinfo2.OprnOprtName = ""
  18636. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18637. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18638. //
  18639. // var iteminfo service.IteminfoStruct
  18640. //
  18641. // var bedCostTotal float64 = 0 //床位总费
  18642. // var bedCostSelfTotal float64 = 0 //床位自费
  18643. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18644. //
  18645. // var examineCostTotal float64 = 0 //诊查总费
  18646. // var examineCostSelfTotal float64 = 0 //诊查自费
  18647. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  18648. //
  18649. // var nursingCostTotal float64 = 0 //护理总费
  18650. // var nursingCostSelfTotal float64 = 0 //护理自费
  18651. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  18652. //
  18653. // var chineseMedicineCostTotal float64 = 0 //中成药
  18654. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  18655. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  18656. //
  18657. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  18658. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  18659. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  18660. //
  18661. // var registerCostTotal float64 = 0 //一般诊疗费
  18662. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  18663. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  18664. //
  18665. // var operationCostTotal float64 = 0 //手术费
  18666. // var operationCostSelfTotal float64 = 0 //手术费
  18667. // var operationCostPartSelfTotal float64 = 0 //手术费
  18668. //
  18669. // var otherCostTotal float64 = 0 //其他费用
  18670. // var otherCostSelfTotal float64 = 0 //其他费用
  18671. // var otherCostPartSelfTotal float64 = 0 //其他费用
  18672. //
  18673. // var materialCostTotal float64 = 0 //材料费
  18674. // var materialCostSelfTotal float64 = 0 //材料费
  18675. // var materialCostPartSelfTotal float64 = 0 //材料费
  18676. //
  18677. // var westernMedicineCostTotal float64 = 0 //西药费
  18678. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  18679. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18680. //
  18681. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18682. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18683. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18684. //
  18685. // var checkCostTotal float64 = 0 //检查费
  18686. // var checkCostSelfTotal float64 = 0 //检查费
  18687. // var checkCostPartSelfTotal float64 = 0 //检查费
  18688. //
  18689. // var laboratoryCostTotal float64 = 0 //化验费
  18690. // var laboratoryCostSelfTotal float64 = 0 //化验费
  18691. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18692. //
  18693. // var treatCostTotal float64 = 0 //治疗费用
  18694. // var treatCostSelfTotal float64 = 0 //治疗费用
  18695. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  18696. //
  18697. // decimal.DivisionPrecision = 2
  18698. //
  18699. // var bed_fulamt_ownpay_amt float64 = 0
  18700. //
  18701. // var examine_fulamt_ownpay_amt float64 = 0
  18702. //
  18703. // var nursing_fulamt_ownpay_amt float64 = 0
  18704. //
  18705. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  18706. //
  18707. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  18708. //
  18709. // var register_fulamt_ownpay_amt float64 = 0
  18710. //
  18711. // var operation_fulamt_ownpay_amt float64 = 0
  18712. // var other_fulamt_ownpay_amt float64 = 0
  18713. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  18714. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18715. // var check_fulamt_ownpay_amt float64 = 0
  18716. // var material_fulamt_ownpay_amt float64 = 0
  18717. // var laboratory_fulamt_ownpay_amt float64 = 0
  18718. // var treat_fulamt_ownpay_amt float64 = 0
  18719. //
  18720. // var bed_claa_sunmfee float64 = 0
  18721. // var bed_clab_amt float64 = 0
  18722. // var bed_other_amt float64 = 0
  18723. //
  18724. // var examine_claa_sunmfee float64 = 0
  18725. // var examine_clab_amt float64 = 0
  18726. // var examine_other_amt float64 = 0
  18727. //
  18728. // var nursing_claa_sunmfee float64 = 0
  18729. // var nursing_clab_amt float64 = 0
  18730. // var nursing_other_amt float64 = 0
  18731. //
  18732. // var chinese_medicine_claa_sunmfee float64 = 0
  18733. // var chinese_medicine_clab_amt float64 = 0
  18734. // var chinese_medicine_other_amt float64 = 0
  18735. //
  18736. // var commonly_treatment_claa_sunmfee float64 = 0
  18737. // var commonly_treatment_clab_amt float64 = 0
  18738. // var commonly_treatment_other_amt float64 = 0
  18739. //
  18740. // var operation_claa_sunmfee float64 = 0
  18741. // var operation_clab_amt float64 = 0
  18742. // var operation_other_amt float64 = 0
  18743. //
  18744. // var other_claa_sunmfee float64 = 0
  18745. // var other_clab_amt float64 = 0
  18746. // var other_other_amt float64 = 0
  18747. //
  18748. // var westernMedicine_claa_sunmfee float64 = 0
  18749. // var westernMedicine_clab_amt float64 = 0
  18750. // var westernMedicine_other_amt float64 = 0
  18751. //
  18752. // var chineseTraditional_claa_sunmfee float64 = 0
  18753. // var chineseTraditional_clab_amt float64 = 0
  18754. // var chineseTraditional_other_amt float64 = 0
  18755. //
  18756. // var check_claa_sunmfee float64 = 0
  18757. // var check_clab_amt float64 = 0
  18758. // var check_other_amt float64 = 0
  18759. //
  18760. // var material_claa_sunmfee float64 = 0
  18761. // var material_clab_amt float64 = 0
  18762. // var material_other_amt float64 = 0
  18763. //
  18764. // var laboratory_claa_sunmfee float64 = 0
  18765. // var laboratory_clab_amt float64 = 0
  18766. // var laboratory_other_amt float64 = 0
  18767. //
  18768. // var treat_claa_sunmfee float64 = 0
  18769. // var treat_clab_amt float64 = 0
  18770. // var treat_other_amt float64 = 0
  18771. //
  18772. // var register_claa_sunmfee float64 = 0
  18773. // var register_clab_amt float64 = 0
  18774. // var register_other_amt float64 = 0
  18775. //
  18776. // for _, item := range order.HisOrderInfo {
  18777. // if item.MedChrgitmType == "01" { //床位费
  18778. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18779. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18780. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18781. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18782. // if item.ChrgitmLv == "1" {
  18783. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18784. // }
  18785. // if item.ChrgitmLv == "2" {
  18786. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18787. //
  18788. // }
  18789. // if item.ChrgitmLv == "3" {
  18790. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18791. // }
  18792. //
  18793. // }
  18794. //
  18795. // if item.MedChrgitmType == "02" { //诊查
  18796. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18797. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18798. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18799. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18800. // if item.ChrgitmLv == "1" {
  18801. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18802. // }
  18803. // if item.ChrgitmLv == "2" {
  18804. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18805. //
  18806. // }
  18807. // if item.ChrgitmLv == "3" {
  18808. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18809. // }
  18810. //
  18811. // }
  18812. //
  18813. // if item.MedChrgitmType == "03" { //检查费
  18814. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18815. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18816. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18817. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18818. // if item.ChrgitmLv == "1" {
  18819. //
  18820. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18821. //
  18822. // }
  18823. // if item.ChrgitmLv == "2" {
  18824. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18825. //
  18826. // }
  18827. // if item.ChrgitmLv == "3" {
  18828. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18829. // }
  18830. // }
  18831. //
  18832. // if item.MedChrgitmType == "04" { //化验费
  18833. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18834. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18835. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18836. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18837. // if item.ChrgitmLv == "1" {
  18838. //
  18839. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18840. //
  18841. // }
  18842. // if item.ChrgitmLv == "2" {
  18843. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18844. //
  18845. // }
  18846. // if item.ChrgitmLv == "3" {
  18847. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18848. // }
  18849. // }
  18850. //
  18851. // if item.MedChrgitmType == "05" { //治疗费
  18852. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18853. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18854. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18855. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18856. // if item.ChrgitmLv == "1" {
  18857. //
  18858. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18859. //
  18860. // }
  18861. // if item.ChrgitmLv == "2" {
  18862. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18863. //
  18864. // }
  18865. // if item.ChrgitmLv == "3" {
  18866. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18867. // }
  18868. // }
  18869. //
  18870. // if item.MedChrgitmType == "06" { //手术费
  18871. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18872. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18873. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18874. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18875. //
  18876. // if item.ChrgitmLv == "1" {
  18877. //
  18878. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18879. //
  18880. // }
  18881. // if item.ChrgitmLv == "2" {
  18882. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18883. //
  18884. // }
  18885. // if item.ChrgitmLv == "3" {
  18886. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18887. // }
  18888. // }
  18889. //
  18890. // if item.MedChrgitmType == "07" { //手术费
  18891. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18892. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18893. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18894. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18895. //
  18896. // if item.ChrgitmLv == "1" {
  18897. //
  18898. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18899. //
  18900. // }
  18901. // if item.ChrgitmLv == "2" {
  18902. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18903. //
  18904. // }
  18905. // if item.ChrgitmLv == "3" {
  18906. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18907. // }
  18908. // }
  18909. //
  18910. // if item.MedChrgitmType == "08" { //材料费
  18911. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18912. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18913. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18914. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18915. // if item.ChrgitmLv == "1" {
  18916. //
  18917. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18918. //
  18919. // }
  18920. // if item.ChrgitmLv == "2" {
  18921. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18922. //
  18923. // }
  18924. // if item.ChrgitmLv == "3" {
  18925. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18926. // }
  18927. // }
  18928. // if item.MedChrgitmType == "09" { //西药费
  18929. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18930. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18931. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18932. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18933. // if item.ChrgitmLv == "1" {
  18934. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18935. // }
  18936. // if item.ChrgitmLv == "2" {
  18937. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18938. // }
  18939. // if item.ChrgitmLv == "3" {
  18940. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18941. // }
  18942. // }
  18943. // if item.MedChrgitmType == "10" { //中药饮片
  18944. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18945. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18946. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18947. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18948. // if item.ChrgitmLv == "1" {
  18949. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18950. // }
  18951. // if item.ChrgitmLv == "2" {
  18952. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18953. // }
  18954. // if item.ChrgitmLv == "3" {
  18955. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18956. // }
  18957. // }
  18958. //
  18959. // if item.MedChrgitmType == "11" { //中成费
  18960. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18961. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18962. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18963. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18964. // if item.ChrgitmLv == "1" {
  18965. //
  18966. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18967. //
  18968. // }
  18969. // if item.ChrgitmLv == "2" {
  18970. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18971. //
  18972. // }
  18973. // if item.ChrgitmLv == "3" {
  18974. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18975. // }
  18976. // }
  18977. //
  18978. // if item.MedChrgitmType == "12" { //中成费
  18979. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18980. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18981. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18982. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18983. // if item.ChrgitmLv == "1" {
  18984. //
  18985. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18986. //
  18987. // }
  18988. // if item.ChrgitmLv == "2" {
  18989. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18990. //
  18991. // }
  18992. // if item.ChrgitmLv == "3" {
  18993. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18994. // }
  18995. // }
  18996. //
  18997. // if item.MedChrgitmType == "13" { //中成费
  18998. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18999. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19000. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19001. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19002. // if item.ChrgitmLv == "1" {
  19003. //
  19004. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19005. //
  19006. // }
  19007. // if item.ChrgitmLv == "2" {
  19008. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19009. //
  19010. // }
  19011. // if item.ChrgitmLv == "3" {
  19012. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19013. // }
  19014. // }
  19015. //
  19016. // if item.MedChrgitmType == "14" { //其他费
  19017. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19018. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19019. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19020. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19021. // if item.ChrgitmLv == "1" {
  19022. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19023. //
  19024. // }
  19025. // if item.ChrgitmLv == "2" {
  19026. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19027. //
  19028. // }
  19029. // if item.ChrgitmLv == "3" {
  19030. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19031. // }
  19032. // }
  19033. //
  19034. // }
  19035. //
  19036. // var iteminfoStructs []service.IteminfoStruct
  19037. //
  19038. // if bedCostTotal != 0 {
  19039. // iteminfo.MedChrgitm = "01"
  19040. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19041. // iteminfo.Amt = bedCostTotal
  19042. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  19043. // iteminfo.ClabAmt = bed_clab_amt
  19044. // iteminfo.OthAmt = bed_other_amt
  19045. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19046. // }
  19047. //
  19048. // if examineCostTotal != 0 {
  19049. // iteminfo.MedChrgitm = "02"
  19050. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  19051. // iteminfo.Amt = examineCostTotal
  19052. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  19053. // iteminfo.ClabAmt = examine_clab_amt
  19054. // iteminfo.OthAmt = examine_other_amt
  19055. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19056. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19057. // }
  19058. //
  19059. // if checkCostTotal != 0 {
  19060. // iteminfo.MedChrgitm = "03"
  19061. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19062. // iteminfo.Amt = checkCostTotal
  19063. // iteminfo.ClaaSumfee = check_claa_sunmfee
  19064. // iteminfo.ClabAmt = check_clab_amt
  19065. // iteminfo.OthAmt = check_other_amt
  19066. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19067. //
  19068. // }
  19069. //
  19070. // if laboratoryCostTotal != 0 {
  19071. // iteminfo.MedChrgitm = "04"
  19072. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19073. // iteminfo.Amt = laboratoryCostTotal
  19074. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19075. // iteminfo.ClabAmt = laboratory_clab_amt
  19076. // iteminfo.OthAmt = laboratory_other_amt
  19077. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19078. //
  19079. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19080. //
  19081. // }
  19082. //
  19083. // if treatCostTotal != 0 {
  19084. // iteminfo.MedChrgitm = "05"
  19085. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19086. // iteminfo.Amt = treatCostTotal
  19087. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  19088. // iteminfo.ClabAmt = treat_clab_amt
  19089. // iteminfo.OthAmt = treat_other_amt
  19090. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19091. // //(struct4101.IteminfoStruct, iteminfo)
  19092. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19093. // }
  19094. //
  19095. // if operationCostTotal != 0 {
  19096. // iteminfo.MedChrgitm = "06"
  19097. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19098. // iteminfo.Amt = operationCostTotal
  19099. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  19100. // iteminfo.ClabAmt = operation_clab_amt
  19101. // iteminfo.OthAmt = operation_other_amt
  19102. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19103. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19104. // }
  19105. //
  19106. // if nursingCostTotal != 0 {
  19107. // iteminfo.MedChrgitm = "07"
  19108. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  19109. // iteminfo.Amt = nursingCostTotal
  19110. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  19111. // iteminfo.ClabAmt = nursing_clab_amt
  19112. // iteminfo.OthAmt = nursing_other_amt
  19113. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19114. // }
  19115. //
  19116. // if materialCostTotal != 0 {
  19117. // iteminfo.MedChrgitm = "08"
  19118. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19119. // iteminfo.Amt = materialCostTotal
  19120. // iteminfo.ClaaSumfee = material_claa_sunmfee
  19121. // iteminfo.ClabAmt = material_clab_amt
  19122. // iteminfo.OthAmt = material_other_amt
  19123. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19124. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19125. // }
  19126. //
  19127. // if westernMedicineCostTotal != 0 {
  19128. // iteminfo.MedChrgitm = "09"
  19129. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19130. // iteminfo.Amt = westernMedicineCostTotal
  19131. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19132. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19133. // iteminfo.OthAmt = westernMedicine_other_amt
  19134. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19135. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19136. //
  19137. // }
  19138. //
  19139. // if chineseMedicineCostTotal != 0 {
  19140. // iteminfo.MedChrgitm = "10"
  19141. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  19142. // iteminfo.Amt = chineseMedicineCostTotal
  19143. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  19144. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  19145. // iteminfo.OthAmt = chinese_medicine_other_amt
  19146. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19147. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19148. //
  19149. // }
  19150. //
  19151. // if chineseTraditionalMedicineCostTotal != 0 {
  19152. // iteminfo.MedChrgitm = "11"
  19153. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19154. // iteminfo.Amt = westernMedicineCostTotal
  19155. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19156. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19157. // iteminfo.OthAmt = westernMedicine_other_amt
  19158. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19159. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19160. //
  19161. // }
  19162. //
  19163. // if commonlyTreatmentCostTotal != 0 {
  19164. // iteminfo.MedChrgitm = "12"
  19165. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  19166. // iteminfo.Amt = commonlyTreatmentCostTotal
  19167. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  19168. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  19169. // iteminfo.OthAmt = commonly_treatment_other_amt
  19170. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19171. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19172. //
  19173. // }
  19174. //
  19175. // if registerCostTotal != 0 {
  19176. // iteminfo.MedChrgitm = "13"
  19177. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  19178. // iteminfo.Amt = registerCostTotal
  19179. // iteminfo.ClaaSumfee = register_claa_sunmfee
  19180. // iteminfo.ClabAmt = register_clab_amt
  19181. // iteminfo.OthAmt = register_other_amt
  19182. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19183. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19184. //
  19185. // }
  19186. //
  19187. // if otherCostTotal != 0 {
  19188. // iteminfo.MedChrgitm = "14"
  19189. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19190. // iteminfo.Amt = otherCostTotal
  19191. // iteminfo.ClaaSumfee = other_claa_sunmfee
  19192. // iteminfo.ClabAmt = other_clab_amt
  19193. // iteminfo.OthAmt = other_other_amt
  19194. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19195. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19196. //
  19197. // }
  19198. // struct4101.IteminfoStruct = iteminfoStructs
  19199. // time_arr := strings.Split(order.SetlTime, " ")
  19200. // struct4101.AdmTime = time_arr[0]
  19201. // struct4101.AdmEndTime = time_arr[0]
  19202. //
  19203. // struct4101.DoctorName = doctor.UserName
  19204. // struct4101.DoctorCode = doctor.DoctorNumber
  19205. //
  19206. // struct4101.Ntly = "中国"
  19207. // struct4101.AdmCaty = "A03.06"
  19208. // var res ResultSeventeen
  19209. // if miConfig.MdtrtareaAdmvs == "421300" {
  19210. // data := make(map[string]interface{})
  19211. // data["struct4101"] = struct4101
  19212. // data["secret_key"] = miConfig.SecretKey
  19213. // data["org_name"] = miConfig.OrgName
  19214. // data["opera"] = curRoles.UserName
  19215. // data["code"] = miConfig.Code
  19216. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  19217. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19218. //
  19219. // client := &http.Client{}
  19220. // bytesData, _ := json.Marshal(data)
  19221. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  19222. // resp, _ := client.Do(req)
  19223. // defer resp.Body.Close()
  19224. // body, ioErr := ioutil.ReadAll(resp.Body)
  19225. // if ioErr != nil {
  19226. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19227. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19228. // return
  19229. // }
  19230. // var respJSON map[string]interface{}
  19231. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19232. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19233. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19234. // return
  19235. // }
  19236. //
  19237. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19238. // userJSONBytes, _ := json.Marshal(respJSON)
  19239. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19240. // utils.ErrorLog("解析失败:%v", err)
  19241. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19242. // adminUser := c.GetAdminUserInfo()
  19243. // errlog := &models.HisOrderError{
  19244. // UserOrgId: adminUser.CurrentOrgId,
  19245. // Ctime: time.Now().Unix(),
  19246. // Mtime: time.Now().Unix(),
  19247. // ErrMsg: res.ErrMsg + "解析失败",
  19248. // Status: 1,
  19249. // PatientId: order_id,
  19250. // Stage: 10088,
  19251. // }
  19252. // service.CreateErrMsgLog(errlog)
  19253. // continue
  19254. // }
  19255. //
  19256. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  19257. // data := make(map[string]interface{})
  19258. // data["struct4101"] = struct4101
  19259. // data["secret_key"] = miConfig.SecretKey
  19260. // data["org_name"] = miConfig.OrgName
  19261. // data["opera"] = curRoles.UserName
  19262. // data["code"] = miConfig.Code
  19263. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  19264. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19265. //
  19266. // client := &http.Client{}
  19267. // bytesData, _ := json.Marshal(data)
  19268. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  19269. // resp, _ := client.Do(req)
  19270. // defer resp.Body.Close()
  19271. // body, ioErr := ioutil.ReadAll(resp.Body)
  19272. // if ioErr != nil {
  19273. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19274. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19275. // return
  19276. // }
  19277. // var respJSON map[string]interface{}
  19278. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19279. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19280. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19281. // return
  19282. // }
  19283. //
  19284. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19285. // userJSONBytes, _ := json.Marshal(respJSON)
  19286. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19287. // utils.ErrorLog("解析失败:%v", err)
  19288. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19289. // adminUser := c.GetAdminUserInfo()
  19290. // errlog := &models.HisOrderError{
  19291. // UserOrgId: adminUser.CurrentOrgId,
  19292. // Ctime: time.Now().Unix(),
  19293. // Mtime: time.Now().Unix(),
  19294. // ErrMsg: res.ErrMsg + "解析失败",
  19295. // Status: 1,
  19296. // PatientId: order_id,
  19297. // Stage: 10088,
  19298. // }
  19299. // service.CreateErrMsgLog(errlog)
  19300. // continue
  19301. // }
  19302. //
  19303. // } else {
  19304. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  19305. // fmt.Println(result)
  19306. //
  19307. // var dat map[string]interface{}
  19308. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19309. // fmt.Println(dat)
  19310. // } else {
  19311. // fmt.Println(err)
  19312. // }
  19313. // userJSONBytes, _ := json.Marshal(dat)
  19314. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19315. // utils.ErrorLog("解析失败:%v", err)
  19316. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19317. // adminUser := c.GetAdminUserInfo()
  19318. // errlog := &models.HisOrderError{
  19319. // UserOrgId: adminUser.CurrentOrgId,
  19320. // Ctime: time.Now().Unix(),
  19321. // Mtime: time.Now().Unix(),
  19322. // ErrMsg: res.ErrMsg + "解析失败",
  19323. // Status: 1,
  19324. // PatientId: order_id,
  19325. // Stage: 10106,
  19326. // }
  19327. // service.CreateErrMsgLog(errlog)
  19328. // continue
  19329. // }
  19330. // }
  19331. //
  19332. // if res.Infcode != 0 {
  19333. // adminUser := c.GetAdminUserInfo()
  19334. // errlog := &models.HisOrderError{
  19335. // UserOrgId: adminUser.CurrentOrgId,
  19336. // Ctime: time.Now().Unix(),
  19337. // Mtime: time.Now().Unix(),
  19338. // ErrMsg: res.ErrMsg,
  19339. // Status: 1,
  19340. // PatientId: order_id,
  19341. // Stage: 10106,
  19342. // }
  19343. // service.CreateErrMsgLog(errlog)
  19344. // continue
  19345. // } else {
  19346. // hisFundSettleListResult := &models.HisFundSettleListResult{
  19347. // Number: res.Output.SetlListId,
  19348. // Status: 1,
  19349. // Ctime: time.Now().Unix(),
  19350. // Mtime: time.Now().Unix(),
  19351. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19352. // IsUpload: 1,
  19353. // OrderId: order_id,
  19354. // }
  19355. // service.CreateUploadRecord(hisFundSettleListResult)
  19356. // continue
  19357. // }
  19358. // }
  19359. //}
  19360. func (c *HisApiController) GetOrgInfo() {
  19361. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  19362. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  19363. }
  19364. func (c *HisApiController) GetHisPatientInfo() {
  19365. medical_insurance_card := c.GetString("medical_insurance_card")
  19366. id_card_type, _ := c.GetInt64("id_card_type")
  19367. id_card := c.GetString("id_card")
  19368. adminInfo := c.GetAdminUserInfo()
  19369. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  19370. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  19371. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  19372. IdCardNo := ""
  19373. if id_card_type == 1 {
  19374. IdCardNo = medical_insurance_card
  19375. } else if id_card_type == 2 {
  19376. IdCardNo = id_card
  19377. }
  19378. if config.IsOpen == 1 {
  19379. 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
  19380. resp, requestErr := http.Get(api)
  19381. if requestErr != nil {
  19382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19383. return
  19384. }
  19385. defer resp.Body.Close()
  19386. body, ioErr := ioutil.ReadAll(resp.Body)
  19387. if ioErr != nil {
  19388. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19390. return
  19391. }
  19392. var respJSON map[string]interface{}
  19393. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19396. return
  19397. }
  19398. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19399. userJSONBytes, _ := json.Marshal(userJSON)
  19400. var res ResultTwo
  19401. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19402. utils.ErrorLog("解析失败:%v", err)
  19403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19404. return
  19405. }
  19406. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  19407. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  19408. infoStr := string(Iinfos)
  19409. idetinfoStr := string(Idetinfos)
  19410. if res.Infcode == 0 {
  19411. his := models.VMHisPatient{
  19412. Status: 1,
  19413. Ctime: time.Now().Unix(),
  19414. Mtime: time.Now().Unix(),
  19415. PsnNo: res.Output.Baseinfo.PsnNo,
  19416. PsnCertType: res.Output.Baseinfo.PsnCertType,
  19417. Certno: res.Output.Baseinfo.Certno,
  19418. PsnName: res.Output.Baseinfo.PsnName,
  19419. Gend: res.Output.Baseinfo.Gend,
  19420. Naty: res.Output.Baseinfo.Naty,
  19421. Iinfo: infoStr,
  19422. Idetinfo: idetinfoStr,
  19423. UserOrgId: adminInfo.CurrentOrgId,
  19424. IsReturn: 1,
  19425. IdCardType: id_card_type,
  19426. }
  19427. c.ServeSuccessJSON(map[string]interface{}{
  19428. "info": his,
  19429. })
  19430. } else {
  19431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  19432. return
  19433. }
  19434. }
  19435. }
  19436. //func GetBasBaseInfo() (jsonStr string, err error) {
  19437. //
  19438. // handle := syscall.NewLazyDLL("SSCard.dll")
  19439. // add := handle.NewProc("ReadCardBas")
  19440. // str := make([]byte, 1024)
  19441. // str1 := make([]byte, 1024)
  19442. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  19443. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  19444. //
  19445. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  19446. //
  19447. // fmt.Println("> Add(4,5)的结果为:", ret)
  19448. // handle.Release()
  19449. //
  19450. // return "", nil
  19451. //
  19452. //}
  19453. //func GetQRBaseInfo() (jsonStr string, err error) {
  19454. // handle := syscall.LoadDLL("SSCard.dll")
  19455. // ReadCardBas := handle.FindProc("GetQRBase")
  19456. //
  19457. // str := make([]byte, 256)
  19458. // str1 := make([]byte, 256)
  19459. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  19460. //
  19461. // fmt.Println(string(str))
  19462. // fmt.Println(r)
  19463. // return string(str), nil
  19464. //}
  19465. //func CardInit() int {
  19466. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  19467. // add := DllTestDef.MustFindProc("Init")
  19468. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  19469. // if err != nil {
  19470. // fmt.Println("SSCard的运算结果为:", ret)
  19471. // }
  19472. // result := int(ret)
  19473. // return result
  19474. //}
  19475. //func CardInit() int {
  19476. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  19477. // if err != nil {
  19478. // fmt.Println("SSCard的运算结果为:", ret)
  19479. // }
  19480. // fmt.Println(err)
  19481. // result := int(ret)
  19482. // return result
  19483. //}
  19484. func IntPtr(n int) uintptr {
  19485. return uintptr(n)
  19486. }
  19487. func StrPtr(s string) uintptr {
  19488. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  19489. }
  19490. type Result2001 struct {
  19491. Cainfo interface{} `json:"cainfo"`
  19492. ErrMsg string `json:"err_msg"`
  19493. InfRefmsgid string `json:"inf_refmsgid"`
  19494. Infcode int64 `json:"infcode"`
  19495. Output struct {
  19496. Trtinfo struct {
  19497. PsnNo string `json:"psn_no"`
  19498. TrtChkType string `json:"trt_chk_type"`
  19499. FundPayType string `json:"fund_pay_type"`
  19500. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  19501. Begndate string `json:"begndate"`
  19502. Enddate string `json:"enddate"`
  19503. TrtChkRslt string `json:"trt_chk_rslt"`
  19504. } `json:"trtinfo"`
  19505. } `json:"output"`
  19506. RefmsgTime string `json:"refmsg_time"`
  19507. RespondTime string `json:"respond_time"`
  19508. Signtype interface{} `json:"signtype"`
  19509. WarnMsg interface{} `json:"warn_msg"`
  19510. }
  19511. type Result2001Org10265 struct {
  19512. Cainfo interface{} `json:"cainfo"`
  19513. ErrMsg string `json:"err_msg"`
  19514. InfRefmsgid string `json:"inf_refmsgid"`
  19515. Infcode string `json:"infcode"`
  19516. Output struct {
  19517. Trtinfo struct {
  19518. PsnNo string `json:"psn_no"`
  19519. TrtChkType string `json:"trt_chk_type"`
  19520. FundPayType string `json:"fund_pay_type"`
  19521. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  19522. Begndate string `json:"begndate"`
  19523. Enddate string `json:"enddate"`
  19524. TrtChkRslt string `json:"trt_chk_rslt"`
  19525. } `json:"trtinfo"`
  19526. } `json:"output"`
  19527. RefmsgTime string `json:"refmsg_time"`
  19528. RespondTime string `json:"respond_time"`
  19529. Signtype interface{} `json:"signtype"`
  19530. WarnMsg interface{} `json:"warn_msg"`
  19531. }
  19532. type ResultTwo struct {
  19533. ErrMsg string `json:"err_msg"`
  19534. InfRefmsgid string `json:"inf_refmsgid"`
  19535. Infcode int64 `json:"infcode"`
  19536. Output struct {
  19537. Baseinfo struct {
  19538. //Brdy string `json:"brdy"`
  19539. Certno string `json:"certno"`
  19540. Gend string `json:"gend"`
  19541. Naty string `json:"naty"`
  19542. PsnCertType string `json:"psn_cert_type"`
  19543. PsnName string `json:"psn_name"`
  19544. PsnNo string `json:"psn_no"`
  19545. } `json:"baseinfo"`
  19546. Idetinfo []interface{} `json:"idetinfo"`
  19547. Iinfo []struct {
  19548. Balc float64 `json:"balc"`
  19549. CvlservFlag string `json:"cvlserv_flag"`
  19550. EmpName string `json:"emp_name"`
  19551. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  19552. Insutype string `json:"insutype"`
  19553. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  19554. //PausInsuDate string `json:"paus_insu_date"`
  19555. //PsnInsuDate string `json:"psn_insu_date"`
  19556. PsnInsuStas string `json:"psn_insu_stas"`
  19557. PsnType string `json:"psn_type"`
  19558. } `json:"insuinfo"`
  19559. } `json:"output"`
  19560. RefmsgTime string `json:"refmsg_time"`
  19561. RespondTime string `json:"respond_time"`
  19562. Signtype interface{} `json:"signtype"`
  19563. WarnInfo interface{} `json:"warn_info"`
  19564. }
  19565. type ResultTwo10265 struct {
  19566. ErrMsg string `json:"err_msg"`
  19567. InfRefmsgid string `json:"inf_refmsgid"`
  19568. Infcode string `json:"infcode"`
  19569. Output struct {
  19570. Baseinfo struct {
  19571. //Brdy string `json:"brdy"`
  19572. Certno string `json:"certno"`
  19573. Gend string `json:"gend"`
  19574. Naty string `json:"naty"`
  19575. PsnCertType string `json:"psn_cert_type"`
  19576. PsnName string `json:"psn_name"`
  19577. PsnNo string `json:"psn_no"`
  19578. } `json:"baseinfo"`
  19579. Idetinfo []interface{} `json:"idetinfo"`
  19580. Iinfo []struct {
  19581. Balc float64 `json:"balc"`
  19582. CvlservFlag string `json:"cvlserv_flag"`
  19583. EmpName string `json:"emp_name"`
  19584. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  19585. Insutype string `json:"insutype"`
  19586. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  19587. PsnInsuStas string `json:"psn_insu_stas"`
  19588. PsnType string `json:"psn_type"`
  19589. } `json:"insuinfo"`
  19590. } `json:"output"`
  19591. RefmsgTime string `json:"refmsg_time"`
  19592. RespondTime string `json:"respond_time"`
  19593. Signtype interface{} `json:"signtype"`
  19594. WarnInfo interface{} `json:"warn_info"`
  19595. }
  19596. type ResultThree struct {
  19597. Cainfo interface{} `json:"cainfo"`
  19598. ErrMsg string `json:"err_msg"`
  19599. InfRefmsgid string `json:"inf_refmsgid"`
  19600. Infcode int64 `json:"infcode"`
  19601. Output struct {
  19602. Data struct {
  19603. IptOtpNo string `json:"ipt_otp_no"`
  19604. MdtrtID string `json:"mdtrt_id"`
  19605. PsnNo string `json:"psn_no"`
  19606. } `json:"data"`
  19607. } `json:"output"`
  19608. RefmsgTime string `json:"refmsg_time"`
  19609. RespondTime string `json:"respond_time"`
  19610. Signtype interface{} `json:"signtype"`
  19611. WarnMsg interface{} `json:"warn_msg"`
  19612. }
  19613. type ResultThree10265 struct {
  19614. Cainfo interface{} `json:"cainfo"`
  19615. ErrMsg string `json:"err_msg"`
  19616. InfRefmsgid string `json:"inf_refmsgid"`
  19617. Infcode string `json:"infcode"`
  19618. Output struct {
  19619. Data struct {
  19620. IptOtpNo string `json:"ipt_otp_no"`
  19621. MdtrtID string `json:"mdtrt_id"`
  19622. PsnNo string `json:"psn_no"`
  19623. } `json:"data"`
  19624. } `json:"output"`
  19625. RefmsgTime string `json:"refmsg_time"`
  19626. RespondTime string `json:"respond_time"`
  19627. Signtype interface{} `json:"signtype"`
  19628. WarnMsg interface{} `json:"warn_msg"`
  19629. }
  19630. type ResultFour struct {
  19631. Cainfo string `json:"cainfo"`
  19632. ErrMsg string `json:"err_msg"`
  19633. InfRefmsgid string `json:"inf_refmsgid"`
  19634. Infcode int64 `json:"infcode"`
  19635. Output struct {
  19636. Result []struct {
  19637. BasMednFlag string `json:"bas_medn_flag"`
  19638. ChldMedcFlag string `json:"chld_medc_flag"`
  19639. ChrgitmLv string `json:"chrgitm_lv"`
  19640. Cnt float64 `json:"cnt"`
  19641. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  19642. DrtReimFlag string `json:"drt_reim_flag"`
  19643. FeedetlSn string `json:"feedetl_sn"`
  19644. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  19645. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  19646. InscpScpAmt float64 `json:"inscp_scp_amt"`
  19647. ListSpItemFlag string `json:"list_sp_item_flag"`
  19648. LmtUsedFlag string `json:"lmt_used_flag"`
  19649. MedChrgitmType string `json:"med_chrgitm_type"`
  19650. Memo string `json:"memo"`
  19651. OverlmtAmt float64 `json:"overlmt_amt"`
  19652. PreselfpayAmt float64 `json:"preselfpay_amt"`
  19653. Pric float64 `json:"pric"`
  19654. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  19655. SelfpayProp float64 `json:"selfpay_prop"`
  19656. } `json:"result"`
  19657. } `json:"output"`
  19658. RefmsgTime string `json:"refmsg_time"`
  19659. RespondTime string `json:"respond_time"`
  19660. Signtype string `json:"signtype"`
  19661. WarnMsg string `json:"warn_msg"`
  19662. }
  19663. type ResultFour10265 struct {
  19664. Cainfo string `json:"cainfo"`
  19665. ErrMsg string `json:"err_msg"`
  19666. InfRefmsgid string `json:"inf_refmsgid"`
  19667. Infcode string `json:"infcode"`
  19668. Output struct {
  19669. Result []struct {
  19670. BasMednFlag string `json:"bas_medn_flag"`
  19671. ChldMedcFlag string `json:"chld_medc_flag"`
  19672. ChrgitmLv string `json:"chrgitm_lv"`
  19673. Cnt float64 `json:"cnt"`
  19674. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  19675. DrtReimFlag string `json:"drt_reim_flag"`
  19676. FeedetlSn string `json:"feedetl_sn"`
  19677. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  19678. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  19679. InscpScpAmt float64 `json:"inscp_scp_amt"`
  19680. ListSpItemFlag string `json:"list_sp_item_flag"`
  19681. LmtUsedFlag string `json:"lmt_used_flag"`
  19682. MedChrgitmType string `json:"med_chrgitm_type"`
  19683. Memo string `json:"memo"`
  19684. OverlmtAmt float64 `json:"overlmt_amt"`
  19685. PreselfpayAmt float64 `json:"preselfpay_amt"`
  19686. Pric float64 `json:"pric"`
  19687. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  19688. SelfpayProp float64 `json:"selfpay_prop"`
  19689. } `json:"result"`
  19690. } `json:"output"`
  19691. RefmsgTime string `json:"refmsg_time"`
  19692. RespondTime string `json:"respond_time"`
  19693. Signtype string `json:"signtype"`
  19694. WarnMsg string `json:"warn_msg"`
  19695. }
  19696. type ResultMemo struct {
  19697. InsuAdmdvs string `json:"insuAdmdvs"`
  19698. }
  19699. // [{"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}]
  19700. type ResultIDInfo struct {
  19701. Begntime string `json:"begntime"`
  19702. Endtime string `json:"endtime"`
  19703. Memo string `json:"memo"`
  19704. }
  19705. type ResultFive struct {
  19706. Balc float64 `json:"balc"`
  19707. CvlservFlag string `json:"cvlserv_flag"`
  19708. EmpName string `json:"emp_name"`
  19709. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  19710. Insutype string `json:"insutype"`
  19711. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  19712. PausInsuDate string `json:"paus_insu_date"`
  19713. PsnInsuDate string `json:"psn_insu_date"`
  19714. PsnInsuStas string `json:"psn_insu_stas"`
  19715. PsnType string `json:"psn_type"`
  19716. }
  19717. type ResultSix struct {
  19718. Cainfo interface{} `json:"cainfo"`
  19719. ErrMsg string `json:"err_msg"`
  19720. InfRefmsgid string `json:"inf_refmsgid"`
  19721. Infcode int64 `json:"infcode"`
  19722. Output struct {
  19723. } `json:"output"`
  19724. RefmsgTime string `json:"refmsg_time"`
  19725. RespondTime string `json:"respond_time"`
  19726. Signtype interface{} `json:"signtype"`
  19727. WarnMsg interface{} `json:"warn_msg"`
  19728. }
  19729. type FJ3507Result struct {
  19730. Cainfo interface{} `json:"cainfo"`
  19731. ErrMsg string `json:"err_msg"`
  19732. InfRefmsgid string `json:"inf_refmsgid"`
  19733. Infcode int64 `json:"infcode"`
  19734. Output struct {
  19735. retRslt string `json:"retRslt"`
  19736. msgRslt string `json:"msgRslt"`
  19737. } `json:"output"`
  19738. RefmsgTime string `json:"refmsg_time"`
  19739. RespondTime string `json:"respond_time"`
  19740. Signtype interface{} `json:"signtype"`
  19741. WarnMsg interface{} `json:"warn_msg"`
  19742. }
  19743. type FJ3507ResultFor10188 struct {
  19744. Cainfo interface{} `json:"cainfo"`
  19745. ErrMsg string `json:"err_msg"`
  19746. InfRefmsgid string `json:"inf_refmsgid"`
  19747. Infcode string `json:"infcode"`
  19748. RefmsgTime string `json:"refmsg_time"`
  19749. RespondTime string `json:"respond_time"`
  19750. Signtype interface{} `json:"signtype"`
  19751. WarnMsg interface{} `json:"warn_msg"`
  19752. }
  19753. type Result2406 struct {
  19754. Cainfo interface{} `json:"cainfo"`
  19755. ErrMsg string `json:"err_msg"`
  19756. InfRefmsgid string `json:"inf_refmsgid"`
  19757. Infcode int64 `json:"infcode"`
  19758. Output struct {
  19759. Result struct {
  19760. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  19761. } `json:"result"`
  19762. } `json:"output"`
  19763. RefmsgTime string `json:"refmsg_time"`
  19764. RespondTime string `json:"respond_time"`
  19765. Signtype interface{} `json:"signtype"`
  19766. WarnMsg interface{} `json:"warn_msg"`
  19767. }
  19768. type GZResultSix struct {
  19769. Cainfo interface{} `json:"cainfo"`
  19770. ErrMsg string `json:"err_msg"`
  19771. InfRefmsgid string `json:"inf_refmsgid"`
  19772. Infcode int64 `json:"infcode"`
  19773. Output string `json:"output"`
  19774. RefmsgTime string `json:"refmsg_time"`
  19775. RespondTime string `json:"respond_time"`
  19776. Signtype interface{} `json:"signtype"`
  19777. WarnMsg interface{} `json:"warn_msg"`
  19778. }
  19779. type ResultSix10265 struct {
  19780. Cainfo interface{} `json:"cainfo"`
  19781. ErrMsg string `json:"err_msg"`
  19782. InfRefmsgid string `json:"inf_refmsgid"`
  19783. Infcode string `json:"infcode"`
  19784. Output struct {
  19785. } `json:"output"`
  19786. RefmsgTime string `json:"refmsg_time"`
  19787. RespondTime string `json:"respond_time"`
  19788. Signtype interface{} `json:"signtype"`
  19789. WarnMsg interface{} `json:"warn_msg"`
  19790. }
  19791. type ResultSeven struct {
  19792. Cainfo string `json:"cainfo"`
  19793. ErrMsg string `json:"err_msg"`
  19794. InfRefmsgid string `json:"inf_refmsgid"`
  19795. Infcode int64 `json:"infcode"`
  19796. Output struct {
  19797. Setlinfo struct {
  19798. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  19799. AcctPay float64 `json:"acct_pay"`
  19800. ActPayDedc float64 `json:"act_pay_dedc"`
  19801. Age float64 `json:"age"`
  19802. Balc float64 `json:"balc"`
  19803. Certno string `json:"certno"`
  19804. ClrOptins string `json:"clr_optins"`
  19805. ClrType string `json:"clr_type"`
  19806. ClrWay string `json:"clr_way"`
  19807. CvlservFlag string `json:"cvlserv_flag"`
  19808. CvlservPay float64 `json:"cvlserv_pay"`
  19809. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  19810. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  19811. Gend string `json:"gend"`
  19812. HifesPay float64 `json:"hifes_pay"`
  19813. HifmiPay float64 `json:"hifmi_pay"`
  19814. HifpPay float64 `json:"hifp_pay"`
  19815. HospPartAmt float64 `json:"hosp_part_amt"`
  19816. InscpScpAmt float64 `json:"inscp_scp_amt"`
  19817. Insutype string `json:"insutype"`
  19818. MafPay float64 `json:"maf_pay"`
  19819. MdtrtCertType string `json:"mdtrt_cert_type"`
  19820. HifobPay float64 `json:"hifob_pay"`
  19821. MdtrtID string `json:"mdtrt_id"`
  19822. MedType string `json:"med_type"`
  19823. MedfeeSumamt float64 `json:"medfee_sumamt"`
  19824. MedinsSetlID string `json:"medins_setl_id"`
  19825. Naty string `json:"naty"`
  19826. OthPay float64 `json:"oth_pay"`
  19827. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  19828. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  19829. PreselfpayAmt float64 `json:"preselfpay_amt"`
  19830. PsnCashPay float64 `json:"psn_cash_pay"`
  19831. PsnCertType string `json:"psn_cert_type"`
  19832. PsnName string `json:"psn_name"`
  19833. PsnNo string `json:"psn_no"`
  19834. PsnPartAmt float64 `json:"psn_part_amt"`
  19835. PsnType string `json:"psn_type"`
  19836. SetlID string `json:"setl_id"`
  19837. SetlTime string `json:"setl_time"`
  19838. } `json:"setlinfo"`
  19839. Setldetail interface{} `json:"setldetail"`
  19840. } `json:"output"`
  19841. RefmsgTime string `json:"refmsg_time"`
  19842. RespondTime string `json:"respond_time"`
  19843. Signtype interface{} `json:"signtype"`
  19844. WarnMsg interface{} `json:"warn_msg"`
  19845. }
  19846. type ResultSevenAH struct {
  19847. Cainfo string `json:"cainfo"`
  19848. ErrMsg string `json:"err_msg"`
  19849. InfRefmsgid string `json:"inf_refmsgid"`
  19850. Infcode int64 `json:"infcode"`
  19851. Output struct {
  19852. Setlinfo struct {
  19853. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  19854. AcctPay float64 `json:"acct_pay"`
  19855. ActPayDedc float64 `json:"act_pay_dedc"`
  19856. Age float64 `json:"age"`
  19857. Balc float64 `json:"balc"`
  19858. Certno string `json:"certno"`
  19859. ClrOptins string `json:"clr_optins"`
  19860. ClrType string `json:"clr_type"`
  19861. ClrWay string `json:"clr_way"`
  19862. CvlservFlag string `json:"cvlserv_flag"`
  19863. CvlservPay float64 `json:"cvlserv_pay"`
  19864. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  19865. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  19866. Gend string `json:"gend"`
  19867. HifesPay float64 `json:"hifes_pay"`
  19868. HifmiPay float64 `json:"hifmi_pay"`
  19869. HifpPay float64 `json:"hifp_pay"`
  19870. HospPartAmt float64 `json:"hosp_part_amt"`
  19871. InscpScpAmt float64 `json:"inscp_scp_amt"`
  19872. Insutype string `json:"insutype"`
  19873. MafPay float64 `json:"maf_pay"`
  19874. MdtrtCertType string `json:"mdtrt_cert_type"`
  19875. HifobPay float64 `json:"hifob_pay"`
  19876. MdtrtID string `json:"mdtrt_id"`
  19877. MedType string `json:"med_type"`
  19878. MedfeeSumamt float64 `json:"medfee_sumamt"`
  19879. MedinsSetlID string `json:"medins_setl_id"`
  19880. Naty string `json:"naty"`
  19881. OthPay float64 `json:"oth_pay"`
  19882. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  19883. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  19884. PreselfpayAmt float64 `json:"preselfpay_amt"`
  19885. PsnCashPay float64 `json:"psn_cash_pay"`
  19886. PsnCertType string `json:"psn_cert_type"`
  19887. PsnName string `json:"psn_name"`
  19888. PsnNo string `json:"psn_no"`
  19889. PsnPartAmt float64 `json:"psn_part_amt"`
  19890. PsnType string `json:"psn_type"`
  19891. SetlID string `json:"setl_id"`
  19892. SetlTime int64 `json:"setl_time"`
  19893. } `json:"setlinfo"`
  19894. Setldetail interface{} `json:"setldetail"`
  19895. } `json:"output"`
  19896. RefmsgTime string `json:"refmsg_time"`
  19897. RespondTime string `json:"respond_time"`
  19898. Signtype interface{} `json:"signtype"`
  19899. WarnMsg interface{} `json:"warn_msg"`
  19900. }
  19901. type ResultSeven10265 struct {
  19902. Cainfo string `json:"cainfo"`
  19903. ErrMsg string `json:"err_msg"`
  19904. InfRefmsgid string `json:"inf_refmsgid"`
  19905. Infcode string `json:"infcode"`
  19906. Output struct {
  19907. Setlinfo struct {
  19908. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  19909. AcctPay float64 `json:"acct_pay"`
  19910. ActPayDedc float64 `json:"act_pay_dedc"`
  19911. Age float64 `json:"age"`
  19912. Balc float64 `json:"balc"`
  19913. Certno string `json:"certno"`
  19914. ClrOptins string `json:"clr_optins"`
  19915. ClrType string `json:"clr_type"`
  19916. ClrWay string `json:"clr_way"`
  19917. CvlservFlag string `json:"cvlserv_flag"`
  19918. CvlservPay float64 `json:"cvlserv_pay"`
  19919. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  19920. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  19921. Gend string `json:"gend"`
  19922. HifesPay float64 `json:"hifes_pay"`
  19923. HifmiPay float64 `json:"hifmi_pay"`
  19924. HifpPay float64 `json:"hifp_pay"`
  19925. HospPartAmt float64 `json:"hosp_part_amt"`
  19926. InscpScpAmt float64 `json:"inscp_scp_amt"`
  19927. Insutype string `json:"insutype"`
  19928. MafPay float64 `json:"maf_pay"`
  19929. MdtrtCertType string `json:"mdtrt_cert_type"`
  19930. HifobPay float64 `json:"hifob_pay"`
  19931. MdtrtID string `json:"mdtrt_id"`
  19932. MedType string `json:"med_type"`
  19933. MedfeeSumamt float64 `json:"medfee_sumamt"`
  19934. MedinsSetlID string `json:"medins_setl_id"`
  19935. Naty string `json:"naty"`
  19936. OthPay float64 `json:"oth_pay"`
  19937. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  19938. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  19939. PreselfpayAmt float64 `json:"preselfpay_amt"`
  19940. PsnCashPay float64 `json:"psn_cash_pay"`
  19941. PsnCertType string `json:"psn_cert_type"`
  19942. PsnName string `json:"psn_name"`
  19943. PsnNo string `json:"psn_no"`
  19944. PsnPartAmt float64 `json:"psn_part_amt"`
  19945. PsnType string `json:"psn_type"`
  19946. SetlID string `json:"setl_id"`
  19947. SetlTime string `json:"setl_time"`
  19948. } `json:"setlinfo"`
  19949. Setldetail interface{} `json:"setldetail"`
  19950. } `json:"output"`
  19951. RefmsgTime string `json:"refmsg_time"`
  19952. RespondTime string `json:"respond_time"`
  19953. Signtype interface{} `json:"signtype"`
  19954. WarnMsg interface{} `json:"warn_msg"`
  19955. }
  19956. type ResultSeven10265Two struct {
  19957. Cainfo string `json:"cainfo"`
  19958. ErrMsg string `json:"err_msg"`
  19959. InfRefmsgid string `json:"inf_refmsgid"`
  19960. Infcode string `json:"infcode"`
  19961. Output struct {
  19962. Setlinfo struct {
  19963. AcctMulaidPay string `json:"acct_mulaid_pay"`
  19964. AcctPay float64 `json:"acct_pay"`
  19965. ActPayDedc float64 `json:"act_pay_dedc"`
  19966. Age float64 `json:"age"`
  19967. Balc float64 `json:"balc"`
  19968. Certno string `json:"certno"`
  19969. ClrOptins string `json:"clr_optins"`
  19970. ClrType string `json:"clr_type"`
  19971. ClrWay string `json:"clr_way"`
  19972. CvlservFlag string `json:"cvlserv_flag"`
  19973. CvlservPay float64 `json:"cvlserv_pay"`
  19974. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  19975. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  19976. Gend string `json:"gend"`
  19977. HifesPay float64 `json:"hifes_pay"`
  19978. HifmiPay float64 `json:"hifmi_pay"`
  19979. HifpPay float64 `json:"hifp_pay"`
  19980. HospPartAmt string `json:"hosp_part_amt"`
  19981. InscpScpAmt float64 `json:"inscp_scp_amt"`
  19982. Insutype string `json:"insutype"`
  19983. MafPay float64 `json:"maf_pay"`
  19984. MdtrtCertType string `json:"mdtrt_cert_type"`
  19985. HifobPay float64 `json:"hifob_pay"`
  19986. MdtrtID string `json:"mdtrt_id"`
  19987. MedType string `json:"med_type"`
  19988. MedfeeSumamt float64 `json:"medfee_sumamt"`
  19989. MedinsSetlID string `json:"medins_setl_id"`
  19990. Naty string `json:"naty"`
  19991. OthPay float64 `json:"oth_pay"`
  19992. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  19993. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  19994. PreselfpayAmt float64 `json:"preselfpay_amt"`
  19995. PsnCashPay float64 `json:"psn_cash_pay"`
  19996. PsnCertType string `json:"psn_cert_type"`
  19997. PsnName string `json:"psn_name"`
  19998. PsnNo string `json:"psn_no"`
  19999. PsnPartAmt float64 `json:"psn_part_amt"`
  20000. PsnType string `json:"psn_type"`
  20001. SetlID string `json:"setl_id"`
  20002. SetlTime string `json:"setl_time"`
  20003. } `json:"setlinfo"`
  20004. Setldetail interface{} `json:"setldetail"`
  20005. } `json:"output"`
  20006. RefmsgTime string `json:"refmsg_time"`
  20007. RespondTime string `json:"respond_time"`
  20008. Signtype interface{} `json:"signtype"`
  20009. WarnMsg interface{} `json:"warn_msg"`
  20010. }
  20011. type GZResultSeven10265Two struct {
  20012. Cainfo string `json:"cainfo"`
  20013. ErrMsg string `json:"err_msg"`
  20014. InfRefmsgid string `json:"inf_refmsgid"`
  20015. Infcode int64 `json:"infcode"`
  20016. Output struct {
  20017. Setlinfo struct {
  20018. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  20019. AcctPay float64 `json:"acct_pay"`
  20020. ActPayDedc float64 `json:"act_pay_dedc"`
  20021. Age float64 `json:"age"`
  20022. Balc float64 `json:"balc"`
  20023. Certno string `json:"certno"`
  20024. ClrOptins string `json:"clr_optins"`
  20025. ClrType string `json:"clr_type"`
  20026. ClrWay string `json:"clr_way"`
  20027. CvlservFlag string `json:"cvlserv_flag"`
  20028. CvlservPay float64 `json:"cvlserv_pay"`
  20029. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20030. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20031. Gend string `json:"gend"`
  20032. HifesPay float64 `json:"hifes_pay"`
  20033. HifmiPay float64 `json:"hifmi_pay"`
  20034. HifpPay float64 `json:"hifp_pay"`
  20035. HospPartAmt float64 `json:"hosp_part_amt"`
  20036. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20037. Insutype string `json:"insutype"`
  20038. MafPay float64 `json:"maf_pay"`
  20039. MdtrtCertType string `json:"mdtrt_cert_type"`
  20040. HifobPay float64 `json:"hifob_pay"`
  20041. MdtrtID string `json:"mdtrt_id"`
  20042. MedType string `json:"med_type"`
  20043. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20044. MedinsSetlID string `json:"medins_setl_id"`
  20045. Naty string `json:"naty"`
  20046. OthPay float64 `json:"oth_pay"`
  20047. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20048. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  20049. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20050. PsnCashPay float64 `json:"psn_cash_pay"`
  20051. PsnCertType string `json:"psn_cert_type"`
  20052. PsnName string `json:"psn_name"`
  20053. PsnNo string `json:"psn_no"`
  20054. PsnPartAmt float64 `json:"psn_part_amt"`
  20055. PsnType string `json:"psn_type"`
  20056. SetlID string `json:"setl_id"`
  20057. SetlTime string `json:"setl_time"`
  20058. } `json:"setlinfo"`
  20059. Setldetail interface{} `json:"setldetail"`
  20060. } `json:"output"`
  20061. RefmsgTime string `json:"refmsg_time"`
  20062. RespondTime string `json:"respond_time"`
  20063. Signtype interface{} `json:"signtype"`
  20064. WarnMsg interface{} `json:"warn_msg"`
  20065. }
  20066. type ResultEight struct {
  20067. Cainfo string `json:"cainfo"`
  20068. ErrMsg string `json:"err_msg"`
  20069. InfRefmsgid string `json:"inf_refmsgid"`
  20070. Infcode int64 `json:"infcode"`
  20071. Output struct {
  20072. Stmtinfo struct {
  20073. SetlOptins string `json:"setl_optins"`
  20074. StmtRslt string `json:"stmt_rslt"`
  20075. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  20076. } `json:"stmtinfo"`
  20077. } `json:"output"`
  20078. RefmsgTime string `json:"refmsg_time"`
  20079. RespondTime string `json:"respond_time"`
  20080. Signtype interface{} `json:"signtype"`
  20081. WarnMsg interface{} `json:"warn_msg"`
  20082. }
  20083. type ResultEightFor10188 struct {
  20084. Cainfo string `json:"cainfo"`
  20085. ErrMsg string `json:"err_msg"`
  20086. InfRefmsgid string `json:"inf_refmsgid"`
  20087. Infcode string `json:"infcode"`
  20088. Output struct {
  20089. Stmtinfo struct {
  20090. SetlOptins string `json:"setl_optins"`
  20091. StmtRslt string `json:"stmt_rslt"`
  20092. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  20093. } `json:"stmtinfo"`
  20094. } `json:"output"`
  20095. RefmsgTime string `json:"refmsg_time"`
  20096. RespondTime string `json:"respond_time"`
  20097. Signtype interface{} `json:"signtype"`
  20098. WarnMsg interface{} `json:"warn_msg"`
  20099. }
  20100. type ResultNine struct {
  20101. Cainfo string `json:"cainfo"`
  20102. ErrMsg string `json:"err_msg"`
  20103. InfRefmsgid string `json:"inf_refmsgid"`
  20104. Infcode int64 `json:"infcode"`
  20105. Output struct {
  20106. FileQuryNo string `json:"file_qury_no"`
  20107. } `json:"output"`
  20108. RefmsgTime string `json:"refmsg_time"`
  20109. RespondTime string `json:"respond_time"`
  20110. Signtype interface{} `json:"signtype"`
  20111. WarnMsg interface{} `json:"warn_msg"`
  20112. }
  20113. type ResultTen struct {
  20114. Cainfo string `json:"cainfo"`
  20115. ErrMsg string `json:"err_msg"`
  20116. InfRefmsgid string `json:"inf_refmsgid"`
  20117. Infcode int64 `json:"infcode"`
  20118. Output struct {
  20119. Fileinfo struct {
  20120. DldEndtime string `json:"dld_endtime"`
  20121. FileQuryNo string `json:"file_qury_no"`
  20122. Filename string `json:"filename"`
  20123. } `json:"fileinfo"`
  20124. } `json:"output"`
  20125. RefmsgTime string `json:"refmsg_time"`
  20126. RespondTime string `json:"respond_time"`
  20127. Signtype interface{} `json:"signtype"`
  20128. WarnMsg interface{} `json:"warn_msg"`
  20129. }
  20130. type Result5262 struct {
  20131. ErrMsg string `json:"err_msg"`
  20132. InfRefmsgid string `json:"inf_refmsgid"`
  20133. Infcode int64 `json:"infcode"`
  20134. Output struct {
  20135. PageInfo struct {
  20136. Size int `json:"size"`
  20137. RecordCounts int `json:"record_counts"`
  20138. } `json:"page_info"`
  20139. Idetinfo []interface{} `json:"idetinfo"`
  20140. Result []struct {
  20141. SetlID string `json:"setl_id"`
  20142. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  20143. MdtrtID string `json:"mdtrt_id"`
  20144. InitSetlID string `json:"init_setl_id,omitempty"`
  20145. PsnNo string `json:"psn_no"`
  20146. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  20147. PsnName string `json:"psn_name"`
  20148. PsnCertType string `json:"psn_cert_type"`
  20149. Certno string `json:"certno"`
  20150. Gend string `json:"gend,omitempty"`
  20151. Naty string `json:"naty,omitempty"`
  20152. Brdy string `json:"brdy,omitempty"`
  20153. Age float64 `json:"age,omitempty"`
  20154. Insutype string `json:"insutype,omitempty"`
  20155. PsnType string `json:"psn_type"`
  20156. CvlservFlag string `json:"cvlserv_flag"`
  20157. CvlservLv string `json:"cvlserv_lv,omitempty"`
  20158. SpPsnType string `json:"sp_psn_type,omitempty"`
  20159. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  20160. ClctGrde string `json:"clct_grde,omitempty"`
  20161. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  20162. NwbFlag string `json:"nwb_flag,omitempty"`
  20163. InsuAdmdvs string `json:"insu_admdvs"`
  20164. EmpNo string `json:"emp_no,omitempty"`
  20165. EmpName string `json:"emp_name,omitempty"`
  20166. EmpType string `json:"emp_type,omitempty"`
  20167. EconType string `json:"econ_type,omitempty"`
  20168. AfilIndu string `json:"afil_indu,omitempty"`
  20169. AfilRlts string `json:"afil_rlts,omitempty"`
  20170. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  20171. PayLoc string `json:"pay_loc,omitempty"`
  20172. FixmedinsCode string `json:"fixmedins_code"`
  20173. FixmedinsName string `json:"fixmedins_name"`
  20174. HospLv string `json:"hosp_lv,omitempty"`
  20175. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  20176. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  20177. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  20178. Begndate string `json:"begndate"`
  20179. Enddate string `json:"enddate"`
  20180. SetlTime string `json:"setl_time"`
  20181. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  20182. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  20183. MedType string `json:"med_type"`
  20184. SetlType string `json:"setl_type,omitempty"`
  20185. ClrType string `json:"clr_type,omitempty"`
  20186. ClrWay string `json:"clr_way,omitempty"`
  20187. PsnSetlway string `json:"psn_setlway,omitempty"`
  20188. ClrOptins string `json:"clr_optins,omitempty"`
  20189. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  20190. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  20191. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  20192. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  20193. InscpAmt float64 `json:"inscp_amt,omitempty"`
  20194. DedcStd float64 `json:"dedc_std,omitempty"`
  20195. CrtDedc float64 `json:"crt_dedc,omitempty"`
  20196. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  20197. HifpPay float64 `json:"hifp_pay,omitempty"`
  20198. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  20199. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  20200. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  20201. HifesPay float64 `json:"hifes_pay,omitempty"`
  20202. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  20203. HifobPay float64 `json:"hifob_pay,omitempty"`
  20204. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  20205. MafPay float64 `json:"maf_pay,omitempty"`
  20206. OthfundPay float64 `json:"othfund_pay,omitempty"`
  20207. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  20208. PsnPay float64 `json:"psn_pay,omitempty"`
  20209. AcctPay float64 `json:"acct_pay,omitempty"`
  20210. CashPayamt float64 `json:"cash_payamt,omitempty"`
  20211. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  20212. Balc float64 `json:"balc,omitempty"`
  20213. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  20214. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  20215. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  20216. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  20217. Year string `json:"year,omitempty"`
  20218. DiseNo string `json:"dise_no,omitempty"`
  20219. DiseName string `json:"dise_name,omitempty"`
  20220. Invono string `json:"invono,omitempty"`
  20221. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  20222. ValiFlag string `json:"vali_flag,omitempty"`
  20223. Memo string `json:"memo,omitempty"`
  20224. Rid string `json:"rid"`
  20225. UpdtTime string `json:"updt_time,omitempty"`
  20226. CrterID string `json:"crter_id,omitempty"`
  20227. CrterName string `json:"crter_name,omitempty"`
  20228. CrteTime string `json:"crte_time,omitempty"`
  20229. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  20230. OpterID string `json:"opter_id,omitempty"`
  20231. OpterName string `json:"opter_name,omitempty"`
  20232. OptTime string `json:"opt_time,omitempty"`
  20233. OptinsNo string `json:"optins_no,omitempty"`
  20234. PoolareaNo string `json:"poolarea_no,omitempty"`
  20235. } `json:"result"`
  20236. } `json:"output"`
  20237. RefmsgTime string `json:"refmsg_time"`
  20238. RespondTime string `json:"respond_time"`
  20239. Signtype interface{} `json:"signtype"`
  20240. WarnInfo interface{} `json:"warn_info"`
  20241. }
  20242. type Result5267 struct {
  20243. ErrMsg string `json:"err_msg"`
  20244. InfRefmsgid string `json:"inf_refmsgid"`
  20245. Infcode int64 `json:"infcode"`
  20246. Output struct {
  20247. PageInfo struct {
  20248. Size int `json:"size"`
  20249. RecordCounts int `json:"record_counts"`
  20250. } `json:"pageinfo"`
  20251. Result []struct {
  20252. SetlID string `json:"setl_id"`
  20253. ClrOptins string `json:"clr_optins"`
  20254. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  20255. MdtrtID string `json:"mdtrt_id"`
  20256. InitSetlID string `json:"init_setl_id,omitempty"`
  20257. PsnNo string `json:"psn_no"`
  20258. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  20259. PsnName string `json:"psn_name"`
  20260. PsnCertType string `json:"psn_cert_type"`
  20261. Certno string `json:"certno"`
  20262. Gend string `json:"gend,omitempty"`
  20263. Naty string `json:"naty,omitempty"`
  20264. Brdy string `json:"brdy,omitempty"`
  20265. Age float64 `json:"age,omitempty"`
  20266. Insutype string `json:"insutype,omitempty"`
  20267. PsnType string `json:"psn_type"`
  20268. CvlservFlag string `json:"cvlserv_flag"`
  20269. CvlservLv string `json:"cvlserv_lv,omitempty"`
  20270. SpPsnType string `json:"sp_psn_type,omitempty"`
  20271. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  20272. ClctGrde string `json:"clct_grde,omitempty"`
  20273. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  20274. NwbFlag string `json:"nwb_flag,omitempty"`
  20275. InsuAdmdvs string `json:"insu_admdvs"`
  20276. EmpNo string `json:"emp_no,omitempty"`
  20277. EmpName string `json:"emp_name,omitempty"`
  20278. EmpType string `json:"emp_type,omitempty"`
  20279. EconType string `json:"econ_type,omitempty"`
  20280. AfilIndu string `json:"afil_indu,omitempty"`
  20281. AfilRlts string `json:"afil_rlts,omitempty"`
  20282. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  20283. PayLoc string `json:"pay_loc,omitempty"`
  20284. FixmedinsCode string `json:"fixmedins_code"`
  20285. FixmedinsName string `json:"fixmedins_name"`
  20286. HospLv string `json:"hosp_lv,omitempty"`
  20287. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  20288. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  20289. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  20290. Begndate string `json:"begndate,omitempty"`
  20291. Enddate string `json:"enddate,omitempty"`
  20292. SetlTime string `json:"setl_time,omitempty"`
  20293. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  20294. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  20295. MedType string `json:"med_type"`
  20296. SetlType string `json:"setl_type,omitempty"`
  20297. ClrType string `json:"clr_type,omitempty"`
  20298. ClrWay string `json:"clr_way,omitempty"`
  20299. PsnSetlway string `json:"psn_setlway,omitempty"`
  20300. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  20301. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  20302. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  20303. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  20304. InscpAmt float64 `json:"inscp_amt,omitempty"`
  20305. DedcStd float64 `json:"dedc_std,omitempty"`
  20306. CrtDedc float64 `json:"crt_dedc,omitempty"`
  20307. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  20308. HifpPay float64 `json:"hifp_pay,omitempty"`
  20309. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  20310. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  20311. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  20312. HifesPay float64 `json:"hifes_pay,omitempty"`
  20313. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  20314. HifobPay float64 `json:"hifob_pay,omitempty"`
  20315. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  20316. MafPay float64 `json:"maf_pay,omitempty"`
  20317. OthfundPay float64 `json:"othfund_pay,omitempty"`
  20318. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  20319. PsnPay float64 `json:"psn_pay,omitempty"`
  20320. AcctPay float64 `json:"acct_pay,omitempty"`
  20321. CashPayamt float64 `json:"cash_payamt,omitempty"`
  20322. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  20323. Balc float64 `json:"balc,omitempty"`
  20324. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  20325. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  20326. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  20327. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  20328. Year string `json:"year,omitempty"`
  20329. DiseNo string `json:"dise_no,omitempty"`
  20330. DiseName string `json:"dise_name,omitempty"`
  20331. Invono string `json:"invono,omitempty"`
  20332. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  20333. Memo string `json:"memo,omitempty"`
  20334. UpdtTime string `json:"updt_time,omitempty"`
  20335. OpterID string `json:"opter_id,omitempty"`
  20336. OpterName string `json:"opter_name,omitempty"`
  20337. OptTime string `json:"opt_time,omitempty"`
  20338. OptinsNo string `json:"optins_no,omitempty"`
  20339. PoolareaNo string `json:"poolarea_no,omitempty"`
  20340. } `json:"result"`
  20341. } `json:"output"`
  20342. RefmsgTime string `json:"refmsg_time"`
  20343. RespondTime string `json:"respond_time"`
  20344. Signtype interface{} `json:"signtype"`
  20345. WarnInfo interface{} `json:"warn_info"`
  20346. }
  20347. // type Autogenerated struct {
  20348. // Output struct {
  20349. // Setlinfo struct {
  20350. // SetlTime string `json:"setl_time"`
  20351. // CvlservPay float64 `json:"cvlserv_pay"`
  20352. // Year string `json:"year"`
  20353. // MedType string `json:"med_type"`
  20354. // PsnPay float64 `json:"psn_pay"`
  20355. // OpterID string `json:"opter_id"`
  20356. // Begndate string `json:"begndate"`
  20357. // FlxempeFlag string `json:"flxempe_flag"`
  20358. // HifmiPay float64 `json:"hifmi_pay"`
  20359. // PsnNo string `json:"psn_no"`
  20360. // ActPayDedc float64 `json:"act_pay_dedc"`
  20361. // MedinsSetlID interface{} `json:"medins_setl_id"`
  20362. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  20363. // ClrWay string `json:"clr_way"`
  20364. // OthPay float64 `json:"oth_pay"`
  20365. // Gend string `json:"gend"`
  20366. // MdtrtID string `json:"mdtrt_id"`
  20367. // AcctPay float64 `json:"acct_pay"`
  20368. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  20369. // Insutype string `json:"insutype"`
  20370. // Invono interface{} `json:"invono"`
  20371. // Enddate string `json:"enddate"`
  20372. // CashPayamt float64 `json:"cash_payamt"`
  20373. // PsnType string `json:"psn_type"`
  20374. // FixmedinsName string `json:"fixmedins_name"`
  20375. // HifpPay float64 `json:"hifp_pay"`
  20376. // NewFlag interface{} `json:"new_flag"`
  20377. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20378. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  20379. // PayLoc string `json:"pay_loc"`
  20380. // ClrType string `json:"clr_type"`
  20381. // RefdSetlFlag string `json:"refd_setl_flag"`
  20382. // CvlservFlag string `json:"cvlserv_flag"`
  20383. // EmpName string `json:"emp_name"`
  20384. // Brdy string `json:"brdy"`
  20385. // Naty string `json:"naty"`
  20386. // Certno string `json:"certno"`
  20387. // DiseCode string `json:"dise_code"`
  20388. // FixmedinsCode string `json:"fixmedins_code"`
  20389. // DedcHospLv string `json:"dedc_hosp_lv"`
  20390. // OpterName string `json:"opter_name"`
  20391. // Balc float64 `json:"balc"`
  20392. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  20393. // PsnCertType string `json:"psn_cert_type"`
  20394. // HifobPay float64 `json:"hifob_pay"`
  20395. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  20396. // HifesPay float64 `json:"hifes_pay"`
  20397. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20398. // OptTime string `json:"opt_time"`
  20399. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20400. // SetlID string `json:"setl_id"`
  20401. // MafPay float64 `json:"maf_pay"`
  20402. // PsnName string `json:"psn_name"`
  20403. // InsuOptins interface{} `json:"insu_optins"`
  20404. // PrefFundPay interface{} `json:"pref_fund_pay"`
  20405. // ClrOptins string `json:"clr_optins"`
  20406. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  20407. // DiseName string `json:"dise_name"`
  20408. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  20409. // Age float64 `json:"age"`
  20410. // DtrtCertType string `json:"dtrt_cert_type"`
  20411. // HospLv string `json:"hosp_lv"`
  20412. // } `json:"setlinfo"`
  20413. // Setldetail []struct {
  20414. // FundPayType string `json:"fund_pay_type"`
  20415. // FundPayamt float64 `json:"fund_payamt"`
  20416. // SetlProcInfo interface{} `json:"setl_proc_info"`
  20417. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  20418. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  20419. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  20420. // PrefFundPay interface{} `json:"pref_fund_pay"`
  20421. // } `json:"setldetail"`
  20422. // } `json:"output"`
  20423. // Infcode int `json:"infcode"`
  20424. // WarnMsg interface{} `json:"warn_msg"`
  20425. // Cainfo interface{} `json:"cainfo"`
  20426. // ErrMsg interface{} `json:"err_msg"`
  20427. // RefmsgTime string `json:"refmsg_time"`
  20428. // Signtype interface{} `json:"signtype"`
  20429. // RespondTime string `json:"respond_time"`
  20430. // InfRefmsgid string `json:"inf_refmsgid"`
  20431. // }
  20432. type Result002 struct {
  20433. Cainfo interface{} `json:"cainfo"`
  20434. ErrMsg string `json:"err_msg"`
  20435. InfRefmsgid string `json:"inf_refmsgid"`
  20436. Infcode int64 `json:"infcode"`
  20437. Output struct {
  20438. RxFile string `json:"rx_file"`
  20439. SignDigest string `json:"sign_digest"`
  20440. SignCertSn string `json:"sign_cert_sn"`
  20441. SignCertDn string `json:"sign_cert_dn"`
  20442. } `json:"output"`
  20443. RefmsgTime string `json:"refmsg_time"`
  20444. RespondTime string `json:"respond_time"`
  20445. Signtype interface{} `json:"signtype"`
  20446. WarnMsg interface{} `json:"warn_msg"`
  20447. }
  20448. type Result003 struct {
  20449. Cainfo interface{} `json:"cainfo"`
  20450. ErrMsg string `json:"err_msg"`
  20451. InfRefmsgid string `json:"inf_refmsgid"`
  20452. Infcode int64 `json:"infcode"`
  20453. Output struct {
  20454. HiRxno string `json:"hi_rxno"`
  20455. RxStasCodg string `json:"rx_stas_codg"`
  20456. RxStasName string `json:"rx_stas_name"`
  20457. } `json:"output"`
  20458. RefmsgTime string `json:"refmsg_time"`
  20459. RespondTime string `json:"respond_time"`
  20460. Signtype interface{} `json:"signtype"`
  20461. WarnMsg interface{} `json:"warn_msg"`
  20462. }
  20463. type ResultEleven struct {
  20464. Cainfo string `json:"cainfo"`
  20465. ErrMsg string `json:"err_msg"`
  20466. InfRefmsgid string `json:"inf_refmsgid"`
  20467. Infcode int64 `json:"infcode"`
  20468. Output struct {
  20469. Setlinfo struct {
  20470. SetlTime string `json:"setl_time"`
  20471. CvlservPay float64 `json:"cvlserv_pay"`
  20472. Year string `json:"year"`
  20473. MedType string `json:"med_type"`
  20474. PsnPay float64 `json:"psn_pay"`
  20475. OpterID string `json:"opter_id"`
  20476. Begndate string `json:"begndate"`
  20477. FlxempeFlag string `json:"flxempe_flag"`
  20478. HifmiPay float64 `json:"hifmi_pay"`
  20479. PsnNo string `json:"psn_no"`
  20480. ActPayDedc float64 `json:"act_pay_dedc"`
  20481. MedinsSetlID interface{} `json:"medins_setl_id"`
  20482. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  20483. ClrWay string `json:"clr_way"`
  20484. OthPay float64 `json:"oth_pay"`
  20485. Gend string `json:"gend"`
  20486. MdtrtID string `json:"mdtrt_id"`
  20487. AcctPay float64 `json:"acct_pay"`
  20488. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20489. Insutype string `json:"insutype"`
  20490. Invono interface{} `json:"invono"`
  20491. Enddate string `json:"enddate"`
  20492. CashPayamt float64 `json:"cash_payamt"`
  20493. PsnType string `json:"psn_type"`
  20494. FixmedinsName string `json:"fixmedins_name"`
  20495. HifpPay float64 `json:"hifp_pay"`
  20496. NewFlag interface{} `json:"new_flag"`
  20497. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20498. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20499. PayLoc string `json:"pay_loc"`
  20500. ClrType string `json:"clr_type"`
  20501. RefdSetlFlag string `json:"refd_setl_flag"`
  20502. CvlservFlag string `json:"cvlserv_flag"`
  20503. EmpName string `json:"emp_name"`
  20504. Brdy string `json:"brdy"`
  20505. Naty string `json:"naty"`
  20506. Certno string `json:"certno"`
  20507. DiseCode string `json:"dise_code"`
  20508. FixmedinsCode string `json:"fixmedins_code"`
  20509. DedcHospLv string `json:"dedc_hosp_lv"`
  20510. OpterName string `json:"opter_name"`
  20511. Balc float64 `json:"balc"`
  20512. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  20513. PsnCertType string `json:"psn_cert_type"`
  20514. HifobPay float64 `json:"hifob_pay"`
  20515. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20516. HifesPay float64 `json:"hifes_pay"`
  20517. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20518. OptTime string `json:"opt_time"`
  20519. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20520. SetlID string `json:"setl_id"`
  20521. MafPay float64 `json:"maf_pay"`
  20522. PsnName string `json:"psn_name"`
  20523. InsuOptins interface{} `json:"insu_optins"`
  20524. PrefFundPay interface{} `json:"pref_fund_pay"`
  20525. ClrOptins string `json:"clr_optins"`
  20526. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  20527. DiseName string `json:"dise_name"`
  20528. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  20529. Age float64 `json:"age"`
  20530. DtrtCertType string `json:"dtrt_cert_type"`
  20531. HospLv string `json:"hosp_lv"`
  20532. PsnCashPay float64 `json:"psn_cash_pay"`
  20533. } `json:"setlinfo"`
  20534. } `json:"output"`
  20535. RefmsgTime string `json:"refmsg_time"`
  20536. RespondTime string `json:"respond_time"`
  20537. Signtype interface{} `json:"signtype"`
  20538. WarnMsg interface{} `json:"warn_msg"`
  20539. }
  20540. type ResultElevenah struct {
  20541. Cainfo string `json:"cainfo"`
  20542. ErrMsg string `json:"err_msg"`
  20543. InfRefmsgid string `json:"inf_refmsgid"`
  20544. Infcode int64 `json:"infcode"`
  20545. Output struct {
  20546. Setlinfo struct {
  20547. SetlTime int64 `json:"setl_time"`
  20548. CvlservPay float64 `json:"cvlserv_pay"`
  20549. Year string `json:"year"`
  20550. MedType string `json:"med_type"`
  20551. PsnPay float64 `json:"psn_pay"`
  20552. OpterID string `json:"opter_id"`
  20553. Begndate int64 `json:"begndate"`
  20554. FlxempeFlag string `json:"flxempe_flag"`
  20555. HifmiPay float64 `json:"hifmi_pay"`
  20556. PsnNo string `json:"psn_no"`
  20557. ActPayDedc float64 `json:"act_pay_dedc"`
  20558. MedinsSetlID interface{} `json:"medins_setl_id"`
  20559. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  20560. ClrWay string `json:"clr_way"`
  20561. OthPay float64 `json:"oth_pay"`
  20562. Gend string `json:"gend"`
  20563. MdtrtID string `json:"mdtrt_id"`
  20564. AcctPay float64 `json:"acct_pay"`
  20565. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20566. Insutype string `json:"insutype"`
  20567. Invono interface{} `json:"invono"`
  20568. Enddate int64 `json:"enddate"`
  20569. CashPayamt float64 `json:"cash_payamt"`
  20570. PsnType string `json:"psn_type"`
  20571. FixmedinsName string `json:"fixmedins_name"`
  20572. HifpPay float64 `json:"hifp_pay"`
  20573. NewFlag interface{} `json:"new_flag"`
  20574. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20575. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20576. PayLoc string `json:"pay_loc"`
  20577. ClrType string `json:"clr_type"`
  20578. RefdSetlFlag string `json:"refd_setl_flag"`
  20579. CvlservFlag string `json:"cvlserv_flag"`
  20580. EmpName string `json:"emp_name"`
  20581. Brdy int64 `json:"brdy"`
  20582. Naty string `json:"naty"`
  20583. Certno string `json:"certno"`
  20584. DiseCode string `json:"dise_code"`
  20585. FixmedinsCode string `json:"fixmedins_code"`
  20586. DedcHospLv string `json:"dedc_hosp_lv"`
  20587. OpterName string `json:"opter_name"`
  20588. Balc float64 `json:"balc"`
  20589. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  20590. PsnCertType string `json:"psn_cert_type"`
  20591. HifobPay float64 `json:"hifob_pay"`
  20592. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20593. HifesPay float64 `json:"hifes_pay"`
  20594. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20595. OptTime int64 `json:"opt_time"`
  20596. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20597. SetlID string `json:"setl_id"`
  20598. MafPay float64 `json:"maf_pay"`
  20599. PsnName string `json:"psn_name"`
  20600. InsuOptins interface{} `json:"insu_optins"`
  20601. PrefFundPay interface{} `json:"pref_fund_pay"`
  20602. ClrOptins string `json:"clr_optins"`
  20603. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  20604. DiseName string `json:"dise_name"`
  20605. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  20606. Age float64 `json:"age"`
  20607. DtrtCertType string `json:"dtrt_cert_type"`
  20608. HospLv string `json:"hosp_lv"`
  20609. PsnCashPay float64 `json:"psn_cash_pay"`
  20610. } `json:"setlinfo"`
  20611. } `json:"output"`
  20612. RefmsgTime string `json:"refmsg_time"`
  20613. RespondTime string `json:"respond_time"`
  20614. Signtype interface{} `json:"signtype"`
  20615. WarnMsg interface{} `json:"warn_msg"`
  20616. }
  20617. type ResultEleven10265 struct {
  20618. Cainfo string `json:"cainfo"`
  20619. ErrMsg string `json:"err_msg"`
  20620. InfRefmsgid string `json:"inf_refmsgid"`
  20621. Infcode string `json:"infcode"`
  20622. Output struct {
  20623. Setlinfo struct {
  20624. SetlTime string `json:"setl_time"`
  20625. CvlservPay float64 `json:"cvlserv_pay"`
  20626. Year string `json:"year"`
  20627. MedType string `json:"med_type"`
  20628. PsnPay float64 `json:"psn_pay"`
  20629. OpterID string `json:"opter_id"`
  20630. Begndate string `json:"begndate"`
  20631. FlxempeFlag string `json:"flxempe_flag"`
  20632. HifmiPay float64 `json:"hifmi_pay"`
  20633. PsnNo string `json:"psn_no"`
  20634. ActPayDedc float64 `json:"act_pay_dedc"`
  20635. MedinsSetlID interface{} `json:"medins_setl_id"`
  20636. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  20637. ClrWay string `json:"clr_way"`
  20638. OthPay float64 `json:"oth_pay"`
  20639. Gend string `json:"gend"`
  20640. MdtrtID string `json:"mdtrt_id"`
  20641. AcctPay float64 `json:"acct_pay"`
  20642. InscpScpAmt float64 `json:"inscp_scp_amt"`
  20643. Insutype string `json:"insutype"`
  20644. Invono interface{} `json:"invono"`
  20645. Enddate string `json:"enddate"`
  20646. CashPayamt float64 `json:"cash_payamt"`
  20647. PsnType string `json:"psn_type"`
  20648. FixmedinsName string `json:"fixmedins_name"`
  20649. HifpPay float64 `json:"hifp_pay"`
  20650. NewFlag interface{} `json:"new_flag"`
  20651. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20652. PreselfpayAmt float64 `json:"preselfpay_amt"`
  20653. PayLoc string `json:"pay_loc"`
  20654. ClrType string `json:"clr_type"`
  20655. RefdSetlFlag string `json:"refd_setl_flag"`
  20656. CvlservFlag string `json:"cvlserv_flag"`
  20657. EmpName string `json:"emp_name"`
  20658. Brdy string `json:"brdy"`
  20659. Naty string `json:"naty"`
  20660. Certno string `json:"certno"`
  20661. DiseCode string `json:"dise_code"`
  20662. FixmedinsCode string `json:"fixmedins_code"`
  20663. DedcHospLv string `json:"dedc_hosp_lv"`
  20664. OpterName string `json:"opter_name"`
  20665. Balc float64 `json:"balc"`
  20666. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  20667. PsnCertType string `json:"psn_cert_type"`
  20668. HifobPay float64 `json:"hifob_pay"`
  20669. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20670. HifesPay float64 `json:"hifes_pay"`
  20671. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  20672. OptTime string `json:"opt_time"`
  20673. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20674. SetlID string `json:"setl_id"`
  20675. MafPay float64 `json:"maf_pay"`
  20676. PsnName string `json:"psn_name"`
  20677. InsuOptins interface{} `json:"insu_optins"`
  20678. PrefFundPay interface{} `json:"pref_fund_pay"`
  20679. ClrOptins string `json:"clr_optins"`
  20680. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  20681. DiseName string `json:"dise_name"`
  20682. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  20683. Age float64 `json:"age"`
  20684. DtrtCertType string `json:"dtrt_cert_type"`
  20685. HospLv string `json:"hosp_lv"`
  20686. PsnCashPay float64 `json:"psn_cash_pay"`
  20687. } `json:"setlinfo"`
  20688. } `json:"output"`
  20689. RefmsgTime string `json:"refmsg_time"`
  20690. RespondTime string `json:"respond_time"`
  20691. Signtype interface{} `json:"signtype"`
  20692. WarnMsg interface{} `json:"warn_msg"`
  20693. }
  20694. type ResultTwelve struct {
  20695. Cainfo string `json:"cainfo"`
  20696. ErrMsg string `json:"err_msg"`
  20697. InfRefmsgid string `json:"inf_refmsgid"`
  20698. Infcode int64 `json:"infcode"`
  20699. Output struct {
  20700. MdtrtId string `json:"mdtrt_id"`
  20701. ChrgBchno string `json:"chrg_bchno"`
  20702. PsnNo string `json:"psn_no"`
  20703. } `json:"output"`
  20704. RefmsgTime string `json:"refmsg_time"`
  20705. RespondTime string `json:"respond_time"`
  20706. Signtype interface{} `json:"signtype"`
  20707. WarnMsg interface{} `json:"warn_msg"`
  20708. }
  20709. type ResultThirteen struct {
  20710. ErrMsg string `json:"err_msg"`
  20711. InfRefmsgid string `json:"inf_refmsgid"`
  20712. Infcode int64 `json:"infcode"`
  20713. Output struct {
  20714. Result struct {
  20715. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  20716. } `json:"result"`
  20717. } `json:"output"`
  20718. RefmsgTime string `json:"refmsg_time"`
  20719. RespondTime string `json:"respond_time"`
  20720. Signtype interface{} `json:"signtype"`
  20721. WarnInfo interface{} `json:"warn_info"`
  20722. }
  20723. type ResultThirteen10265 struct {
  20724. ErrMsg string `json:"err_msg"`
  20725. InfRefmsgid string `json:"inf_refmsgid"`
  20726. Infcode string `json:"infcode"`
  20727. Output struct {
  20728. Result struct {
  20729. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  20730. } `json:"result"`
  20731. } `json:"output"`
  20732. RefmsgTime string `json:"refmsg_time"`
  20733. RespondTime string `json:"respond_time"`
  20734. Signtype interface{} `json:"signtype"`
  20735. WarnInfo interface{} `json:"warn_info"`
  20736. }
  20737. type ResultFourteen struct {
  20738. ErrMsg string `json:"err_msg"`
  20739. InfRefmsgid string `json:"inf_refmsgid"`
  20740. Infcode int64 `json:"infcode"`
  20741. Output struct {
  20742. } `json:"output"`
  20743. RefmsgTime string `json:"refmsg_time"`
  20744. RespondTime string `json:"respond_time"`
  20745. Signtype interface{} `json:"signtype"`
  20746. WarnInfo interface{} `json:"warn_info"`
  20747. }
  20748. type ResultCFYLJG001 struct {
  20749. ErrMsg string `json:"err_msg"`
  20750. InfRefmsgid string `json:"inf_refmsgid"`
  20751. Infcode int64 `json:"infcode"`
  20752. Output struct {
  20753. RxTraceCode string `json:"rx_trace_code"`
  20754. HiRxno string `json:"hi_rxno"`
  20755. } `json:"output"`
  20756. RefmsgTime string `json:"refmsg_time"`
  20757. RespondTime string `json:"respond_time"`
  20758. Signtype interface{} `json:"signtype"`
  20759. WarnInfo interface{} `json:"warn_info"`
  20760. }
  20761. type ResultCFYLJG007 struct {
  20762. ErrMsg string `json:"err_msg"`
  20763. InfRefmsgid string `json:"inf_refmsgid"`
  20764. Infcode int64 `json:"infcode"`
  20765. Output struct {
  20766. HiRxno string `json:"hi_rxno"`
  20767. RxStasName string `json:"rx_stas_name"`
  20768. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  20769. Seltdelts []interface{} `json:"seltdelts"`
  20770. RxUsedStasName string `json:"rx_used_stas_name"`
  20771. RxStasCodg string `json:"rx_stas_codg"`
  20772. } `json:"output"`
  20773. RefmsgTime string `json:"refmsg_time"`
  20774. RespondTime string `json:"respond_time"`
  20775. Signtype interface{} `json:"signtype"`
  20776. WarnInfo interface{} `json:"warn_info"`
  20777. }
  20778. type ResultCFYLJG002 struct {
  20779. ErrMsg string `json:"err_msg"`
  20780. InfRefmsgid string `json:"inf_refmsgid"`
  20781. Infcode int64 `json:"infcode"`
  20782. Output struct {
  20783. RxFile string `json:"rx_file"`
  20784. SignDigest string `json:"sign_digest"`
  20785. SignCertSn string `json:"sign_cert_sn"`
  20786. SignCertDn string `json:"sign_cert_dn"`
  20787. } `json:"output"`
  20788. RefmsgTime string `json:"refmsg_time"`
  20789. RespondTime string `json:"respond_time"`
  20790. Signtype interface{} `json:"signtype"`
  20791. WarnInfo interface{} `json:"warn_info"`
  20792. }
  20793. type ResultCFYLJG003 struct {
  20794. ErrMsg string `json:"err_msg"`
  20795. InfRefmsgid string `json:"inf_refmsgid"`
  20796. Infcode int64 `json:"infcode"`
  20797. Output struct {
  20798. HiRxno string `json:"hi_rxno"`
  20799. RxStasCodg string `json:"rx_stas_codg"`
  20800. RxStasName string `json:"rx_stas_name"`
  20801. } `json:"output"`
  20802. RefmsgTime string `json:"refmsg_time"`
  20803. RespondTime string `json:"respond_time"`
  20804. Signtype interface{} `json:"signtype"`
  20805. WarnInfo interface{} `json:"warn_info"`
  20806. }
  20807. type ResultCFYLJG004 struct {
  20808. ErrMsg string `json:"err_msg"`
  20809. InfRefmsgid string `json:"inf_refmsgid"`
  20810. Infcode int64 `json:"infcode"`
  20811. Output struct {
  20812. HiRxno string `json:"hi_rxno"`
  20813. RxStasCodg string `json:"rx_stas_codg"`
  20814. RxStasName string `json:"rx_stas_name"`
  20815. } `json:"output"`
  20816. RefmsgTime string `json:"refmsg_time"`
  20817. RespondTime string `json:"respond_time"`
  20818. Signtype interface{} `json:"signtype"`
  20819. WarnInfo interface{} `json:"warn_info"`
  20820. }
  20821. type ResultCFYLJG008 struct {
  20822. ErrMsg string `json:"err_msg"`
  20823. InfRefmsgid string `json:"inf_refmsgid"`
  20824. Infcode int64 `json:"infcode"`
  20825. Output struct {
  20826. PoolareaNo string `json:"poolareaNo"`
  20827. AdmdvsName string `json:"admdvsName"`
  20828. Count string `json:"count"`
  20829. } `json:"output"`
  20830. RefmsgTime string `json:"refmsg_time"`
  20831. RespondTime string `json:"respond_time"`
  20832. Signtype interface{} `json:"signtype"`
  20833. WarnInfo interface{} `json:"warn_info"`
  20834. }
  20835. type ResultCFYLJG005 struct {
  20836. ErrMsg string `json:"err_msg"`
  20837. InfRefmsgid string `json:"inf_refmsgid"`
  20838. Infcode int64 `json:"infcode"`
  20839. Output struct {
  20840. HiRxNo string `json:"hi_rxno"`
  20841. FixMedinsCode string `json:"fixmedins_code"`
  20842. FixMedinsName string `json:"fixmedins_name"`
  20843. RxStasCodg string `json:"rx_stas_codg"`
  20844. RxStasName string `json:"rx_stas_name"`
  20845. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  20846. RxUserdStasName string `json:"rx_userd_stas_name"`
  20847. PrscTime string `json:"prsc_time"`
  20848. RxDrugCnt float64 `json:"rx_drug_cnt"`
  20849. RxUsedWayCodg string `json:"rx_used_way_codg"`
  20850. RxUsedWayName string `json:"rx_used_way_name"`
  20851. RxFrquCodg string `json:"rx_frqu_codg"`
  20852. RxFrquName string `json:"rx_frqu_name"`
  20853. RxDosunt string `json:"rx_dosunt"`
  20854. RxDoscnt float64 `json:"rx_doscnt"`
  20855. RxDrordDscr string `json:"rx_drord_dscr"`
  20856. ValiDays int64 `json:"vali_days"`
  20857. ValiEndTime string `json:"vali_end_time"`
  20858. ReptFlag string `json:"rept_flag"`
  20859. MaxReptCnt int64 `json:"max_rept_cnt"`
  20860. ReptdCnt int64 `json:"reptd_cnt"`
  20861. MinInrvDays int64 `json:"min_inrv_days"`
  20862. RxTypeCode string `json:"rx_type_code"`
  20863. RxTypeName string `json:"rx_type_name"`
  20864. LongRxFlag string `json:"long_rx_flag"`
  20865. RxDetlList []struct {
  20866. MedListCodg string `json:"med_list_codg"`
  20867. MedinsListCodg string `json:"medins_list_codg"`
  20868. HospPrepFlag string `json:"hosp_prep_flag"`
  20869. RxItemTypeCode string `json:"rx_item_type_code"`
  20870. RxItemTypeName string `json:"rx_item_type_name"`
  20871. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  20872. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  20873. TcmHerbFoote string `json:"tcmherb_foote"`
  20874. MednTypeCode string `json:"medn_type_code"`
  20875. MednTypeName string `json:"medn_type_name"`
  20876. MainMedcFlag string `json:"main_medc_flag"`
  20877. UrgtFlag string `json:"urgt_flag"`
  20878. BasMednFlag string `json:"bas_medn_flag"`
  20879. ImpDrugFlag string `json:"imp_drug_flag"`
  20880. ProdBarc string `json:"prod_barc"`
  20881. DrugProdname string `json:"drug_prodname"`
  20882. GennameCodg string `json:"genname_codg"`
  20883. DrugGenname string `json:"drug_genname"`
  20884. DrugDosform string `json:"drug_dosform"`
  20885. DrugSpec string `json:"drug_spec"`
  20886. PrdrName string `json:"prdr_name"`
  20887. MedcWayCodg string `json:"medc_way_codg"`
  20888. MedcWayDscr string `json:"medc_way_dscr"`
  20889. MedcBegntime string `json:"medc_begntime"`
  20890. MedcEndtime string `json:"medc_endtime"`
  20891. MedcDays float64 `json:"medc_days"`
  20892. DrugPric float64 `json:"drug_pric"`
  20893. DrugSumamt float64 `json:"drug_sumamt"`
  20894. DrugCnt float64 `json:"drug_cnt"`
  20895. DrugDosunt string `json:"drug_dosunt"`
  20896. SinDoscnt float64 `json:"sin_doscnt"`
  20897. SinDosunt string `json:"sin_dosunt"`
  20898. UsedFrquCodg string `json:"used_frqu_codg"`
  20899. UsedFrquName string `json:"used_frqu_name"`
  20900. DrugTotlcnt string `json:"drug_totlcnt"`
  20901. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  20902. DiseCodg string `json:"dise_codg"`
  20903. HospApprFlag string `json:"hosp_appr_flag"`
  20904. } `json:"rx_detl_list"`
  20905. RxOtpinfo struct {
  20906. MedType string `json:"med_type"`
  20907. IptOtpNo string `json:"ipt_otp_no"`
  20908. OtpIptFlag string `json:"otp_ipt_flag"`
  20909. PatnName string `json:"patn_name"`
  20910. PatnAge float64 `json:"patn_age"`
  20911. PatnHgt float64 `json:"patn_hgt"`
  20912. PatnWt float64 `json:"patn_wt"`
  20913. Gend string `json:"gend"`
  20914. GesoVal float64 `json:"geso_val"`
  20915. NwbFlag string `json:"nwb_flag"`
  20916. NwbAge string `json:"nwb_age"`
  20917. SuckPrdFlag string `json:"suck_prd_flag"`
  20918. AlgsHis string `json:"algs_his"`
  20919. Insutype string `json:"insutype"`
  20920. PrscDeptName string `json:"prsc_dept_name"`
  20921. PrscDrName string `json:"prsc_dr_name"`
  20922. PharName string `json:"phar_name"`
  20923. PharChkTime string `json:"phar_chk_time"`
  20924. MdtrtTime string `json:"mdtrt_time"`
  20925. DiseCodg string `json:"dise_codg"`
  20926. DiseName string `json:"dise_name"`
  20927. SpDiseFlag string `json:"sp_dise_flag"`
  20928. MaindiagCode string `json:"maindiag_code"`
  20929. MaindiagName string `json:"maindiag_name"`
  20930. DiseCondDscr string `json:"dise_cond_dscr"`
  20931. FstdiagFlag string `json:"fstdiag_flag"`
  20932. } `json:"rx_otpinfo"`
  20933. RxDiseList []struct {
  20934. DiagType string `json:"diag_type"`
  20935. MaindiagFlag string `json:"maindiag_flag"`
  20936. DiagSrtNo string `json:"diag_srt_no"`
  20937. DiagCode string `json:"diag_code"`
  20938. DiagName string `json:"diag_name"`
  20939. DiagDept string `json:"diag_dept"`
  20940. DiagDrNo string `json:"diag_dr_no"`
  20941. DiagDrName string `json:"diag_dr_name"`
  20942. DiagTime string `json:"diag_time"`
  20943. TcmDiseCode string `json:"tcm_dise_code"`
  20944. TcmDiseName string `json:"tcm_dise_name"`
  20945. TcmSympCode string `json:"tcmsymp_code"`
  20946. TcmSymp string `json:"tcmsymp"`
  20947. } `json:"rx_dise_list"`
  20948. } `json:"output"`
  20949. RefmsgTime string `json:"refmsg_time"`
  20950. RespondTime string `json:"respond_time"`
  20951. Signtype interface{} `json:"signtype"`
  20952. WarnInfo interface{} `json:"warn_info"`
  20953. }
  20954. type ResultCFYLJG006 struct {
  20955. ErrMsg string `json:"err_msg"`
  20956. InfRefmsgid string `json:"inf_refmsgid"`
  20957. Infcode int64 `json:"infcode"`
  20958. Output struct {
  20959. HiRxNo string `json:"hi_rxno"`
  20960. PharCode string `json:"phar_code"`
  20961. PharName string `json:"phar_name"`
  20962. RxChkOpnn string `json:"rx_chk_opnn"`
  20963. RxChkTime string `json:"rx_chk_time"`
  20964. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  20965. RxChkStasName string `json:"rx_chk_stas_name"`
  20966. RxStasCodg string `json:"rx_stas_codg"`
  20967. RxStasName string `json:"rx_stas_name"`
  20968. } `json:"output"`
  20969. RefmsgTime string `json:"refmsg_time"`
  20970. RespondTime string `json:"respond_time"`
  20971. Signtype interface{} `json:"signtype"`
  20972. WarnInfo interface{} `json:"warn_info"`
  20973. }
  20974. type ResultFourteen10265 struct {
  20975. ErrMsg string `json:"err_msg"`
  20976. InfRefmsgid string `json:"inf_refmsgid"`
  20977. Infcode string `json:"infcode"`
  20978. Output struct {
  20979. } `json:"output"`
  20980. RefmsgTime string `json:"refmsg_time"`
  20981. RespondTime string `json:"respond_time"`
  20982. Signtype interface{} `json:"signtype"`
  20983. WarnInfo interface{} `json:"warn_info"`
  20984. }
  20985. type ResultSixteen struct {
  20986. Cainfo string `json:"cainfo"`
  20987. ErrMsg string `json:"err_msg"`
  20988. InfRefmsgid string `json:"inf_refmsgid"`
  20989. Infcode int64 `json:"infcode"`
  20990. Output struct {
  20991. Setlinfo struct {
  20992. MdtrtID string `json:"mdtrt_id"`
  20993. SetlID string `json:"setl_id"`
  20994. ClrOptins string `json:"clr_optins"`
  20995. SetlTime string `json:"setl_time"`
  20996. MedfeeSumamt float64 `json:"medfee_sumamt"`
  20997. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  20998. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  20999. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21000. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21001. ActPayDedc float64 `json:"act_pay_dedc"`
  21002. HifpPay float64 `json:"hifp_pay"`
  21003. PoolPropSe float64 `json:"pool_prop_selfpay"`
  21004. Lfpay float64 `json:"selfpay"`
  21005. CvlservPay float64 `json:"cvlserv_pay"`
  21006. HifesPay float64 `json:"hifes_pay"`
  21007. HifmiPay float64 `json:"hifmi_pay"`
  21008. HifobPay float64 `json:"hifob_pay"`
  21009. MafPay float64 `json:"maf_pay"`
  21010. OthPay float64 `json:"oth_pay"`
  21011. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21012. PsnPartAmt float64 `json:"psn_part_amt"`
  21013. AcctPay float64 `json:"acct_pay"`
  21014. Balc float64 `json:"balc"`
  21015. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21016. HospPartAmt float64 `json:"hosp_part_amt"`
  21017. MedinsSetlID string `json:"medins_setl_id"`
  21018. PdnCashPay string `json:"pdn_cash_pay"`
  21019. } `json:"setlinfo"`
  21020. } `json:"output"`
  21021. RefmsgTime string `json:"refmsg_time"`
  21022. RespondTime string `json:"respond_time"`
  21023. Signtype interface{} `json:"signtype"`
  21024. WarnMsg interface{} `json:"warn_msg"`
  21025. }
  21026. type ResultSixteen10265 struct {
  21027. Cainfo string `json:"cainfo"`
  21028. ErrMsg string `json:"err_msg"`
  21029. InfRefmsgid string `json:"inf_refmsgid"`
  21030. Infcode string `json:"infcode"`
  21031. Output struct {
  21032. Setlinfo struct {
  21033. MdtrtID string `json:"mdtrt_id"`
  21034. SetlID string `json:"setl_id"`
  21035. ClrOptins string `json:"clr_optins"`
  21036. SetlTime string `json:"setl_time"`
  21037. MedfeeSumamt float64 `json:"medfee_sumamt"`
  21038. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  21039. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  21040. PreselfpayAmt float64 `json:"preselfpay_amt"`
  21041. InscpScpAmt float64 `json:"inscp_scp_amt"`
  21042. ActPayDedc float64 `json:"act_pay_dedc"`
  21043. HifpPay float64 `json:"hifp_pay"`
  21044. PoolPropSe float64 `json:"pool_prop_selfpay"`
  21045. Lfpay float64 `json:"selfpay"`
  21046. CvlservPay float64 `json:"cvlserv_pay"`
  21047. HifesPay float64 `json:"hifes_pay"`
  21048. HifmiPay float64 `json:"hifmi_pay"`
  21049. HifobPay float64 `json:"hifob_pay"`
  21050. MafPay float64 `json:"maf_pay"`
  21051. OthPay float64 `json:"oth_pay"`
  21052. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  21053. PsnPartAmt float64 `json:"psn_part_amt"`
  21054. AcctPay float64 `json:"acct_pay"`
  21055. Balc float64 `json:"balc"`
  21056. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  21057. HospPartAmt float64 `json:"hosp_part_amt"`
  21058. MedinsSetlID string `json:"medins_setl_id"`
  21059. PdnCashPay string `json:"pdn_cash_pay"`
  21060. } `json:"setlinfo"`
  21061. } `json:"output"`
  21062. RefmsgTime string `json:"refmsg_time"`
  21063. RespondTime string `json:"respond_time"`
  21064. Signtype interface{} `json:"signtype"`
  21065. WarnMsg interface{} `json:"warn_msg"`
  21066. }
  21067. type ResultSixteen10265Two struct {
  21068. Cainfo string `json:"cainfo"`
  21069. ErrMsg string `json:"err_msg"`
  21070. InfRefmsgid string `json:"inf_refmsgid"`
  21071. Infcode string `json:"infcode"`
  21072. Output struct {
  21073. Setlinfo interface{} `json:"setlinfo"`
  21074. } `json:"output"`
  21075. RefmsgTime string `json:"refmsg_time"`
  21076. RespondTime string `json:"respond_time"`
  21077. Signtype interface{} `json:"signtype"`
  21078. WarnMsg interface{} `json:"warn_msg"`
  21079. }
  21080. type ResultgzSixteen10265Two struct {
  21081. Cainfo string `json:"cainfo"`
  21082. ErrMsg string `json:"err_msg"`
  21083. InfRefmsgid string `json:"inf_refmsgid"`
  21084. Infcode int64 `json:"infcode"`
  21085. Output struct {
  21086. Setlinfo interface{} `json:"setlinfo"`
  21087. } `json:"output"`
  21088. RefmsgTime string `json:"refmsg_time"`
  21089. RespondTime string `json:"respond_time"`
  21090. Signtype interface{} `json:"signtype"`
  21091. WarnMsg interface{} `json:"warn_msg"`
  21092. }
  21093. type ResultSeventeen struct {
  21094. ErrMsg string `json:"err_msg"`
  21095. InfRefmsgid string `json:"inf_refmsgid"`
  21096. Infcode int64 `json:"infcode"`
  21097. Output struct {
  21098. SetlListId string `json:"setl_list_id"`
  21099. } `json:"output"`
  21100. RefmsgTime string `json:"refmsg_time"`
  21101. RespondTime string `json:"respond_time"`
  21102. Signtype string `json:"signtype"`
  21103. WarnInfo string `json:"warn_info"`
  21104. }
  21105. type ResultSeventeenOther struct {
  21106. ErrMsg string `json:"err_msg"`
  21107. InfRefmsgid string `json:"inf_refmsgid"`
  21108. Infcode string `json:"infcode"`
  21109. Output struct {
  21110. SetlListId string `json:"setl_list_id"`
  21111. } `json:"output"`
  21112. RefmsgTime string `json:"refmsg_time"`
  21113. RespondTime string `json:"respond_time"`
  21114. Signtype string `json:"signtype"`
  21115. WarnInfo string `json:"warn_info"`
  21116. }
  21117. type Result90991 struct {
  21118. ErrMsg string `json:"err_msg"`
  21119. InfRefmsgid string `json:"inf_refmsgid"`
  21120. Infcode int64 `json:"infcode"`
  21121. Output struct {
  21122. Result struct {
  21123. PsnNo string `json:"psn_no"`
  21124. CardStat string `json:"card_stat"`
  21125. Certno string `json:"certno"`
  21126. PsnName string `json:"psn_name"`
  21127. CheckStat string `json:"check_stat"`
  21128. SscnoCheckStat string `json:"sscno_check_stat"`
  21129. } `json:"result"`
  21130. } `json:"output"`
  21131. RefmsgTime string `json:"refmsg_time"`
  21132. RespondTime string `json:"respond_time"`
  21133. Signtype interface{} `json:"signtype"`
  21134. WarnInfo interface{} `json:"warn_info"`
  21135. }
  21136. type Result90100 struct {
  21137. ErrMsg string `json:"err_msg"`
  21138. InfRefmsgid string `json:"inf_refmsgid"`
  21139. Infcode int64 `json:"infcode"`
  21140. Output struct {
  21141. PoolareaNo string `json:"poolarea_no"`
  21142. PoolareaNoName string `json:"poolarea_no_name"`
  21143. Insutype string `json:"insutype"`
  21144. InsutypeName string `json:"insutype_name"`
  21145. ClctType string `json:"clct_type"`
  21146. ClctTypeName string `json:"clct_type_name"`
  21147. ClctFlag string `json:"clct_flag"`
  21148. ClctFlagName string `json:"clct_flag_name"`
  21149. AccrymBegn string `json:"accrym_begn"`
  21150. AccrymEnd string `json:"accrym_end"`
  21151. ClctTime string `json:"clct_time"`
  21152. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  21153. } `json:"output"`
  21154. RefmsgTime string `json:"refmsg_time"`
  21155. RespondTime string `json:"respond_time"`
  21156. Signtype interface{} `json:"signtype"`
  21157. WarnInfo interface{} `json:"warn_info"`
  21158. }
  21159. type Custom struct {
  21160. DetItemFeeSumamt string
  21161. Cut string
  21162. FeedetlSn string
  21163. Price string
  21164. MedListCodg string
  21165. Type int64
  21166. AdviceId int64
  21167. ProjectId int64
  21168. ItemId int64
  21169. }
  21170. type Result5301 struct {
  21171. ErrMsg string `json:"err_msg"`
  21172. InfRefmsgid string `json:"inf_refmsgid"`
  21173. Infcode int64 `json:"infcode"`
  21174. Output struct {
  21175. Result []struct {
  21176. OpspDiseCode string `json:"opsp_dise_code"`
  21177. OpspDiseName string `json:"opsp_dise_name"`
  21178. Begndate string `json:"begndate"`
  21179. Enddate string `json:"enddate"`
  21180. } `json:"feedetail"`
  21181. } `json:"output"`
  21182. RefmsgTime string `json:"refmsg_time"`
  21183. RespondTime string `json:"respond_time"`
  21184. Signtype interface{} `json:"signtype"`
  21185. WarnInfo interface{} `json:"warn_info"`
  21186. }
  21187. type Result5301For10265 struct {
  21188. ErrMsg string `json:"err_msg"`
  21189. InfRefmsgid string `json:"inf_refmsgid"`
  21190. Infcode string `json:"infcode"`
  21191. Output struct {
  21192. Result []struct {
  21193. OpspDiseCode string `json:"opsp_dise_code"`
  21194. OpspDiseName string `json:"opsp_dise_name"`
  21195. Begndate string `json:"begndate"`
  21196. Enddate string `json:"enddate"`
  21197. } `json:"feedetail"`
  21198. } `json:"output"`
  21199. RefmsgTime string `json:"refmsg_time"`
  21200. RespondTime string `json:"respond_time"`
  21201. Signtype interface{} `json:"signtype"`
  21202. WarnInfo interface{} `json:"warn_info"`
  21203. }
  21204. //获取个人信息----挂号-----上传就诊信息
  21205. func (c *HisApiController) GetRegisterInfo() {
  21206. id, _ := c.GetInt64("id")
  21207. record_time := c.GetString("record_time")
  21208. settlementValue, _ := c.GetInt64("settlement_value")
  21209. medical_insurance_card := c.GetString("medical_insurance_card")
  21210. name := c.GetString("name")
  21211. id_card_type, _ := c.GetInt64("id_card_type")
  21212. certificates, _ := c.GetInt64("certificates")
  21213. medical_care, _ := c.GetInt64("medical_care")
  21214. birthday := c.GetString("birthday")
  21215. id_card := c.GetString("id_card")
  21216. register_type, _ := c.GetInt64("register")
  21217. doctor, _ := c.GetInt64("doctor")
  21218. department, _ := c.GetInt64("department")
  21219. gender, _ := c.GetInt64("sex")
  21220. registration_fee, _ := c.GetFloat("registration_fee")
  21221. medical_expenses, _ := c.GetFloat("medical_expenses")
  21222. social_type, _ := c.GetInt64("social_type")
  21223. admin_user_id, _ := c.GetInt64("admin_user_id")
  21224. insuplc_admdvs := c.GetString("insuplc_admdvs")
  21225. mdtrt_type := c.GetString("mdtrt_type")
  21226. if id_card_type == 5 {
  21227. id_card_type = 4
  21228. }
  21229. timeLayout := "2006-01-02"
  21230. loc, _ := time.LoadLocation("Local")
  21231. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  21232. birthUnix := birthdays.Unix()
  21233. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  21234. if err != nil {
  21235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21236. return
  21237. }
  21238. recordDateTime := theTime.Unix()
  21239. adminInfo := c.GetAdminUserInfo()
  21240. var patient service.Patients
  21241. if id == 0 {
  21242. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  21243. } else {
  21244. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  21245. }
  21246. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  21247. if patientPrescription.ID == 0 {
  21248. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  21249. }
  21250. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  21251. if patient.ID == 0 {
  21252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  21253. return
  21254. }
  21255. if len(patient.IdCardNo) == 0 {
  21256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  21257. return
  21258. }
  21259. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  21260. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  21261. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  21262. //就诊结算未完成,不能进行二次挂号
  21263. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  21264. if len(his) >= 1 {
  21265. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  21266. if len(his) >= 1 && order.ID == 0 {
  21267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  21268. return
  21269. }
  21270. }
  21271. //var register_log string
  21272. if config.IsOpen == 1 {
  21273. var res ResultTwo
  21274. var res10265 ResultTwo10265
  21275. var PsnNo string
  21276. var PsnCertType string
  21277. var Certno string
  21278. var PsnName string
  21279. var Gend string
  21280. var Naty string
  21281. var Brdy string
  21282. var Age float64
  21283. var infoStr string
  21284. var idetinfoStr string
  21285. var infocode int64
  21286. var verify_number string
  21287. fmt.Println(verify_number)
  21288. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  21289. psn_info, _ := service.GetPsnByPatientId(id)
  21290. PsnNo = psn_info.PsnNo
  21291. PsnCertType = psn_info.PsnCertType
  21292. Certno = psn_info.Certno
  21293. PsnName = psn_info.PsnName
  21294. Gend = psn_info.Gend
  21295. Naty = psn_info.Naty
  21296. Brdy = psn_info.Brdy
  21297. Age = psn_info.Age
  21298. infoStr = psn_info.Insuinfo
  21299. idetinfoStr = psn_info.Idetinfo
  21300. infocode = 0
  21301. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21302. psn_info, _ := service.GetPsnByPatientId(id)
  21303. PsnNo = psn_info.PsnNo
  21304. PsnCertType = psn_info.PsnCertType
  21305. Certno = psn_info.Certno
  21306. PsnName = psn_info.PsnName
  21307. Gend = psn_info.Gend
  21308. Naty = psn_info.Naty
  21309. Brdy = psn_info.Brdy
  21310. Age = psn_info.Age
  21311. infoStr = psn_info.Insuinfo
  21312. idetinfoStr = psn_info.Idetinfo
  21313. infocode = 0
  21314. verify_number = psn_info.VerifyNumber
  21315. } else if miConfig.MdtrtareaAdmvs == "150499" {
  21316. if id_card_type == 2 {
  21317. //请求内网数据
  21318. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  21319. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21320. "&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
  21321. resp, requestErr := http.Get(api)
  21322. if requestErr != nil {
  21323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21324. return
  21325. }
  21326. body, ioErr := ioutil.ReadAll(resp.Body)
  21327. if ioErr != nil {
  21328. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21330. return
  21331. }
  21332. var respJSON map[string]interface{}
  21333. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21334. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21336. return
  21337. }
  21338. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21339. result_byte, _ := json.Marshal(respJSON)
  21340. result := string(result_byte)
  21341. var dat map[string]interface{}
  21342. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21343. fmt.Println(dat)
  21344. } else {
  21345. fmt.Println(err)
  21346. }
  21347. userJSONBytes, _ := json.Marshal(dat)
  21348. var res ResultTwo
  21349. var resTwo10265 ResultTwo10265
  21350. if miConfig.Code == "H15049901371" {
  21351. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  21352. utils.ErrorLog("解析失败:%v", err)
  21353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21354. return
  21355. }
  21356. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  21357. res.Infcode = Infcode
  21358. res.ErrMsg = resTwo10265.ErrMsg
  21359. res.Output = resTwo10265.Output
  21360. res.InfRefmsgid = resTwo10265.InfRefmsgid
  21361. res.RespondTime = resTwo10265.RespondTime
  21362. res.WarnInfo = resTwo10265.WarnInfo
  21363. } else {
  21364. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21365. utils.ErrorLog("解析失败:%v", err)
  21366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21367. return
  21368. }
  21369. }
  21370. //var insutypes []string
  21371. //var insutype string
  21372. //var is390 int = 0
  21373. //var is310 int = 0
  21374. //for _, item := range res.Output.Iinfo {
  21375. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  21376. // insutypes = append(insutypes, item.Insutype)
  21377. // }
  21378. //}
  21379. //if len(insutypes) == 1 {
  21380. // insutype = insutypes[0]
  21381. //} else {
  21382. // for _, i := range insutypes {
  21383. // if i == "390" {
  21384. // is390 = 1
  21385. // }
  21386. //
  21387. // if i == "310" {
  21388. // is310 = 1
  21389. // }
  21390. // }
  21391. //}
  21392. //if is390 == 1 {
  21393. // insutype = "390"
  21394. //}
  21395. //if is310 == 1 {
  21396. // insutype = "310"
  21397. //}
  21398. //if len(insutypes) == 0 {
  21399. // insutype = "310"
  21400. //}
  21401. PsnNo = res.Output.Baseinfo.PsnNo
  21402. PsnCertType = res.Output.Baseinfo.PsnCertType
  21403. Certno = res.Output.Baseinfo.Certno
  21404. PsnName = res.Output.Baseinfo.PsnName
  21405. Gend = res.Output.Baseinfo.Gend
  21406. Naty = res.Output.Baseinfo.Naty
  21407. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21408. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21409. infoStr = string(Iinfos)
  21410. idetinfoStr = string(Idetinfos)
  21411. infocode = res.Infcode
  21412. //infocode = 0
  21413. //verify_number = psn_info.VerifyNumber
  21414. } else {
  21415. psn_info, _ := service.GetPsnByPatientId(id)
  21416. PsnNo = psn_info.PsnNo
  21417. PsnCertType = psn_info.PsnCertType
  21418. Certno = psn_info.Certno
  21419. PsnName = psn_info.PsnName
  21420. Gend = psn_info.Gend
  21421. Naty = psn_info.Naty
  21422. Brdy = psn_info.Brdy
  21423. Age = psn_info.Age
  21424. infoStr = psn_info.Insuinfo
  21425. idetinfoStr = psn_info.Idetinfo
  21426. infocode = 0
  21427. verify_number = psn_info.VerifyNumber
  21428. }
  21429. } else if miConfig.MdtrtareaAdmvs == "350500" {
  21430. if id_card_type == 1 {
  21431. psn_info, _ := service.GetPsnByPatientId(id)
  21432. PsnNo = psn_info.PsnNo
  21433. PsnCertType = psn_info.PsnCertType
  21434. Certno = psn_info.Certno
  21435. PsnName = psn_info.PsnName
  21436. Gend = psn_info.Gend
  21437. Naty = psn_info.Naty
  21438. Brdy = psn_info.Brdy
  21439. Age = psn_info.Age
  21440. infoStr = psn_info.Insuinfo
  21441. idetinfoStr = psn_info.Idetinfo
  21442. infocode = 0
  21443. verify_number = psn_info.VerifyNumber
  21444. } else if id_card_type == 2 {
  21445. 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)
  21446. fmt.Println(errMsgLog)
  21447. saveLog(result, requestLog, "1101", "人员基本信息获取")
  21448. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21449. utils.ErrorLog("解析失败:%v", err)
  21450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21451. return
  21452. }
  21453. PsnNo = res.Output.Baseinfo.PsnNo
  21454. PsnCertType = res.Output.Baseinfo.PsnCertType
  21455. Certno = res.Output.Baseinfo.Certno
  21456. PsnName = res.Output.Baseinfo.PsnName
  21457. Gend = res.Output.Baseinfo.Gend
  21458. Naty = res.Output.Baseinfo.Naty
  21459. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21460. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21461. infoStr = string(Iinfos)
  21462. idetinfoStr = string(Idetinfos)
  21463. infocode = res.Infcode
  21464. }
  21465. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21466. if id_card_type == 1 {
  21467. psn_info, _ := service.GetPsnByPatientId(id)
  21468. PsnNo = psn_info.PsnNo
  21469. PsnCertType = psn_info.PsnCertType
  21470. Certno = psn_info.Certno
  21471. PsnName = psn_info.PsnName
  21472. Gend = psn_info.Gend
  21473. Naty = psn_info.Naty
  21474. Brdy = psn_info.Brdy
  21475. Age = psn_info.Age
  21476. infoStr = psn_info.Insuinfo
  21477. idetinfoStr = psn_info.Idetinfo
  21478. infocode = 0
  21479. verify_number = psn_info.VerifyNumber
  21480. } else if id_card_type == 2 {
  21481. 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, "")
  21482. saveLog(result, requestLog, "1101", "人员基本信息获取")
  21483. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21484. utils.ErrorLog("解析失败:%v", err)
  21485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21486. return
  21487. }
  21488. PsnNo = res.Output.Baseinfo.PsnNo
  21489. PsnCertType = res.Output.Baseinfo.PsnCertType
  21490. Certno = res.Output.Baseinfo.Certno
  21491. PsnName = res.Output.Baseinfo.PsnName
  21492. Gend = res.Output.Baseinfo.Gend
  21493. Naty = res.Output.Baseinfo.Naty
  21494. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21495. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21496. infoStr = string(Iinfos)
  21497. idetinfoStr = string(Idetinfos)
  21498. infocode = res.Infcode
  21499. } else {
  21500. psn_info, _ := service.GetPsnByPatientId(id)
  21501. PsnNo = psn_info.PsnNo
  21502. PsnCertType = psn_info.PsnCertType
  21503. Certno = psn_info.Certno
  21504. PsnName = psn_info.PsnName
  21505. Gend = psn_info.Gend
  21506. Naty = psn_info.Naty
  21507. Brdy = psn_info.Brdy
  21508. Age = psn_info.Age
  21509. infoStr = psn_info.Insuinfo
  21510. idetinfoStr = psn_info.Idetinfo
  21511. infocode = 0
  21512. verify_number = psn_info.VerifyNumber
  21513. }
  21514. } else if miConfig.MdtrtareaAdmvs == "341203" {
  21515. psn_info, _ := service.GetPsnByPatientId(id)
  21516. PsnNo = psn_info.PsnNo
  21517. PsnCertType = psn_info.PsnCertType
  21518. Certno = psn_info.Certno
  21519. PsnName = psn_info.PsnName
  21520. Gend = psn_info.Gend
  21521. Naty = psn_info.Naty
  21522. Brdy = psn_info.Brdy
  21523. Age = psn_info.Age
  21524. infoStr = psn_info.Insuinfo
  21525. idetinfoStr = psn_info.Idetinfo
  21526. infocode = 0
  21527. verify_number = psn_info.VerifyNumber
  21528. } else if miConfig.MdtrtareaAdmvs == "430800" {
  21529. if id_card_type == 1 {
  21530. psn_info, _ := service.GetPsnByPatientId(id)
  21531. PsnNo = psn_info.PsnNo
  21532. PsnCertType = psn_info.PsnCertType
  21533. Certno = psn_info.Certno
  21534. PsnName = psn_info.PsnName
  21535. Gend = psn_info.Gend
  21536. Naty = psn_info.Naty
  21537. Brdy = psn_info.Brdy
  21538. Age = psn_info.Age
  21539. infoStr = psn_info.Insuinfo
  21540. idetinfoStr = psn_info.Idetinfo
  21541. infocode = 0
  21542. verify_number = psn_info.VerifyNumber
  21543. } else if id_card_type == 2 {
  21544. 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)
  21545. saveLog(result, requestLog, "1101", "人员基本信息获取")
  21546. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21547. utils.ErrorLog("解析失败:%v", err)
  21548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21549. return
  21550. }
  21551. PsnNo = res.Output.Baseinfo.PsnNo
  21552. PsnCertType = res.Output.Baseinfo.PsnCertType
  21553. Certno = res.Output.Baseinfo.Certno
  21554. PsnName = res.Output.Baseinfo.PsnName
  21555. Gend = res.Output.Baseinfo.Gend
  21556. Naty = res.Output.Baseinfo.Naty
  21557. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21558. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21559. infoStr = string(Iinfos)
  21560. idetinfoStr = string(Idetinfos)
  21561. infocode = res.Infcode
  21562. } else if id_card_type == 4 {
  21563. psn_info, _ := service.GetPsnByPatientId(id)
  21564. PsnNo = psn_info.PsnNo
  21565. PsnCertType = psn_info.PsnCertType
  21566. Certno = psn_info.Certno
  21567. PsnName = psn_info.PsnName
  21568. Gend = psn_info.Gend
  21569. Naty = psn_info.Naty
  21570. Brdy = psn_info.Brdy
  21571. Age = psn_info.Age
  21572. infoStr = psn_info.Insuinfo
  21573. idetinfoStr = psn_info.Idetinfo
  21574. infocode = 0
  21575. verify_number = psn_info.VerifyNumber
  21576. }
  21577. } else if miConfig.MdtrtareaAdmvs == "131023" {
  21578. var result string
  21579. var requestLog string
  21580. 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), "")
  21581. if id_card_type == 4 {
  21582. psn_info, _ := service.GetPsnByPatientId(id)
  21583. PsnNo = psn_info.PsnNo
  21584. PsnCertType = psn_info.PsnCertType
  21585. Certno = psn_info.Certno
  21586. PsnName = psn_info.PsnName
  21587. Gend = psn_info.Gend
  21588. Naty = psn_info.Naty
  21589. Brdy = psn_info.Brdy
  21590. Age = psn_info.Age
  21591. infoStr = psn_info.Insuinfo
  21592. idetinfoStr = psn_info.Idetinfo
  21593. infocode = 0
  21594. verify_number = psn_info.VerifyNumber
  21595. } else {
  21596. saveLog(result, requestLog, "1101", "人员基本信息获取")
  21597. if miConfig.Code == "H15049901371" {
  21598. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  21599. utils.ErrorLog("解析失败:%v", err)
  21600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21601. return
  21602. }
  21603. res.ErrMsg = res10265.ErrMsg
  21604. res.Output = res10265.Output
  21605. res.InfRefmsgid = res10265.InfRefmsgid
  21606. } else {
  21607. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21608. utils.ErrorLog("解析失败:%v", err)
  21609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21610. return
  21611. }
  21612. }
  21613. PsnNo = res.Output.Baseinfo.PsnNo
  21614. PsnCertType = res.Output.Baseinfo.PsnCertType
  21615. Certno = res.Output.Baseinfo.Certno
  21616. PsnName = res.Output.Baseinfo.PsnName
  21617. Gend = res.Output.Baseinfo.Gend
  21618. Naty = res.Output.Baseinfo.Naty
  21619. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21620. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21621. infoStr = string(Iinfos)
  21622. idetinfoStr = string(Idetinfos)
  21623. if miConfig.Code == "H15049901371" {
  21624. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  21625. } else {
  21626. infocode = res.Infcode
  21627. }
  21628. }
  21629. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21630. psn_info, _ := service.GetPsnByPatientId(id)
  21631. PsnNo = psn_info.PsnNo
  21632. PsnCertType = psn_info.PsnCertType
  21633. Certno = psn_info.Certno
  21634. PsnName = psn_info.PsnName
  21635. Gend = psn_info.Gend
  21636. Naty = psn_info.Naty
  21637. Brdy = psn_info.Brdy
  21638. Age = psn_info.Age
  21639. infoStr = psn_info.Insuinfo
  21640. idetinfoStr = psn_info.Idetinfo
  21641. infocode = 0
  21642. verify_number = psn_info.VerifyNumber
  21643. } else if miConfig.MdtrtareaAdmvs == "450721" {
  21644. psn_info, _ := service.GetPsnByPatientId(id)
  21645. PsnNo = psn_info.PsnNo
  21646. PsnCertType = psn_info.PsnCertType
  21647. Certno = psn_info.Certno
  21648. PsnName = psn_info.PsnName
  21649. Gend = psn_info.Gend
  21650. Naty = psn_info.Naty
  21651. Brdy = psn_info.Brdy
  21652. Age = psn_info.Age
  21653. infoStr = psn_info.Insuinfo
  21654. idetinfoStr = psn_info.Idetinfo
  21655. infocode = 0
  21656. verify_number = psn_info.VerifyNumber
  21657. } else {
  21658. var result string
  21659. var requestLog string
  21660. //if miConfig.UserOrgId == 10138 {
  21661. if id_card_type != 4 || id_card_type != 1 {
  21662. var insa string
  21663. if len(patient.InsuplcAdmdvs) > 0 {
  21664. insa = patient.InsuplcAdmdvs
  21665. } else {
  21666. insa = miConfig.InsuplcAdmdvs
  21667. }
  21668. //psn_info, _ := service.GetPsnByPatientId(id)
  21669. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  21670. 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)
  21671. }
  21672. //}
  21673. //else {
  21674. // var insa string
  21675. // if len(patient.InsuplcAdmdvs) > 0 {
  21676. // insa = patient.InsuplcAdmdvs
  21677. // } else {
  21678. // insa = miConfig.InsuplcAdmdvs
  21679. // }
  21680. // 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)
  21681. //}
  21682. if id_card_type == 4 || id_card_type == 1 {
  21683. psn_info, _ := service.GetPsnByPatientId(id)
  21684. PsnNo = psn_info.PsnNo
  21685. PsnCertType = psn_info.PsnCertType
  21686. Certno = psn_info.Certno
  21687. PsnName = psn_info.PsnName
  21688. Gend = psn_info.Gend
  21689. Naty = psn_info.Naty
  21690. Brdy = psn_info.Brdy
  21691. Age = psn_info.Age
  21692. infoStr = psn_info.Insuinfo
  21693. idetinfoStr = psn_info.Idetinfo
  21694. infocode = 0
  21695. verify_number = psn_info.VerifyNumber
  21696. } else {
  21697. saveLog(result, requestLog, "1101", "人员基本信息获取")
  21698. if miConfig.Code == "H15049901371" {
  21699. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  21700. utils.ErrorLog("解析失败:%v", err)
  21701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21702. return
  21703. }
  21704. res.ErrMsg = res10265.ErrMsg
  21705. res.Output = res10265.Output
  21706. res.InfRefmsgid = res10265.InfRefmsgid
  21707. } else {
  21708. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21709. utils.ErrorLog("解析失败:%v", err)
  21710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21711. return
  21712. }
  21713. }
  21714. PsnNo = res.Output.Baseinfo.PsnNo
  21715. PsnCertType = res.Output.Baseinfo.PsnCertType
  21716. Certno = res.Output.Baseinfo.Certno
  21717. PsnName = res.Output.Baseinfo.PsnName
  21718. Gend = res.Output.Baseinfo.Gend
  21719. Naty = res.Output.Baseinfo.Naty
  21720. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  21721. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  21722. infoStr = string(Iinfos)
  21723. idetinfoStr = string(Idetinfos)
  21724. if miConfig.Code == "H15049901371" {
  21725. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  21726. } else {
  21727. infocode = res.Infcode
  21728. }
  21729. }
  21730. }
  21731. if infocode == 0 {
  21732. his := models.VMHisPatient{
  21733. Name: name,
  21734. Gender: gender,
  21735. Birthday: birthUnix,
  21736. MedicalTreatmentType: medical_care,
  21737. IdType: certificates,
  21738. IdCardNo: id_card,
  21739. BalanceAccountsType: settlementValue,
  21740. SocialType: social_type,
  21741. MedicalInsuranceNumber: medical_insurance_card,
  21742. RegisterType: register_type,
  21743. RegisterCost: registration_fee,
  21744. TreatmentCost: medical_expenses,
  21745. Status: 1,
  21746. Ctime: time.Now().Unix(),
  21747. Mtime: time.Now().Unix(),
  21748. PsnNo: PsnNo,
  21749. PsnCertType: PsnCertType,
  21750. Certno: Certno,
  21751. PsnName: PsnName,
  21752. Gend: Gend,
  21753. Naty: Naty,
  21754. Brdy: Brdy,
  21755. Age: Age,
  21756. Iinfo: infoStr,
  21757. Idetinfo: idetinfoStr,
  21758. PatientId: patient.ID,
  21759. RecordDate: theTime.Unix(),
  21760. UserOrgId: adminInfo.CurrentOrgId,
  21761. AdminUserId: admin_user_id,
  21762. IsReturn: 1,
  21763. IdCardType: id_card_type,
  21764. Doctor: doctor,
  21765. Departments: department,
  21766. MdtrtGrpType: mdtrt_type,
  21767. }
  21768. timestamp := time.Now().Unix()
  21769. tempTime := time.Unix(timestamp, 0)
  21770. timeFormat := tempTime.Format("20060102150405")
  21771. chrgBchno := rand.Intn(100000) + 10000
  21772. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  21773. his.Number = ipt_otp_no
  21774. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  21775. department, _ := service.GetDepartMentDetail(department)
  21776. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  21777. IdCardNo := ""
  21778. if id_card_type == 1 {
  21779. // IdCardNo = medical_insurance_card
  21780. IdCardNo = patient.IdCardNo
  21781. } else {
  21782. IdCardNo = patient.IdCardNo
  21783. }
  21784. var rf []*ResultFive
  21785. json.Unmarshal([]byte(his.Iinfo), &rf)
  21786. var insutypes []*ResultFive
  21787. var insutype string
  21788. var insuplc_admdvs_temp string
  21789. var is390 int = 0
  21790. var is310 int = 0
  21791. for _, item := range rf {
  21792. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  21793. insutypes = append(insutypes, item)
  21794. }
  21795. }
  21796. if len(insutypes) == 1 {
  21797. insutype = insutypes[0].Insutype
  21798. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  21799. if insutype == "390" {
  21800. is390 = 1
  21801. }
  21802. if insutype == "310" {
  21803. is310 = 1
  21804. }
  21805. } else {
  21806. for _, i := range insutypes {
  21807. if i.Insutype == "390" {
  21808. is390 = 1
  21809. }
  21810. if i.Insutype == "310" {
  21811. is310 = 1
  21812. }
  21813. }
  21814. }
  21815. if is390 == 1 {
  21816. insutype = "390"
  21817. }
  21818. if is310 == 1 {
  21819. insutype = "310"
  21820. }
  21821. fmt.Println(social_type)
  21822. if social_type > 0 {
  21823. insutype = strconv.FormatInt(social_type, 10)
  21824. }
  21825. var infocode int64
  21826. var resThree ResultThree
  21827. var resThree10265 ResultThree10265
  21828. if len(insuplc_admdvs) == 0 {
  21829. psn_info, _ := service.GetPsnByPatientId(id)
  21830. //if len(psn_info.InsuplcAdmdvs) > 0 {
  21831. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  21832. //}
  21833. } else {
  21834. insuplc_admdvs_temp = insuplc_admdvs
  21835. }
  21836. if miConfig.MdtrtareaAdmvs == "421300" {
  21837. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  21838. psn_info, _ := service.GetPsnByPatientId(id)
  21839. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  21840. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  21841. "&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
  21842. resp, requestErr := http.Get(api)
  21843. if requestErr != nil {
  21844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21845. return
  21846. }
  21847. body, ioErr := ioutil.ReadAll(resp.Body)
  21848. if ioErr != nil {
  21849. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21851. return
  21852. }
  21853. var respJSON map[string]interface{}
  21854. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21855. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21857. return
  21858. }
  21859. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21860. result, _ := json.Marshal(respJSON)
  21861. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  21862. utils.ErrorLog("解析失败:%v", err)
  21863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21864. return
  21865. }
  21866. infocode = resThree.Infcode
  21867. } else if miConfig.MdtrtareaAdmvs == "420200" {
  21868. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  21869. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  21870. // insuplc_admdvs_temp =
  21871. //}
  21872. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  21873. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  21874. //}
  21875. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  21876. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  21877. "&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
  21878. resp, requestErr := http.Get(api)
  21879. if requestErr != nil {
  21880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21881. return
  21882. }
  21883. body, ioErr := ioutil.ReadAll(resp.Body)
  21884. if ioErr != nil {
  21885. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21887. return
  21888. }
  21889. var respJSON map[string]interface{}
  21890. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21891. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21893. return
  21894. }
  21895. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21896. result, _ := json.Marshal(respJSON)
  21897. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  21898. utils.ErrorLog("解析失败:%v", err)
  21899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21900. return
  21901. }
  21902. infocode = resThree.Infcode
  21903. } else if miConfig.MdtrtareaAdmvs == "420902" {
  21904. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  21905. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  21906. // insuplc_admdvs_temp =
  21907. //}
  21908. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  21909. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  21910. //}
  21911. utils.ErrorLog("解析失败:%v", insutype)
  21912. utils.ErrorLog("解析失败:%v", PsnNo)
  21913. utils.ErrorLog("解析失败:%v", Certno)
  21914. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  21915. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  21916. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  21917. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  21918. utils.ErrorLog("解析失败:%v", PsnNo)
  21919. utils.ErrorLog("解析失败:%v", department.Number)
  21920. utils.ErrorLog("解析失败:%v", department.Name)
  21921. utils.ErrorLog("解析失败:%v", roles.UserName)
  21922. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  21923. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  21924. "&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
  21925. resp, requestErr := http.Get(api)
  21926. if requestErr != nil {
  21927. utils.ErrorLog("解析失败:%v", requestErr)
  21928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21929. return
  21930. }
  21931. body, ioErr := ioutil.ReadAll(resp.Body)
  21932. if ioErr != nil {
  21933. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21935. return
  21936. }
  21937. var respJSON map[string]interface{}
  21938. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21939. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21941. return
  21942. }
  21943. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21944. result, _ := json.Marshal(respJSON)
  21945. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  21946. utils.ErrorLog("解析失败:%v", err)
  21947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21948. return
  21949. }
  21950. infocode = resThree.Infcode
  21951. } else if miConfig.MdtrtareaAdmvs == "421182" {
  21952. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  21953. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  21954. // insuplc_admdvs_temp =
  21955. //}
  21956. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  21957. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  21958. //}
  21959. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  21960. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  21961. "&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
  21962. resp, requestErr := http.Get(api)
  21963. if requestErr != nil {
  21964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21965. return
  21966. }
  21967. body, ioErr := ioutil.ReadAll(resp.Body)
  21968. if ioErr != nil {
  21969. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21971. return
  21972. }
  21973. var respJSON map[string]interface{}
  21974. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21975. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21977. return
  21978. }
  21979. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21980. result, _ := json.Marshal(respJSON)
  21981. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  21982. utils.ErrorLog("解析失败:%v", err)
  21983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21984. return
  21985. }
  21986. infocode = resThree.Infcode
  21987. } else if miConfig.MdtrtareaAdmvs == "150499" {
  21988. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  21989. psn_info, _ := service.GetPsnByPatientId(id)
  21990. var verify_number string
  21991. if id_card_type == 4 {
  21992. verify_number = psn_info.VerifyNumber
  21993. } else if id_card_type == 1 {
  21994. bas := strings.Split(psn_info.CardInfo, "|")
  21995. cardNumber := bas[2]
  21996. verify_number = cardNumber
  21997. }
  21998. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  21999. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22000. "&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
  22001. resp, requestErr := http.Get(api)
  22002. if requestErr != nil {
  22003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22004. return
  22005. }
  22006. body, ioErr := ioutil.ReadAll(resp.Body)
  22007. if ioErr != nil {
  22008. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22010. return
  22011. }
  22012. var respJSON map[string]interface{}
  22013. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22014. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22016. return
  22017. }
  22018. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22019. result, _ := json.Marshal(respJSON)
  22020. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22021. // utils.ErrorLog("解析失败:%v", err)
  22022. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22023. // return
  22024. //}
  22025. //infocode = resThree.Infcode
  22026. //result, _ := json.Marshal(respJSON)
  22027. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22028. utils.ErrorLog("解析失败:%v", err)
  22029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22030. return
  22031. }
  22032. resThree.ErrMsg = resThree10265.ErrMsg
  22033. resThree.Output = resThree10265.Output
  22034. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22035. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22036. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22037. psn_info, _ := service.GetPsnByPatientId(id)
  22038. his.PsnNo = psn_info.PsnNo
  22039. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  22040. var cert_no string
  22041. if id_card_type == 3 {
  22042. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  22043. cert_no = IdCardNo
  22044. } else if id_card_type == 4 {
  22045. cert_no = IdCardNo
  22046. psn_info.VerifyNumber = psn_info.VerifyNumber
  22047. } else {
  22048. bas := strings.Split(psn_info.CardInfo, "|")
  22049. cert_no = bas[2]
  22050. }
  22051. var hisPrescription []*models.HisPrescription
  22052. for _, item := range rf {
  22053. if item.Insutype == insutype {
  22054. //insuplc_admdvs = item.InsuplcAdmdvs
  22055. his.InsuplcAdmdvs = insuplc_admdvs
  22056. }
  22057. }
  22058. his.Insutype = insutype
  22059. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  22060. fmt.Println(res3101)
  22061. fmt.Println(res3101.Infcode)
  22062. if res3101.Infcode == "0" {
  22063. fmt.Println("33333333")
  22064. if len(res3101.Output.Result) > 0 {
  22065. fmt.Println("222222")
  22066. for _, item := range res3101.Output.Result {
  22067. if len(res3101.ErrMsg) == 0 {
  22068. res3101.ErrMsg = item.VolaCont
  22069. } else {
  22070. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  22071. }
  22072. }
  22073. c.ServeSuccessJSON(map[string]interface{}{
  22074. "failed_code": -10,
  22075. "msg": res3101.ErrMsg,
  22076. })
  22077. return
  22078. } else {
  22079. fmt.Println("11111")
  22080. var api string
  22081. if miConfig.MdtrtareaAdmvs == "320921" {
  22082. ipt_otp_no = timeFormat
  22083. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  22084. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22085. "&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
  22086. } else {
  22087. ipt_otp_no = timeFormat
  22088. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  22089. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22090. "&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
  22091. }
  22092. resp, requestErr := http.Get(api)
  22093. if requestErr != nil {
  22094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22095. return
  22096. }
  22097. body, ioErr := ioutil.ReadAll(resp.Body)
  22098. if ioErr != nil {
  22099. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22101. return
  22102. }
  22103. var respJSON map[string]interface{}
  22104. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22105. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22107. return
  22108. }
  22109. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22110. result, _ := json.Marshal(respJSON)
  22111. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22112. utils.ErrorLog("解析失败:%v", err)
  22113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22114. return
  22115. }
  22116. resThree.ErrMsg = resThree10265.ErrMsg
  22117. resThree.Output = resThree10265.Output
  22118. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22119. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22120. }
  22121. } else if res3101.Infcode != "0" {
  22122. c.ServeSuccessJSON(map[string]interface{}{
  22123. "failed_code": -10,
  22124. "msg": res3101.ErrMsg,
  22125. })
  22126. return
  22127. }
  22128. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22129. psn_info, _ := service.GetPsnByPatientId(id)
  22130. var cert_no string
  22131. if id_card_type == 1 {
  22132. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  22133. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  22134. } else if id_card_type == 4 {
  22135. cert_no = psn_info.VerifyNumber
  22136. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  22137. } else {
  22138. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  22139. cert_no = psn_info.VerifyNumber
  22140. }
  22141. 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)
  22142. saveLog(result, requestLog, "2201", "挂号")
  22143. if miConfig.Code == "H15049901371" {
  22144. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22145. utils.ErrorLog("解析失败:%v", err)
  22146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22147. return
  22148. }
  22149. resThree.ErrMsg = resThree10265.ErrMsg
  22150. resThree.Output = resThree10265.Output
  22151. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22152. } else {
  22153. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22154. utils.ErrorLog("解析失败:%v", err)
  22155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22156. return
  22157. }
  22158. }
  22159. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22160. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  22161. psn_info, _ := service.GetPsnByPatientId(id)
  22162. var result string
  22163. var requestLog string
  22164. if id_card_type == 1 {
  22165. bas := strings.Split(psn_info.CardInfo, "|")
  22166. basNumber := bas[2]
  22167. card_sn := bas[3]
  22168. 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)
  22169. saveLog(result, requestLog, "2201A", "挂号")
  22170. } else if id_card_type == 2 {
  22171. 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, "", "", "", "", "", "")
  22172. saveLog(result, requestLog, "2201A", "挂号")
  22173. } else {
  22174. 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)
  22175. saveLog(result, requestLog, "2201A", "挂号")
  22176. }
  22177. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22178. utils.ErrorLog("解析失败:%v", err)
  22179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22180. return
  22181. }
  22182. infocode = resThree.Infcode
  22183. } else if miConfig.MdtrtareaAdmvs == "341203" {
  22184. psn_info, _ := service.GetPsnByPatientId(id)
  22185. his.PsnNo = psn_info.PsnNo
  22186. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  22187. var cert_no string
  22188. if id_card_type == 1 {
  22189. bas := strings.Split(psn_info.CardInfo, "|")
  22190. cert_no = bas[2]
  22191. } else if id_card_type == 4 {
  22192. cert_no = IdCardNo
  22193. psn_info.VerifyNumber = psn_info.VerifyNumber
  22194. } else {
  22195. cert_no = IdCardNo
  22196. psn_info.VerifyNumber = cert_no
  22197. }
  22198. for _, item := range rf {
  22199. if item.Insutype == insutype {
  22200. his.InsuplcAdmdvs = insuplc_admdvs
  22201. }
  22202. }
  22203. his.Insutype = insutype
  22204. var api string
  22205. ipt_otp_no = timeFormat
  22206. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  22207. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22208. "&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
  22209. resp, requestErr := http.Get(api)
  22210. if requestErr != nil {
  22211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22212. return
  22213. }
  22214. body, ioErr := ioutil.ReadAll(resp.Body)
  22215. if ioErr != nil {
  22216. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22218. return
  22219. }
  22220. var respJSON map[string]interface{}
  22221. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22222. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22224. return
  22225. }
  22226. status := respJSON["data"].(map[string]interface{})["status"].(string)
  22227. if status == "0" {
  22228. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  22229. c.ServeSuccessJSON(map[string]interface{}{
  22230. "failed_code": -10,
  22231. "msg": err_msg,
  22232. })
  22233. return
  22234. }
  22235. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22236. result, _ := json.Marshal(respJSON)
  22237. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22238. utils.ErrorLog("解析失败:%v", err)
  22239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22240. return
  22241. }
  22242. infocode = resThree.Infcode
  22243. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22244. psn_info, _ := service.GetPsnByPatientId(id)
  22245. var result string
  22246. var requestLog string
  22247. if id_card_type == 1 {
  22248. bas := strings.Split(psn_info.CardInfo, "|")
  22249. basNumber := bas[2]
  22250. card_sn := bas[3]
  22251. 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)
  22252. saveLog(result, requestLog, "2201A", "挂号")
  22253. } else if id_card_type == 2 {
  22254. 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, "", "")
  22255. saveLog(result, requestLog, "2201A", "挂号")
  22256. } else {
  22257. 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, "", "")
  22258. saveLog(result, requestLog, "2201A", "挂号")
  22259. }
  22260. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22261. utils.ErrorLog("解析失败:%v", err)
  22262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22263. return
  22264. }
  22265. infocode = resThree.Infcode
  22266. } else if miConfig.MdtrtareaAdmvs == "131023" {
  22267. psn_info, _ := service.GetPsnByPatientId(id)
  22268. 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)
  22269. saveLog(result, requestLog, "2201A", "挂号")
  22270. if miConfig.Code == "H15049901371" {
  22271. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22272. utils.ErrorLog("解析失败:%v", err)
  22273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22274. return
  22275. }
  22276. resThree.ErrMsg = resThree10265.ErrMsg
  22277. resThree.Output = resThree10265.Output
  22278. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22279. } else {
  22280. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22281. utils.ErrorLog("解析失败:%v", err)
  22282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22283. return
  22284. }
  22285. }
  22286. if miConfig.Code == "H15049901371" {
  22287. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22288. } else {
  22289. infocode = resThree.Infcode
  22290. }
  22291. } else {
  22292. psn_info, _ := service.GetPsnByPatientId(id)
  22293. if id_card_type == 4 || id_card_type == 1 {
  22294. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  22295. }
  22296. var rf []*ResultFive
  22297. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  22298. var insutypes []*ResultFive
  22299. var insutype string
  22300. var is390 int = 0
  22301. var is310 int = 0
  22302. for _, item := range rf {
  22303. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  22304. insutypes = append(insutypes, item)
  22305. }
  22306. }
  22307. if len(insutypes) == 1 {
  22308. insutype = insutypes[0].Insutype
  22309. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  22310. } else {
  22311. for _, i := range insutypes {
  22312. if i.Insutype == "390" {
  22313. is390 = 1
  22314. }
  22315. if i.Insutype == "310" {
  22316. is310 = 1
  22317. }
  22318. }
  22319. }
  22320. if is390 == 1 {
  22321. insutype = "390"
  22322. }
  22323. if is310 == 1 {
  22324. insutype = "310"
  22325. }
  22326. fmt.Println(len(insutypes))
  22327. if len(insutypes) == 0 {
  22328. for index, item := range rf {
  22329. if index == 0 {
  22330. insutype = item.Insutype
  22331. insuplc_admdvs = item.InsuplcAdmdvs
  22332. }
  22333. }
  22334. fmt.Println(insutype)
  22335. fmt.Println(insuplc_admdvs)
  22336. }
  22337. if social_type > 0 {
  22338. insutype = strconv.FormatInt(social_type, 10)
  22339. }
  22340. fmt.Println("--------")
  22341. fmt.Println(psn_info)
  22342. fmt.Println(psn_info.PsnNo)
  22343. if miConfig.MdtrtareaAdmvs == "441202" {
  22344. var hisPrescription []*models.HisPrescription
  22345. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  22346. if res3101.Infcode == 0 {
  22347. fmt.Println("33333333")
  22348. if len(res3101.Output.Result) > 0 {
  22349. fmt.Println("222222")
  22350. for _, item := range res3101.Output.Result {
  22351. if len(res3101.ErrMsg) == 0 {
  22352. res3101.ErrMsg = item.VolaCont
  22353. } else {
  22354. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  22355. }
  22356. }
  22357. c.ServeSuccessJSON(map[string]interface{}{
  22358. "failed_code": -10,
  22359. "msg": res3101.ErrMsg,
  22360. })
  22361. return
  22362. } else {
  22363. hour := time.Now().Format("15")
  22364. min := time.Now().Format("04")
  22365. sec := time.Now().Format("05")
  22366. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  22367. fmt.Println(record_time_two)
  22368. 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)
  22369. saveLog(result, requestLog, "2201A", "挂号")
  22370. if miConfig.Code == "H15049901371" {
  22371. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22372. utils.ErrorLog("解析失败:%v", err)
  22373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22374. return
  22375. }
  22376. resThree.ErrMsg = resThree10265.ErrMsg
  22377. resThree.Output = resThree10265.Output
  22378. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22379. } else {
  22380. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22381. utils.ErrorLog("解析失败:%v", err)
  22382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22383. return
  22384. }
  22385. }
  22386. if miConfig.Code == "H15049901371" {
  22387. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22388. } else {
  22389. infocode = resThree.Infcode
  22390. }
  22391. }
  22392. } else if res3101.Infcode != 0 {
  22393. c.ServeSuccessJSON(map[string]interface{}{
  22394. "failed_code": -10,
  22395. "msg": res3101.ErrMsg,
  22396. })
  22397. return
  22398. }
  22399. } else if miConfig.MdtrtareaAdmvs == "440205" {
  22400. var hisPrescription []*models.HisPrescription
  22401. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  22402. if res3101.Infcode == 0 {
  22403. fmt.Println("33333333")
  22404. if len(res3101.Output.Result) > 0 {
  22405. fmt.Println("222222")
  22406. for _, item := range res3101.Output.Result {
  22407. if len(res3101.ErrMsg) == 0 {
  22408. res3101.ErrMsg = item.VolaCont
  22409. } else {
  22410. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  22411. }
  22412. }
  22413. c.ServeSuccessJSON(map[string]interface{}{
  22414. "failed_code": -10,
  22415. "msg": res3101.ErrMsg,
  22416. })
  22417. return
  22418. } else {
  22419. hour := time.Now().Format("15")
  22420. min := time.Now().Format("04")
  22421. sec := time.Now().Format("05")
  22422. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  22423. fmt.Println(record_time_two)
  22424. 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)
  22425. saveLog(result, requestLog, "2201A", "挂号")
  22426. if miConfig.Code == "H15049901371" {
  22427. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22428. utils.ErrorLog("解析失败:%v", err)
  22429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22430. return
  22431. }
  22432. resThree.ErrMsg = resThree10265.ErrMsg
  22433. resThree.Output = resThree10265.Output
  22434. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22435. } else {
  22436. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22437. utils.ErrorLog("解析失败:%v", err)
  22438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22439. return
  22440. }
  22441. }
  22442. if miConfig.Code == "H15049901371" {
  22443. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22444. } else {
  22445. infocode = resThree.Infcode
  22446. }
  22447. }
  22448. } else if res3101.Infcode != 0 {
  22449. c.ServeSuccessJSON(map[string]interface{}{
  22450. "failed_code": -10,
  22451. "msg": res3101.ErrMsg,
  22452. })
  22453. return
  22454. }
  22455. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22456. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  22457. psn_info, _ := service.GetPsnByPatientId(id)
  22458. var verify_number string
  22459. if id_card_type == 4 {
  22460. verify_number = psn_info.VerifyNumber
  22461. } else if id_card_type == 1 {
  22462. bas := strings.Split(psn_info.CardInfo, "|")
  22463. cardNumber := bas[2]
  22464. verify_number = cardNumber
  22465. } else {
  22466. verify_number = psn_info.Certno
  22467. }
  22468. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  22469. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  22470. "&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
  22471. resp, requestErr := http.Get(api)
  22472. if requestErr != nil {
  22473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22474. return
  22475. }
  22476. body, ioErr := ioutil.ReadAll(resp.Body)
  22477. if ioErr != nil {
  22478. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22480. return
  22481. }
  22482. var respJSON map[string]interface{}
  22483. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22484. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22486. return
  22487. }
  22488. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22489. result, _ := json.Marshal(respJSON)
  22490. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22491. utils.ErrorLog("解析失败:%v", err)
  22492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22493. return
  22494. }
  22495. infocode = resThree.Infcode
  22496. } else {
  22497. hour := time.Now().Format("15")
  22498. min := time.Now().Format("04")
  22499. sec := time.Now().Format("05")
  22500. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  22501. if id_card_type == 1 {
  22502. for _, item := range rf {
  22503. if item.Insutype == strconv.FormatInt(social_type, 10) {
  22504. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  22505. insuplc_admdvs_temp = item.InsuplcAdmdvs
  22506. } else if strconv.FormatInt(social_type, 10) == "390" {
  22507. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  22508. } else {
  22509. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  22510. }
  22511. }
  22512. }
  22513. }
  22514. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  22515. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  22516. }
  22517. if id_card_type == 1 {
  22518. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  22519. bas := strings.Split(psn_info.CardInfo, "|")
  22520. basNumber := bas[1]
  22521. IdCardNo = basNumber
  22522. }
  22523. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  22524. IdCardNo = psn_info.VerifyNumber
  22525. }
  22526. if len(insuplc_admdvs_temp) == 0 {
  22527. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  22528. }
  22529. 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)
  22530. saveLog(result, requestLog, "2201A", "挂号")
  22531. if miConfig.Code == "H15049901371" {
  22532. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  22533. utils.ErrorLog("解析失败:%v", err)
  22534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22535. return
  22536. }
  22537. resThree.ErrMsg = resThree10265.ErrMsg
  22538. resThree.Output = resThree10265.Output
  22539. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  22540. } else {
  22541. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  22542. utils.ErrorLog("解析失败:%v", err)
  22543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22544. return
  22545. }
  22546. }
  22547. if miConfig.Code == "H15049901371" {
  22548. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  22549. } else {
  22550. infocode = resThree.Infcode
  22551. }
  22552. }
  22553. }
  22554. if infocode == -1 {
  22555. adminUser := c.GetAdminUserInfo()
  22556. errlog := &models.HisOrderError{
  22557. UserOrgId: adminUser.CurrentOrgId,
  22558. Ctime: time.Now().Unix(),
  22559. Mtime: time.Now().Unix(),
  22560. ErrMsg: resThree.ErrMsg,
  22561. Status: 1,
  22562. PatientId: id,
  22563. RecordTime: recordDateTime,
  22564. Stage: 2,
  22565. }
  22566. service.CreateErrMsgLog(errlog)
  22567. c.ServeSuccessJSON(map[string]interface{}{
  22568. "failed_code": -10,
  22569. "msg": resThree.ErrMsg,
  22570. })
  22571. return
  22572. }
  22573. his.Number = resThree.Output.Data.MdtrtID
  22574. his.PsnNo = resThree.Output.Data.PsnNo
  22575. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  22576. his.IdCardNo = patient.IdCardNo
  22577. his.PhoneNumber = patient.Phone
  22578. his.UserOrgId = adminInfo.CurrentOrgId
  22579. his.Insutype = insutype
  22580. his.Ctime = time.Now().Unix()
  22581. his.Mtime = time.Now().Unix()
  22582. his.InsuplcAdmdvs = insuplc_admdvs_temp
  22583. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  22584. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  22585. }
  22586. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  22587. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  22588. }
  22589. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  22590. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  22591. }
  22592. his.Status = 1
  22593. his.MdtrtGrpType = mdtrt_type
  22594. service.UpdateHisPatientStatus(&his)
  22595. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  22596. c.ServeSuccessJSON(map[string]interface{}{
  22597. "his_info": his,
  22598. })
  22599. } else {
  22600. adminUser := c.GetAdminUserInfo()
  22601. errlog := &models.HisOrderError{
  22602. UserOrgId: adminUser.CurrentOrgId,
  22603. Ctime: time.Now().Unix(),
  22604. Mtime: time.Now().Unix(),
  22605. ErrMsg: res.ErrMsg,
  22606. Status: 1,
  22607. PatientId: id,
  22608. RecordTime: recordDateTime,
  22609. Stage: 1,
  22610. }
  22611. service.CreateErrMsgLog(errlog)
  22612. c.ServeSuccessJSON(map[string]interface{}{
  22613. "failed_code": -10,
  22614. "msg": res.ErrMsg,
  22615. })
  22616. return
  22617. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  22618. }
  22619. }
  22620. }
  22621. func (c *HisApiController) GetUploadInfo() {
  22622. id, _ := c.GetInt64("id")
  22623. record_time := c.GetString("record_time")
  22624. his_patient_id, _ := c.GetInt64("his_patient_id")
  22625. order_id, _ := c.GetInt64("order_id")
  22626. pay_way, _ := c.GetInt64("pay_way")
  22627. pay_ways := c.GetString("pay_ways")
  22628. oth_desc := c.GetString("oth_desc")
  22629. pay_price, _ := c.GetFloat("pay_price")
  22630. pay_card_no := c.GetString("pay_card_no")
  22631. discount_price, _ := c.GetFloat("discount_price")
  22632. preferential_price, _ := c.GetFloat("preferential_price")
  22633. reality_price, _ := c.GetFloat("reality_price")
  22634. found_price, _ := c.GetFloat("found_price")
  22635. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  22636. private_price, _ := c.GetFloat("private_price")
  22637. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  22638. admin_user_id, _ := c.GetInt64("admin_user_id")
  22639. fapiao_code := c.GetString("fapiao_code")
  22640. fapiao_number := c.GetString("fapiao_number")
  22641. diagnosis_id := c.GetString("diagnosis")
  22642. sick_type, _ := c.GetInt64("sick_type")
  22643. reg_type, _ := c.GetInt64("p_type")
  22644. begin_time := c.GetString("begin_time")
  22645. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  22646. cash_pay := c.GetString("cash_pay")
  22647. band_card_pay := c.GetString("band_card_pay")
  22648. wechat_pay := c.GetString("wechat_pay")
  22649. ali_pay := c.GetString("ali_pay")
  22650. jifen_pay := c.GetString("jifen_pay")
  22651. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  22652. fmt.Println(acct_used_flag)
  22653. id_str := c.GetString("ids")
  22654. ids_arr := strings.Split(id_str, ",")
  22655. timeLayout := "2006-01-02"
  22656. loc, _ := time.LoadLocation("Local")
  22657. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  22658. if err != nil {
  22659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22660. return
  22661. }
  22662. recordDateTime := theTime.Unix()
  22663. adminUser := c.GetAdminUserInfo()
  22664. var tempOrder models.HisOrder
  22665. tempOrder, _ = service.GetHisOrderByID(order_id)
  22666. var prescriptions []*models.HisPrescription
  22667. var start_time int64
  22668. var end_time int64
  22669. //押金模块
  22670. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  22671. tmp_decimal := c.GetString("tmp_decimal")
  22672. var decimal float64 //本次使用的押金
  22673. var errmsg error
  22674. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  22675. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  22676. return
  22677. }
  22678. if len(tmp_decimal) > 0 {
  22679. if tmp_decimal[0] == 45 {
  22680. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  22681. return
  22682. }
  22683. }
  22684. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  22685. fmt.Println(errs)
  22686. decimal = tt
  22687. //if adminUser.CurrentOrgId == 10106{
  22688. // if len(fapiao_code) == 0{
  22689. // fapiao_code = "144072080589"
  22690. // }
  22691. // if len(fapiao_number) == 0{
  22692. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  22693. // if order.ID == 0{
  22694. // fapiao_number = "00001520"
  22695. // }else{
  22696. // //fapiao_code = "00001520"
  22697. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  22698. // var zero string
  22699. // if fpNumber >= 1000{
  22700. // zero = "0000" + strconv.Itoa(fpNumber)
  22701. // }else if fpNumber >= 10000{
  22702. // zero = "000" + strconv.Itoa(fpNumber)
  22703. // } else if fpNumber >= 100000{
  22704. // zero = "00" + strconv.Itoa(fpNumber)
  22705. // } else if fpNumber >= 1000000{
  22706. // zero = "0" + strconv.Itoa(fpNumber)
  22707. // }else {
  22708. // zero = strconv.Itoa(fpNumber)
  22709. // }
  22710. // fapiao_number = zero
  22711. // }
  22712. // }
  22713. //}
  22714. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  22715. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  22716. var patientPrescription models.HisPrescriptionInfo
  22717. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  22718. if patientPrescription.ID == 0 {
  22719. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  22720. }
  22721. //if patientPrescription.Do
  22722. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  22723. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  22724. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  22725. diagnosis_ids := strings.Split(diagnosis_id, ",")
  22726. var config []*models.HisXtDiagnoseConfig
  22727. for _, item := range diagnosis_ids {
  22728. id, _ := strconv.ParseInt(item, 10, 64)
  22729. diagnosisConfig, _ := service.FindDiagnoseById(id)
  22730. config = append(config, &diagnosisConfig)
  22731. }
  22732. sickConfig, _ := service.FindSickById(sick_type)
  22733. //if tempOrder.ID == 0 {
  22734. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  22735. //}
  22736. if tempOrder.ID == 0 {
  22737. var result string
  22738. var requestLog string
  22739. var res2 ResultSix
  22740. var res3 GZResultSix
  22741. var ressix10265 ResultSix10265
  22742. if miConfig.MdtrtareaAdmvs == "421300" {
  22743. data := make(map[string]interface{})
  22744. client := &http.Client{}
  22745. data["psn_no"] = his.PsnNo
  22746. data["mdtrt_id"] = his.Number
  22747. data["opter"] = roles.UserName
  22748. data["org_name"] = miConfig.OrgName
  22749. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22750. data["doctor_id"] = doctor_info.DoctorNumber
  22751. data["doctor_name"] = doctor_info.UserName
  22752. data["department"] = department.Name
  22753. data["fixmedins_code"] = miConfig.Code
  22754. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22755. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22756. data["secret_key"] = miConfig.SecretKey
  22757. data["sick_code"] = sickConfig.CountryCode
  22758. data["sick_name"] = sickConfig.ClassName
  22759. data["dept"] = strconv.FormatInt(department.ID, 10)
  22760. data["config"] = config
  22761. data["begin_time"] = begin_time
  22762. bytesData, _ := json.Marshal(data)
  22763. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  22764. resp, _ := client.Do(req)
  22765. defer resp.Body.Close()
  22766. body, ioErr := ioutil.ReadAll(resp.Body)
  22767. if ioErr != nil {
  22768. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22770. return
  22771. }
  22772. var respJSON map[string]interface{}
  22773. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22774. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22776. return
  22777. }
  22778. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22779. userJSONBytes, _ := json.Marshal(respJSON)
  22780. fmt.Println("log")
  22781. fmt.Println(string(userJSONBytes))
  22782. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22783. utils.ErrorLog("解析失败:%v", err)
  22784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22785. return
  22786. }
  22787. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22788. data := make(map[string]interface{})
  22789. client := &http.Client{}
  22790. data["psn_no"] = his.PsnNo
  22791. data["mdtrt_id"] = his.Number
  22792. data["opter"] = roles.UserName
  22793. data["org_name"] = miConfig.OrgName
  22794. if reg_type == 11 && his.Insutype == "390" {
  22795. data["med_type"] = "110104"
  22796. } else {
  22797. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22798. }
  22799. data["doctor_id"] = doctor_info.DoctorNumber
  22800. data["doctor_name"] = doctor_info.UserName
  22801. data["department"] = department.Name
  22802. data["fixmedins_code"] = miConfig.Code
  22803. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22804. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22805. data["secret_key"] = miConfig.SecretKey
  22806. data["sick_code"] = sickConfig.CountryCode
  22807. data["sick_name"] = sickConfig.ClassName
  22808. data["dept"] = strconv.FormatInt(department.ID, 10)
  22809. data["config"] = config
  22810. data["begin_time"] = begin_time
  22811. bytesData, _ := json.Marshal(data)
  22812. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  22813. resp, _ := client.Do(req)
  22814. defer resp.Body.Close()
  22815. body, ioErr := ioutil.ReadAll(resp.Body)
  22816. if ioErr != nil {
  22817. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22819. return
  22820. }
  22821. var respJSON map[string]interface{}
  22822. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22823. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22825. return
  22826. }
  22827. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22828. userJSONBytes, _ := json.Marshal(respJSON)
  22829. fmt.Println("log")
  22830. fmt.Println(string(userJSONBytes))
  22831. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22832. utils.ErrorLog("解析失败:%v", err)
  22833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22834. return
  22835. }
  22836. } else if miConfig.MdtrtareaAdmvs == "420902" {
  22837. data := make(map[string]interface{})
  22838. client := &http.Client{}
  22839. data["psn_no"] = his.PsnNo
  22840. data["mdtrt_id"] = his.Number
  22841. data["opter"] = roles.UserName
  22842. data["org_name"] = miConfig.OrgName
  22843. if reg_type == 11 && his.Insutype == "390" {
  22844. data["med_type"] = "110104"
  22845. } else {
  22846. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22847. }
  22848. data["doctor_id"] = doctor_info.DoctorNumber
  22849. data["doctor_name"] = doctor_info.UserName
  22850. data["department"] = department.Name
  22851. data["fixmedins_code"] = miConfig.Code
  22852. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22853. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22854. data["secret_key"] = miConfig.SecretKey
  22855. data["sick_code"] = sickConfig.CountryCode
  22856. data["sick_name"] = sickConfig.ClassName
  22857. data["dept"] = strconv.FormatInt(department.ID, 10)
  22858. data["config"] = config
  22859. data["begin_time"] = begin_time
  22860. bytesData, _ := json.Marshal(data)
  22861. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  22862. resp, _ := client.Do(req)
  22863. defer resp.Body.Close()
  22864. body, ioErr := ioutil.ReadAll(resp.Body)
  22865. if ioErr != nil {
  22866. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22868. return
  22869. }
  22870. var respJSON map[string]interface{}
  22871. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22874. return
  22875. }
  22876. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22877. userJSONBytes, _ := json.Marshal(respJSON)
  22878. fmt.Println("log")
  22879. fmt.Println(string(userJSONBytes))
  22880. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22881. utils.ErrorLog("解析失败:%v", err)
  22882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22883. return
  22884. }
  22885. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22886. data := make(map[string]interface{})
  22887. client := &http.Client{}
  22888. data["psn_no"] = his.PsnNo
  22889. data["mdtrt_id"] = his.Number
  22890. data["opter"] = roles.UserName
  22891. data["org_name"] = miConfig.OrgName
  22892. if reg_type == 11 && his.Insutype == "390" {
  22893. data["med_type"] = "110104"
  22894. } else {
  22895. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22896. }
  22897. data["doctor_id"] = doctor_info.DoctorNumber
  22898. data["doctor_name"] = doctor_info.UserName
  22899. data["department"] = department.Name
  22900. data["fixmedins_code"] = miConfig.Code
  22901. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22902. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22903. data["secret_key"] = miConfig.SecretKey
  22904. data["sick_code"] = sickConfig.CountryCode
  22905. data["sick_name"] = sickConfig.ClassName
  22906. data["dept"] = strconv.FormatInt(department.ID, 10)
  22907. data["config"] = config
  22908. data["begin_time"] = begin_time
  22909. bytesData, _ := json.Marshal(data)
  22910. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  22911. resp, _ := client.Do(req)
  22912. defer resp.Body.Close()
  22913. body, ioErr := ioutil.ReadAll(resp.Body)
  22914. if ioErr != nil {
  22915. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22917. return
  22918. }
  22919. var respJSON map[string]interface{}
  22920. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22921. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22923. return
  22924. }
  22925. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22926. userJSONBytes, _ := json.Marshal(respJSON)
  22927. fmt.Println("log")
  22928. fmt.Println(string(userJSONBytes))
  22929. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22930. utils.ErrorLog("解析失败:%v", err)
  22931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22932. return
  22933. }
  22934. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22935. data := make(map[string]interface{})
  22936. client := &http.Client{}
  22937. data["psn_no"] = his.PsnNo
  22938. data["mdtrt_id"] = his.Number
  22939. data["doctor"] = roles.UserName
  22940. data["department"] = department.Name
  22941. data["org_name"] = miConfig.OrgName
  22942. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22943. data["doctor_id"] = doctor_info.DoctorNumber
  22944. data["new_doctor_name"] = doctor_info.UserName
  22945. data["fixmedins_code"] = miConfig.Code
  22946. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22947. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22948. data["secret_key"] = miConfig.SecretKey
  22949. data["sick_code"] = sickConfig.CountryCode
  22950. data["sick_name"] = sickConfig.ClassName
  22951. data["url"] = miConfig.Url
  22952. data["ak"] = miConfig.AccessKey
  22953. data["begin_time"] = begin_time
  22954. data["cainfo"] = miConfig.Cainfo
  22955. data["dept"] = strconv.FormatInt(department.ID, 10)
  22956. data["config"] = config
  22957. bytesData, _ := json.Marshal(data)
  22958. var req *http.Request
  22959. if miConfig.MdtrtareaAdmvs == "320921" {
  22960. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  22961. //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 +
  22962. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  22963. } else {
  22964. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  22965. }
  22966. resp, _ := client.Do(req)
  22967. defer resp.Body.Close()
  22968. body, ioErr := ioutil.ReadAll(resp.Body)
  22969. if ioErr != nil {
  22970. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22972. return
  22973. }
  22974. var respJSON map[string]interface{}
  22975. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22976. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22978. return
  22979. }
  22980. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22981. userJSONBytes, _ := json.Marshal(respJSON)
  22982. fmt.Println("log")
  22983. fmt.Println(string(userJSONBytes))
  22984. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  22985. utils.ErrorLog("解析失败:%v", err)
  22986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22987. return
  22988. }
  22989. res2.InfRefmsgid = ressix10265.InfRefmsgid
  22990. res2.Output = ressix10265.Output
  22991. res2.ErrMsg = ressix10265.ErrMsg
  22992. res2.Cainfo = ressix10265.Cainfo
  22993. res2.WarnMsg = ressix10265.WarnMsg
  22994. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  22995. res2.Infcode = infocode
  22996. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22997. data := make(map[string]interface{})
  22998. client := &http.Client{}
  22999. data["psn_no"] = his.PsnNo
  23000. data["mdtrt_id"] = his.Number
  23001. data["doctor"] = roles.UserName
  23002. data["department"] = department.Name
  23003. data["org_name"] = miConfig.OrgName
  23004. data["med_type"] = strconv.FormatInt(reg_type, 10)
  23005. data["doctor_id"] = doctor_info.DoctorNumber
  23006. data["new_doctor_name"] = doctor_info.UserName
  23007. data["fixmedins_code"] = miConfig.Code
  23008. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  23009. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  23010. data["secret_key"] = miConfig.SecretKey
  23011. data["sick_code"] = sickConfig.CountryCode
  23012. data["sick_name"] = sickConfig.ClassName
  23013. data["url"] = miConfig.Url
  23014. data["ak"] = miConfig.AccessKey
  23015. data["begin_time"] = begin_time
  23016. data["cainfo"] = miConfig.Cainfo
  23017. data["dept"] = strconv.FormatInt(department.ID, 10)
  23018. data["config"] = config
  23019. bytesData, _ := json.Marshal(data)
  23020. var req *http.Request
  23021. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  23022. resp, _ := client.Do(req)
  23023. defer resp.Body.Close()
  23024. body, ioErr := ioutil.ReadAll(resp.Body)
  23025. if ioErr != nil {
  23026. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23028. return
  23029. }
  23030. var respJSON map[string]interface{}
  23031. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23032. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23034. return
  23035. }
  23036. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23037. userJSONBytes, _ := json.Marshal(respJSON)
  23038. fmt.Println("log")
  23039. fmt.Println(string(userJSONBytes))
  23040. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  23041. utils.ErrorLog("解析失败:%v", err)
  23042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23043. return
  23044. }
  23045. res2.InfRefmsgid = ressix10265.InfRefmsgid
  23046. res2.Output = ressix10265.Output
  23047. res2.ErrMsg = ressix10265.ErrMsg
  23048. res2.Cainfo = ressix10265.Cainfo
  23049. res2.WarnMsg = ressix10265.WarnMsg
  23050. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  23051. res2.Infcode = infocode
  23052. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23053. 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)
  23054. saveLog(result, requestLog, "2203", "上传就诊信息")
  23055. var respJSON2 map[string]interface{}
  23056. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  23057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23059. return
  23060. }
  23061. userJSONBytes2, _ := json.Marshal(respJSON2)
  23062. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  23063. utils.ErrorLog("解析失败:%v", err)
  23064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23065. return
  23066. }
  23067. 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)
  23068. fmt.Println(result2)
  23069. fmt.Println(src_request)
  23070. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23071. data := make(map[string]interface{})
  23072. client := &http.Client{}
  23073. data["psn_no"] = his.PsnNo
  23074. data["mdtrt_id"] = his.Number
  23075. data["doctor"] = roles.UserName
  23076. data["department"] = department.Name
  23077. data["org_name"] = miConfig.OrgName
  23078. data["med_type"] = strconv.FormatInt(reg_type, 10)
  23079. data["doctor_id"] = doctor_info.DoctorNumber
  23080. data["new_doctor_name"] = doctor_info.UserName
  23081. data["fixmedins_code"] = miConfig.Code
  23082. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  23083. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  23084. data["secret_key"] = miConfig.SecretKey
  23085. data["sick_code"] = sickConfig.CountryCode
  23086. data["sick_name"] = sickConfig.ClassName
  23087. data["url"] = miConfig.Url
  23088. data["ak"] = miConfig.AccessKey
  23089. data["begin_time"] = begin_time
  23090. data["cainfo"] = miConfig.Cainfo
  23091. data["dept"] = strconv.FormatInt(department.ID, 10)
  23092. data["config"] = config
  23093. bytesData, _ := json.Marshal(data)
  23094. var req *http.Request
  23095. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  23096. resp, _ := client.Do(req)
  23097. defer resp.Body.Close()
  23098. body, ioErr := ioutil.ReadAll(resp.Body)
  23099. if ioErr != nil {
  23100. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23102. return
  23103. }
  23104. var respJSON map[string]interface{}
  23105. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23106. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23108. return
  23109. }
  23110. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23111. userJSONBytes, _ := json.Marshal(respJSON)
  23112. fmt.Println("log")
  23113. fmt.Println(string(userJSONBytes))
  23114. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23115. utils.ErrorLog("解析失败:%v", err)
  23116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23117. return
  23118. }
  23119. } else {
  23120. if miConfig.MdtrtareaAdmvs == "440781" { //
  23121. 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)
  23122. } else {
  23123. if miConfig.Code == "H15049901371" {
  23124. //赤峰地区国家医保医疗类别
  23125. //职工透析:医疗类别选特殊情况门诊990502
  23126. //居民定额血透门慢: 医疗类别选门诊慢病140104
  23127. var med_type string
  23128. if his.Insutype == "390" {
  23129. if reg_type == 14 {
  23130. med_type = "9933"
  23131. } else if reg_type == 11 {
  23132. med_type = "11"
  23133. }
  23134. } else if his.Insutype == "310" {
  23135. if reg_type == 14 {
  23136. med_type = "990502"
  23137. } else if reg_type == 11 {
  23138. med_type = "11"
  23139. }
  23140. }
  23141. 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)
  23142. } else {
  23143. 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)
  23144. }
  23145. }
  23146. saveLog(result, requestLog, "2203", "上传就诊信息")
  23147. var respJSON2 map[string]interface{}
  23148. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  23149. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23151. return
  23152. }
  23153. userJSONBytes2, _ := json.Marshal(respJSON2)
  23154. if miConfig.Code == "H15049901371" {
  23155. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  23156. utils.ErrorLog("解析失败:%v", err)
  23157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23158. return
  23159. }
  23160. res2.InfRefmsgid = ressix10265.InfRefmsgid
  23161. res2.Output = ressix10265.Output
  23162. res2.ErrMsg = ressix10265.ErrMsg
  23163. res2.Cainfo = ressix10265.Cainfo
  23164. res2.WarnMsg = ressix10265.WarnMsg
  23165. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  23166. res2.Infcode = infocode
  23167. } else {
  23168. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23169. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  23170. utils.ErrorLog("解析失败:%v", err)
  23171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23172. return
  23173. }
  23174. res2.Infcode = res3.Infcode
  23175. } else {
  23176. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  23177. utils.ErrorLog("解析失败:%v", err)
  23178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23179. return
  23180. }
  23181. }
  23182. }
  23183. }
  23184. if res2.Infcode == -1 {
  23185. adminUser := c.GetAdminUserInfo()
  23186. errlog := &models.HisOrderError{
  23187. UserOrgId: adminUser.CurrentOrgId,
  23188. Ctime: time.Now().Unix(),
  23189. Mtime: time.Now().Unix(),
  23190. ErrMsg: res2.ErrMsg,
  23191. Status: 1,
  23192. PatientId: id,
  23193. RecordTime: recordDateTime,
  23194. Stage: 3,
  23195. }
  23196. service.CreateErrMsgLog(errlog)
  23197. c.ServeSuccessJSON(map[string]interface{}{
  23198. "failed_code": -10,
  23199. "msg": res2.ErrMsg,
  23200. })
  23201. return
  23202. } else {
  23203. his.Diagnosis = diagnosis_id
  23204. his.SickType = sickConfig.ID
  23205. //var p_type int64
  23206. //if reg_type == 1111 || reg_type == 1112 {
  23207. // p_type = 11
  23208. //
  23209. //}
  23210. his.PType = fmt.Sprintf("%d", reg_type)
  23211. service.UpdateHisPatientThree(&his)
  23212. data := make(map[string]interface{})
  23213. if settle_accounts_type == 1 { //日结
  23214. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  23215. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  23216. } else {
  23217. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  23218. }
  23219. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  23220. data["pre"] = prescriptions
  23221. } else { //月结
  23222. start_time_str := c.GetString("start_time")
  23223. end_time_str := c.GetString("end_time")
  23224. timeLayout := "2006-01-02"
  23225. loc, _ := time.LoadLocation("Local")
  23226. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  23227. if err != nil {
  23228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23229. return
  23230. }
  23231. recordStartTime := theStartTime.Unix()
  23232. start_time = recordStartTime
  23233. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  23234. if err != nil {
  23235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23236. return
  23237. }
  23238. recordEndTime := theEndTime.Unix()
  23239. end_time = recordEndTime
  23240. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  23241. data["pre"] = prescriptions
  23242. }
  23243. timestamp := time.Now().Unix()
  23244. tempTime := time.Unix(timestamp, 0)
  23245. timeFormat := tempTime.Format("20060102150405")
  23246. chrgBchno := rand.Intn(100000) + 10000
  23247. new_chrg_bchno := ""
  23248. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  23249. new_chrg_bchno = chrg_bchno
  23250. strconv.FormatInt(his.PatientId, 10)
  23251. client := &http.Client{}
  23252. if adminUser.CurrentOrgId == 10265 {
  23253. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  23254. new_chrg_bchno = "0000"
  23255. }
  23256. }
  23257. data["psn_no"] = his.PsnNo
  23258. data["mdtrt_id"] = his.Number
  23259. data["chrg_bchno"] = new_chrg_bchno
  23260. data["org_name"] = miConfig.OrgName
  23261. data["doctor"] = doctor_info.UserName
  23262. data["doctor_id"] = doctor_info.DoctorNumber
  23263. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  23264. data["fixmedins_code"] = miConfig.Code
  23265. data["dept_code"] = department.Number
  23266. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  23267. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  23268. data["secret_key"] = miConfig.SecretKey
  23269. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  23270. data["url"] = miConfig.Url
  23271. data["ak"] = miConfig.AccessKey
  23272. data["new_doctor_name"] = patientPrescription.Doctor
  23273. data["diag_code"] = sickConfig.CountryCode
  23274. data["cainfo"] = miConfig.Cainfo
  23275. data["opter"] = roles.UserName
  23276. var ids []int64
  23277. for _, item := range prescriptions {
  23278. ids = append(ids, item.ID)
  23279. }
  23280. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  23281. if config.IsOpen == 1 { //对接了医保,走医保流程
  23282. var res ResultFour
  23283. var resFour10265 ResultFour10265
  23284. if miConfig.MdtrtareaAdmvs == "421300" {
  23285. bytesData, _ := json.Marshal(data)
  23286. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  23287. resp, _ := client.Do(req)
  23288. defer resp.Body.Close()
  23289. body, ioErr := ioutil.ReadAll(resp.Body)
  23290. if ioErr != nil {
  23291. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23293. return
  23294. }
  23295. var respJSON map[string]interface{}
  23296. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23297. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23299. return
  23300. }
  23301. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23302. userJSONBytes, _ := json.Marshal(respJSON)
  23303. fmt.Println("log")
  23304. fmt.Println(string(userJSONBytes))
  23305. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23306. utils.ErrorLog("解析失败:%v", err)
  23307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23308. return
  23309. }
  23310. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23311. bytesData, _ := json.Marshal(data)
  23312. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  23313. resp, _ := client.Do(req)
  23314. defer resp.Body.Close()
  23315. body, ioErr := ioutil.ReadAll(resp.Body)
  23316. if ioErr != nil {
  23317. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23319. return
  23320. }
  23321. var respJSON map[string]interface{}
  23322. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23323. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23325. return
  23326. }
  23327. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23328. userJSONBytes, _ := json.Marshal(respJSON)
  23329. fmt.Println("log")
  23330. fmt.Println(string(userJSONBytes))
  23331. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23332. utils.ErrorLog("解析失败:%v", err)
  23333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23334. return
  23335. }
  23336. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23337. bytesData, _ := json.Marshal(data)
  23338. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  23339. resp, _ := client.Do(req)
  23340. defer resp.Body.Close()
  23341. body, ioErr := ioutil.ReadAll(resp.Body)
  23342. if ioErr != nil {
  23343. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23345. return
  23346. }
  23347. var respJSON map[string]interface{}
  23348. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23349. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23351. return
  23352. }
  23353. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23354. userJSONBytes, _ := json.Marshal(respJSON)
  23355. fmt.Println("log")
  23356. fmt.Println(string(userJSONBytes))
  23357. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23358. utils.ErrorLog("解析失败:%v", err)
  23359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23360. return
  23361. }
  23362. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23363. bytesData, _ := json.Marshal(data)
  23364. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  23365. resp, _ := client.Do(req)
  23366. defer resp.Body.Close()
  23367. body, ioErr := ioutil.ReadAll(resp.Body)
  23368. if ioErr != nil {
  23369. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23371. return
  23372. }
  23373. var respJSON map[string]interface{}
  23374. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23375. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23377. return
  23378. }
  23379. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23380. userJSONBytes, _ := json.Marshal(respJSON)
  23381. fmt.Println("log")
  23382. fmt.Println(string(userJSONBytes))
  23383. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23384. utils.ErrorLog("解析失败:%v", err)
  23385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23386. return
  23387. }
  23388. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23389. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  23390. if result3101.Infcode == "0" {
  23391. if len(result3101.Output.Result) > 0 {
  23392. var errMsgs []string
  23393. for _, item := range result3101.Output.Result {
  23394. errMsgs = append(errMsgs, item.VolaCont)
  23395. }
  23396. c.ServeSuccessJSON(map[string]interface{}{
  23397. "failed_code": -10,
  23398. "msg": errMsgs,
  23399. })
  23400. return
  23401. }
  23402. }
  23403. bytesData, _ := json.Marshal(data)
  23404. var req *http.Request
  23405. if miConfig.MdtrtareaAdmvs == "320921" {
  23406. data["diag_code"] = sickConfig.CountryCode
  23407. fmt.Println(data)
  23408. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23409. } else {
  23410. data["diag_code"] = sickConfig.CountryCode
  23411. fmt.Println(data)
  23412. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23413. }
  23414. resp, _ := client.Do(req)
  23415. defer resp.Body.Close()
  23416. body, ioErr := ioutil.ReadAll(resp.Body)
  23417. if ioErr != nil {
  23418. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23420. return
  23421. }
  23422. var respJSON map[string]interface{}
  23423. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23424. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23426. return
  23427. }
  23428. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23429. userJSONBytes, _ := json.Marshal(respJSON)
  23430. fmt.Println("log")
  23431. fmt.Println(string(userJSONBytes))
  23432. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  23433. utils.ErrorLog("解析失败:%v", err)
  23434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23435. return
  23436. }
  23437. res.InfRefmsgid = resFour10265.InfRefmsgid
  23438. res.Output = resFour10265.Output
  23439. res.ErrMsg = resFour10265.ErrMsg
  23440. res.Cainfo = resFour10265.Cainfo
  23441. res.WarnMsg = resFour10265.WarnMsg
  23442. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  23443. res.Infcode = infocode
  23444. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23445. var pagesize int = 2
  23446. var start int = 1
  23447. var stop int
  23448. var pagecount int
  23449. var curpage int
  23450. var isSuccess bool = true
  23451. data["doctor_id"] = doctor_info.DoctorNumber
  23452. //总页数,向上取整,注意除之前要先转换类型为float64
  23453. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  23454. for curpage = 1; curpage <= pagecount; curpage++ {
  23455. if curpage == 1 {
  23456. start = 1
  23457. } else {
  23458. start = (curpage-1)*pagesize + 1
  23459. }
  23460. stop = curpage * pagesize
  23461. if stop > len(prescriptions) {
  23462. stop = len(prescriptions)
  23463. }
  23464. //var requestLog string
  23465. data["pre"] = prescriptions[start-1 : stop]
  23466. fmt.Println(data["pre"])
  23467. bytesData, _ := json.Marshal(data)
  23468. var req *http.Request
  23469. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  23470. resp, _ := client.Do(req)
  23471. defer resp.Body.Close()
  23472. body, ioErr := ioutil.ReadAll(resp.Body)
  23473. if ioErr != nil {
  23474. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23476. return
  23477. }
  23478. var respJSON map[string]interface{}
  23479. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23480. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23482. return
  23483. }
  23484. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23485. userJSONBytes, _ := json.Marshal(respJSON)
  23486. fmt.Println("log")
  23487. fmt.Println(string(userJSONBytes))
  23488. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  23489. utils.ErrorLog("解析失败:%v", err)
  23490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23491. return
  23492. }
  23493. res.InfRefmsgid = resFour10265.InfRefmsgid
  23494. res.Output = resFour10265.Output
  23495. res.ErrMsg = resFour10265.ErrMsg
  23496. res.Cainfo = resFour10265.Cainfo
  23497. res.WarnMsg = resFour10265.WarnMsg
  23498. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  23499. res.Infcode = infocode
  23500. if infocode == 0 {
  23501. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  23502. } else {
  23503. isSuccess = false
  23504. errlog := &models.HisOrderError{
  23505. UserOrgId: adminUser.CurrentOrgId,
  23506. Ctime: time.Now().Unix(),
  23507. Mtime: time.Now().Unix(),
  23508. Number: chrg_bchno,
  23509. ErrMsg: "",
  23510. Status: 1,
  23511. PatientId: id,
  23512. RecordTime: recordDateTime,
  23513. Stage: 4,
  23514. }
  23515. service.CreateErrMsgLog(errlog)
  23516. c.ServeSuccessJSON(map[string]interface{}{
  23517. "failed_code": -10,
  23518. "msg": res.ErrMsg,
  23519. })
  23520. return
  23521. }
  23522. }
  23523. if isSuccess {
  23524. res.Infcode = 0
  23525. }
  23526. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23527. 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)
  23528. var dat map[string]interface{}
  23529. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23530. fmt.Println(dat)
  23531. } else {
  23532. fmt.Println(err)
  23533. }
  23534. saveLog(result, request_log, "2204", "上传费用明细")
  23535. userJSONBytes, _ := json.Marshal(dat)
  23536. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  23537. utils.ErrorLog("解析失败:%v", err)
  23538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23539. return
  23540. }
  23541. res.InfRefmsgid = resFour10265.InfRefmsgid
  23542. res.Output = resFour10265.Output
  23543. res.ErrMsg = resFour10265.ErrMsg
  23544. res.Cainfo = resFour10265.Cainfo
  23545. res.WarnMsg = resFour10265.WarnMsg
  23546. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  23547. res.Infcode = infocode
  23548. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23549. bytesData, _ := json.Marshal(data)
  23550. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  23551. resp, _ := client.Do(req)
  23552. defer resp.Body.Close()
  23553. body, ioErr := ioutil.ReadAll(resp.Body)
  23554. if ioErr != nil {
  23555. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23557. return
  23558. }
  23559. var respJSON map[string]interface{}
  23560. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23561. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23563. return
  23564. }
  23565. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23566. userJSONBytes, _ := json.Marshal(respJSON)
  23567. fmt.Println("log")
  23568. fmt.Println(string(userJSONBytes))
  23569. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23570. utils.ErrorLog("解析失败:%v", err)
  23571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23572. return
  23573. }
  23574. } else {
  23575. if miConfig.Code == "H15049901371" {
  23576. 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)
  23577. var dat map[string]interface{}
  23578. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23579. fmt.Println(dat)
  23580. } else {
  23581. fmt.Println(err)
  23582. }
  23583. saveLog(result, request_log, "2204", "上传费用明细")
  23584. userJSONBytes, _ := json.Marshal(dat)
  23585. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  23586. utils.ErrorLog("解析失败:%v", err)
  23587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23588. return
  23589. }
  23590. res.InfRefmsgid = resFour10265.InfRefmsgid
  23591. res.Output = resFour10265.Output
  23592. res.ErrMsg = resFour10265.ErrMsg
  23593. res.Cainfo = resFour10265.Cainfo
  23594. res.WarnMsg = resFour10265.WarnMsg
  23595. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  23596. res.Infcode = infocode
  23597. } else {
  23598. 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)
  23599. var dat map[string]interface{}
  23600. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23601. fmt.Println(dat)
  23602. } else {
  23603. fmt.Println(err)
  23604. }
  23605. saveLog(result, request_log, "2204", "上传费用明细")
  23606. userJSONBytes, _ := json.Marshal(dat)
  23607. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23608. utils.ErrorLog("解析失败:%v", err)
  23609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23610. return
  23611. }
  23612. }
  23613. }
  23614. if res.Infcode == 0 {
  23615. order := &models.HisOrder{
  23616. UserOrgId: adminUser.CurrentOrgId,
  23617. HisPatientId: his.ID,
  23618. PatientId: his.PatientId,
  23619. SettleAccountsDate: recordDateTime,
  23620. MdtrtId: his.Number,
  23621. PsnNo: his.PsnNo,
  23622. MedType: strconv.FormatInt(reg_type, 10),
  23623. Ctime: time.Now().Unix(),
  23624. Mtime: time.Now().Unix(),
  23625. Status: 1,
  23626. Number: chrg_bchno,
  23627. Infcode: res.Infcode,
  23628. WarnMsg: res.WarnMsg,
  23629. Cainfo: res.Cainfo,
  23630. ErrMsg: res.ErrMsg,
  23631. RespondTime: res.RefmsgTime,
  23632. InfRefmsgid: res.InfRefmsgid,
  23633. OrderStatus: 1,
  23634. PayWay: pay_way,
  23635. PayWays: pay_ways,
  23636. OthDesc: oth_desc,
  23637. PayPrice: pay_price,
  23638. PayCardNo: pay_card_no,
  23639. DiscountPrice: discount_price,
  23640. PreferentialPrice: preferential_price,
  23641. RealityPrice: reality_price,
  23642. FoundPrice: found_price,
  23643. MedicalInsurancePrice: medical_insurance_price,
  23644. PrivatePrice: private_price,
  23645. IsMedicineInsurance: 1,
  23646. SettleType: settle_accounts_type,
  23647. SettleStartTime: start_time,
  23648. SettleEndTime: end_time,
  23649. Creator: roles.AdminUserId,
  23650. Modify: roles.AdminUserId,
  23651. FaPiaoNumber: fapiao_number,
  23652. FaPiaoCode: fapiao_code,
  23653. PType: 2,
  23654. Diagnosis: diagnosis_id,
  23655. CashPay: cash_pay,
  23656. WechatPay: wechat_pay,
  23657. AliPay: ali_pay,
  23658. JifenPay: jifen_pay,
  23659. BandCardPay: band_card_pay,
  23660. }
  23661. err = service.CreateOrder(order)
  23662. if err != nil {
  23663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  23664. return
  23665. }
  23666. for _, item := range res.Output.Result {
  23667. temp := strings.Split(item.FeedetlSn, "-")
  23668. var advice_id int64 = 0
  23669. var project_id int64 = 0
  23670. var types int64 = 0
  23671. id, _ := strconv.ParseInt(temp[2], 10, 64)
  23672. types, _ = strconv.ParseInt(temp[1], 10, 64)
  23673. if temp[1] == "1" {
  23674. advice_id = id
  23675. project_id = 0
  23676. } else if temp[1] == "2" {
  23677. advice_id = 0
  23678. project_id = id
  23679. }
  23680. if item.MedChrgitmType == "9" {
  23681. item.MedChrgitmType = "09"
  23682. }
  23683. info := &models.HisOrderInfo{
  23684. OrderNumber: order.Number,
  23685. FeedetlSn: item.FeedetlSn,
  23686. UploadDate: time.Now().Unix(),
  23687. AdviceId: advice_id,
  23688. DetItemFeeSumamt: item.DetItemFeeSumamt,
  23689. Cnt: item.Cnt,
  23690. Pric: float64(item.Pric),
  23691. PatientId: his.PatientId,
  23692. PricUplmtAmt: item.PricUplmtAmt,
  23693. SelfpayProp: item.SelfpayProp,
  23694. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  23695. OverlmtAmt: item.OverlmtAmt,
  23696. PreselfpayAmt: item.PreselfpayAmt,
  23697. BasMednFlag: item.BasMednFlag,
  23698. MedChrgitmType: item.MedChrgitmType,
  23699. HiNegoDrugFlag: item.HiNegoDrugFlag,
  23700. Status: 1,
  23701. Memo: item.Memo,
  23702. Mtime: time.Now().Unix(),
  23703. InscpScpAmt: item.InscpScpAmt,
  23704. DrtReimFlag: item.DrtReimFlag,
  23705. Ctime: time.Now().Unix(),
  23706. ListSpItemFlag: item.ListSpItemFlag,
  23707. ChldMedcFlag: item.ChldMedcFlag,
  23708. LmtUsedFlag: item.LmtUsedFlag,
  23709. ChrgitmLv: item.ChrgitmLv,
  23710. UserOrgId: adminUser.CurrentOrgId,
  23711. HisPatientId: his.ID,
  23712. OrderId: order.ID,
  23713. ProjectId: project_id,
  23714. Type: types,
  23715. }
  23716. service.CreateOrderInfo(info)
  23717. }
  23718. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  23719. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  23720. var total float64
  23721. for _, item := range prescriptions {
  23722. if item.Type == 1 { //药品
  23723. for _, subItem := range item.HisDoctorAdviceInfo {
  23724. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  23725. total_one := price * subItem.PrescribingNumber
  23726. total = total + total_one
  23727. }
  23728. }
  23729. if item.Type == 2 { //项目
  23730. for _, subItem := range item.HisPrescriptionProject {
  23731. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  23732. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  23733. total_one := price * cnt
  23734. total = total + total_one
  23735. }
  23736. }
  23737. }
  23738. allTotal := fmt.Sprintf("%.2f", total)
  23739. //if adminUser.CurrentOrgId == 9919 {
  23740. //
  23741. // allTotal = fmt.Sprintf("%.2f", total)
  23742. //
  23743. //} else {
  23744. //
  23745. // allTotal = fmt.Sprintf("%.2f", total)
  23746. //
  23747. //}
  23748. if res.Infcode == 0 {
  23749. var rf []*ResultFive
  23750. json.Unmarshal([]byte(his.Iinfo), &rf)
  23751. chrg_bchno := chrg_bchno
  23752. cert_no := his.Certno
  23753. var insutypes []string
  23754. var insutype string
  23755. var is390 int = 0
  23756. var is310 int = 0
  23757. for _, item := range rf {
  23758. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23759. insutypes = append(insutypes, item.Insutype)
  23760. }
  23761. }
  23762. if len(insutypes) == 1 {
  23763. insutype = insutypes[0]
  23764. } else {
  23765. for _, i := range insutypes {
  23766. if i == "390" {
  23767. is390 = 1
  23768. }
  23769. if i == "310" {
  23770. is310 = 1
  23771. }
  23772. }
  23773. }
  23774. if is390 == 1 {
  23775. insutype = "390"
  23776. }
  23777. if is310 == 1 {
  23778. insutype = "310"
  23779. }
  23780. if len(insutypes) == 0 {
  23781. insutype = "310"
  23782. }
  23783. if len(insutypes) == 2 {
  23784. insutype = strconv.FormatInt(his.SocialType, 10)
  23785. }
  23786. insutype = strconv.FormatInt(his.SocialType, 10)
  23787. //insutype = "390"
  23788. if his.IdCardType == 1 {
  23789. // cert_no = his.MedicalInsuranceNumber
  23790. cert_no = his.Certno
  23791. } else {
  23792. cert_no = his.Certno
  23793. }
  23794. var res ResultSeven
  23795. var resSeven10265 ResultSeven10265
  23796. var gzresSeven10265Two GZResultSeven10265Two
  23797. var src_resquest string
  23798. var result2 string
  23799. if miConfig.MdtrtareaAdmvs == "421300" {
  23800. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23801. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23802. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23803. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23804. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23805. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23806. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  23807. resp, requestErr := http.Get(api)
  23808. if requestErr != nil {
  23809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23810. return
  23811. }
  23812. body, ioErr := ioutil.ReadAll(resp.Body)
  23813. if ioErr != nil {
  23814. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23816. return
  23817. }
  23818. var respJSON map[string]interface{}
  23819. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23822. return
  23823. }
  23824. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23825. result, _ := json.Marshal(respJSON)
  23826. if miConfig.Code == "H15049901371" {
  23827. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  23828. utils.ErrorLog("解析失败:%v", err)
  23829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23830. return
  23831. }
  23832. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23833. res.Output = resSeven10265.Output
  23834. res.ErrMsg = resSeven10265.ErrMsg
  23835. res.Cainfo = resSeven10265.Cainfo
  23836. res.WarnMsg = resSeven10265.WarnMsg
  23837. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23838. res.Infcode = infocode
  23839. } else {
  23840. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23841. utils.ErrorLog("解析失败:%v", err)
  23842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23843. return
  23844. }
  23845. }
  23846. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23847. if reg_type == 11 && his.Insutype == "390" {
  23848. reg_type = 110104
  23849. }
  23850. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23851. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23852. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23853. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23854. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23855. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23856. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  23857. resp, requestErr := http.Get(api)
  23858. if requestErr != nil {
  23859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23860. return
  23861. }
  23862. body, ioErr := ioutil.ReadAll(resp.Body)
  23863. if ioErr != nil {
  23864. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23866. return
  23867. }
  23868. var respJSON map[string]interface{}
  23869. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23870. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23872. return
  23873. }
  23874. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23875. result, _ := json.Marshal(respJSON)
  23876. if miConfig.Code == "H15049901371" {
  23877. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  23878. utils.ErrorLog("解析失败:%v", err)
  23879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23880. return
  23881. }
  23882. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23883. res.Output = resSeven10265.Output
  23884. res.ErrMsg = resSeven10265.ErrMsg
  23885. res.Cainfo = resSeven10265.Cainfo
  23886. res.WarnMsg = resSeven10265.WarnMsg
  23887. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23888. res.Infcode = infocode
  23889. } else {
  23890. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23891. utils.ErrorLog("解析失败:%v", err)
  23892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23893. return
  23894. }
  23895. }
  23896. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23897. if reg_type == 11 && his.Insutype == "390" {
  23898. reg_type = 110104
  23899. }
  23900. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23901. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23902. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23903. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23904. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23905. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23906. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  23907. resp, requestErr := http.Get(api)
  23908. if requestErr != nil {
  23909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23910. return
  23911. }
  23912. body, ioErr := ioutil.ReadAll(resp.Body)
  23913. if ioErr != nil {
  23914. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23916. return
  23917. }
  23918. var respJSON map[string]interface{}
  23919. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23920. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23922. return
  23923. }
  23924. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23925. result, _ := json.Marshal(respJSON)
  23926. if miConfig.Code == "H15049901371" {
  23927. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  23928. utils.ErrorLog("解析失败:%v", err)
  23929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23930. return
  23931. }
  23932. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23933. res.Output = resSeven10265.Output
  23934. res.ErrMsg = resSeven10265.ErrMsg
  23935. res.Cainfo = resSeven10265.Cainfo
  23936. res.WarnMsg = resSeven10265.WarnMsg
  23937. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23938. res.Infcode = infocode
  23939. } else {
  23940. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23941. utils.ErrorLog("解析失败:%v", err)
  23942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23943. return
  23944. }
  23945. }
  23946. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23947. if reg_type == 11 && his.Insutype == "390" {
  23948. reg_type = 110104
  23949. }
  23950. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23951. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23952. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23953. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23954. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23955. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23956. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  23957. resp, requestErr := http.Get(api)
  23958. if requestErr != nil {
  23959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23960. return
  23961. }
  23962. body, ioErr := ioutil.ReadAll(resp.Body)
  23963. if ioErr != nil {
  23964. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23966. return
  23967. }
  23968. var respJSON map[string]interface{}
  23969. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23970. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23972. return
  23973. }
  23974. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23975. result, _ := json.Marshal(respJSON)
  23976. if miConfig.Code == "H15049901371" {
  23977. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  23978. utils.ErrorLog("解析失败:%v", err)
  23979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23980. return
  23981. }
  23982. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23983. res.Output = resSeven10265.Output
  23984. res.ErrMsg = resSeven10265.ErrMsg
  23985. res.Cainfo = resSeven10265.Cainfo
  23986. res.WarnMsg = resSeven10265.WarnMsg
  23987. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23988. res.Infcode = infocode
  23989. } else {
  23990. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23991. utils.ErrorLog("解析失败:%v", err)
  23992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23993. return
  23994. }
  23995. }
  23996. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23997. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  23998. if result3101.Infcode == "0" {
  23999. if len(result3101.Output.Result) > 0 {
  24000. var errMsgs []string
  24001. for _, item := range result3101.Output.Result {
  24002. errMsgs = append(errMsgs, item.VolaCont)
  24003. }
  24004. c.ServeSuccessJSON(map[string]interface{}{
  24005. "failed_code": -10,
  24006. "msg": errMsgs,
  24007. })
  24008. return
  24009. } else {
  24010. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24011. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24012. bas := strings.Split(psn_info.CardInfo, "|")
  24013. if his.IdCardType == 1 {
  24014. cert_no = bas[2]
  24015. } else if his.IdCardType == 3 {
  24016. cert_no = his.Certno
  24017. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  24018. } else if his.IdCardType == 4 {
  24019. cert_no = his.Certno
  24020. psn_info.VerifyNumber = psn_info.VerifyNumber
  24021. }
  24022. var api string
  24023. if miConfig.MdtrtareaAdmvs == "320921" {
  24024. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24025. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24026. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24027. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24028. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24029. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24030. "&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
  24031. } else {
  24032. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24033. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24034. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24035. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24036. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24037. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24038. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  24039. }
  24040. resp, requestErr := http.Get(api)
  24041. if requestErr != nil {
  24042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24043. return
  24044. }
  24045. body, ioErr := ioutil.ReadAll(resp.Body)
  24046. if ioErr != nil {
  24047. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24049. return
  24050. }
  24051. var respJSON map[string]interface{}
  24052. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24053. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24055. return
  24056. }
  24057. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24058. result, _ := json.Marshal(respJSON)
  24059. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  24060. utils.ErrorLog("解析失败:%v", err)
  24061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24062. return
  24063. }
  24064. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24065. res.Output = resSeven10265.Output
  24066. res.ErrMsg = resSeven10265.ErrMsg
  24067. res.Cainfo = resSeven10265.Cainfo
  24068. res.WarnMsg = resSeven10265.WarnMsg
  24069. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24070. res.Infcode = infocode
  24071. }
  24072. }
  24073. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24074. psn_info, _ := service.GetPsnByPatientId(id)
  24075. var verify_number string
  24076. if psn_info.IdCardType == 4 {
  24077. verify_number = psn_info.VerifyNumber
  24078. } else if psn_info.IdCardType == 1 {
  24079. bas := strings.Split(psn_info.CardInfo, "|")
  24080. cardNumber := bas[2]
  24081. verify_number = cardNumber
  24082. } else {
  24083. psn_info.IdCardType = 2
  24084. verify_number = psn_info.Certno
  24085. }
  24086. var api string
  24087. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24088. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24089. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24090. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24091. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24092. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24093. "&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
  24094. resp, requestErr := http.Get(api)
  24095. if requestErr != nil {
  24096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24097. return
  24098. }
  24099. body, ioErr := ioutil.ReadAll(resp.Body)
  24100. if ioErr != nil {
  24101. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24103. return
  24104. }
  24105. var respJSON map[string]interface{}
  24106. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24107. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24109. return
  24110. }
  24111. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24112. result, _ := json.Marshal(respJSON)
  24113. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  24114. utils.ErrorLog("解析失败:%v", err)
  24115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24116. return
  24117. }
  24118. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24119. res.Output = resSeven10265.Output
  24120. res.ErrMsg = resSeven10265.ErrMsg
  24121. res.Cainfo = resSeven10265.Cainfo
  24122. res.WarnMsg = resSeven10265.WarnMsg
  24123. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24124. res.Infcode = infocode
  24125. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24126. var cert_no string
  24127. if his.IdCardType == 4 {
  24128. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24129. cert_no = psn_info.VerifyNumber
  24130. 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)
  24131. } else if his.IdCardType == 1 {
  24132. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24133. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  24134. 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)
  24135. }
  24136. //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)
  24137. var dat map[string]interface{}
  24138. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24139. fmt.Println(dat)
  24140. } else {
  24141. fmt.Println(err)
  24142. }
  24143. saveLog(result2, src_resquest, "2207", "结算")
  24144. userJSONBytes, _ := json.Marshal(dat)
  24145. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  24146. utils.ErrorLog("解析失败:%v", err)
  24147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24148. return
  24149. }
  24150. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24151. res.Output = resSeven10265.Output
  24152. res.ErrMsg = resSeven10265.ErrMsg
  24153. res.Cainfo = resSeven10265.Cainfo
  24154. res.WarnMsg = resSeven10265.WarnMsg
  24155. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24156. res.Infcode = infocode
  24157. } else if miConfig.MdtrtareaAdmvs == "450721" {
  24158. res2 := c.GetoleInfo()
  24159. if res2.Infcode == 0 {
  24160. var result string
  24161. var request_log string
  24162. var result_log string
  24163. if res2.Output.MdtrtCertType == "02" {
  24164. 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)
  24165. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  24166. } else if res2.Output.MdtrtCertType == "01" {
  24167. 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)
  24168. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  24169. } else {
  24170. 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)
  24171. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  24172. }
  24173. var dat map[string]interface{}
  24174. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24175. fmt.Println(dat)
  24176. } else {
  24177. fmt.Println(err)
  24178. }
  24179. userJSONBytes, _ := json.Marshal(dat)
  24180. var res5 ResultTwo
  24181. //var resTwo10265 ResultTwo10265
  24182. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  24183. utils.ErrorLog("解析失败:%v", err)
  24184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24185. return
  24186. }
  24187. if res5.Infcode == -1 {
  24188. c.ServeSuccessJSON(map[string]interface{}{
  24189. "failed_code": -10,
  24190. "msg": res5.ErrMsg,
  24191. })
  24192. return
  24193. }
  24194. var insutypes []string
  24195. var insutype string
  24196. var is390 int = 0
  24197. var is310 int = 0
  24198. for _, item := range res5.Output.Iinfo {
  24199. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24200. insutypes = append(insutypes, item.Insutype)
  24201. }
  24202. }
  24203. if len(insutypes) == 1 {
  24204. insutype = insutypes[0]
  24205. } else {
  24206. for _, i := range insutypes {
  24207. if i == "390" {
  24208. is390 = 1
  24209. }
  24210. if i == "310" {
  24211. is310 = 1
  24212. }
  24213. }
  24214. }
  24215. if is390 == 1 {
  24216. insutype = "390"
  24217. }
  24218. if is310 == 1 {
  24219. insutype = "310"
  24220. }
  24221. if len(insutypes) == 0 {
  24222. insutype = "310"
  24223. }
  24224. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  24225. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  24226. infoStr := string(Iinfos)
  24227. idetinfoStr := string(Idetinfos)
  24228. psn := &models.HisPsn{
  24229. PsnNo: res5.Output.Baseinfo.PsnNo,
  24230. PatientId: id,
  24231. Certno: res5.Output.Baseinfo.Certno,
  24232. Gend: res5.Output.Baseinfo.Gend,
  24233. Naty: res5.Output.Baseinfo.Naty,
  24234. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  24235. PsnName: res5.Output.Baseinfo.PsnName,
  24236. Idetinfo: idetinfoStr,
  24237. Insuinfo: infoStr,
  24238. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  24239. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  24240. VerifyNumber: res2.Output.EcToken,
  24241. }
  24242. if res2.Output.MdtrtCertType == "01" {
  24243. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24244. psn.VerifyNumber = res2.Output.EcToken
  24245. } else if res2.Output.MdtrtCertType == "02" {
  24246. psn.VerifyNumber = res2.Output.CardNo
  24247. } else {
  24248. psn.VerifyNumber = res2.Output.MdtrtCertNo
  24249. }
  24250. service.CreateHisPsn(psn)
  24251. if res2.Output.MdtrtCertType == "01" {
  24252. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24253. token := res2.Output.EcToken
  24254. 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)
  24255. } else if res2.Output.MdtrtCertType == "02" {
  24256. 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)
  24257. } else {
  24258. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 1, acct_used_flag, "", admin_user_id)
  24259. }
  24260. var dat2 map[string]interface{}
  24261. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  24262. fmt.Println(dat2)
  24263. } else {
  24264. fmt.Println(err)
  24265. }
  24266. userJSONBytes3, _ := json.Marshal(dat2)
  24267. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24268. utils.ErrorLog("解析失败:%v", err)
  24269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24270. return
  24271. }
  24272. saveLog(result2, src_resquest, "2207", "结算")
  24273. } else {
  24274. c.ServeSuccessJSON(map[string]interface{}{
  24275. "failed_code": -10,
  24276. "msg": res2.ErrMsg,
  24277. })
  24278. return
  24279. }
  24280. } else {
  24281. if miConfig.Code == "H15049901371" {
  24282. //赤峰地区国家医保医疗类别
  24283. //职工透析:医疗类别选特殊情况门诊990502
  24284. //居民定额血透门慢: 医疗类别选门诊慢病140104
  24285. var med_type string
  24286. if his.Insutype == "390" {
  24287. if reg_type == 14 {
  24288. med_type = "9933"
  24289. } else if reg_type == 11 {
  24290. med_type = "11"
  24291. }
  24292. } else if his.Insutype == "310" {
  24293. if reg_type == 14 {
  24294. med_type = "990502"
  24295. } else if reg_type == 11 {
  24296. med_type = "11"
  24297. }
  24298. }
  24299. 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)
  24300. } else {
  24301. if his.IdCardType == 4 {
  24302. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24303. var token string
  24304. token = psn_info.VerifyNumber
  24305. 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)
  24306. } else {
  24307. if his.IdCardType == 1 {
  24308. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24309. bas := strings.Split(psn_info.CardInfo, "|")
  24310. basNumber := bas[2]
  24311. cert_no = basNumber
  24312. }
  24313. 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)
  24314. }
  24315. }
  24316. //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)
  24317. var dat map[string]interface{}
  24318. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24319. fmt.Println(dat)
  24320. } else {
  24321. fmt.Println(err)
  24322. }
  24323. saveLog(result2, src_resquest, "2207", "结算")
  24324. userJSONBytes, _ := json.Marshal(dat)
  24325. if miConfig.Code == "H15049901371" {
  24326. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  24327. utils.ErrorLog("解析失败:%v", err)
  24328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24329. return
  24330. }
  24331. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24332. res.Output = resSeven10265.Output
  24333. res.ErrMsg = resSeven10265.ErrMsg
  24334. res.Cainfo = resSeven10265.Cainfo
  24335. res.WarnMsg = resSeven10265.WarnMsg
  24336. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24337. res.Infcode = infocode
  24338. } else {
  24339. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24340. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  24341. utils.ErrorLog("解析失败:%v", err)
  24342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24343. return
  24344. }
  24345. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  24346. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  24347. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  24348. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  24349. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  24350. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  24351. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  24352. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  24353. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  24354. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24355. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24356. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24357. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24358. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  24359. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  24360. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  24361. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  24362. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  24363. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  24364. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  24365. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  24366. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  24367. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  24368. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  24369. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  24370. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  24371. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  24372. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  24373. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  24374. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  24375. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  24376. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  24377. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  24378. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  24379. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  24380. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  24381. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  24382. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  24383. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24384. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  24385. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  24386. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  24387. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  24388. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  24389. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  24390. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  24391. res.ErrMsg = gzresSeven10265Two.ErrMsg
  24392. res.Cainfo = gzresSeven10265Two.Cainfo
  24393. res.WarnMsg = gzresSeven10265Two.WarnMsg
  24394. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  24395. //res.Infcode = infocode
  24396. } else {
  24397. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24398. utils.ErrorLog("解析失败:%v", err)
  24399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24400. return
  24401. }
  24402. }
  24403. }
  24404. }
  24405. if res.Infcode == -1 {
  24406. errlog := &models.HisOrderError{
  24407. UserOrgId: adminUser.CurrentOrgId,
  24408. Ctime: time.Now().Unix(),
  24409. Mtime: time.Now().Unix(),
  24410. Number: chrg_bchno,
  24411. ErrMsg: res.ErrMsg,
  24412. Status: 1,
  24413. PatientId: id,
  24414. RecordTime: recordDateTime,
  24415. Stage: 6,
  24416. }
  24417. service.CreateErrMsgLog(errlog)
  24418. c.ServeSuccessJSON(map[string]interface{}{
  24419. "failed_code": -10,
  24420. "msg": res.ErrMsg,
  24421. })
  24422. return
  24423. } else {
  24424. sickConfig, _ := service.FindSickById(his.SickType)
  24425. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  24426. order.OrderStatus = 2
  24427. order.Status = 1
  24428. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  24429. order.SetlId = res.Output.Setlinfo.SetlID
  24430. order.PsnNo = res.Output.Setlinfo.PsnNo
  24431. order.PsnName = res.Output.Setlinfo.PsnName
  24432. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  24433. order.Certno = res.Output.Setlinfo.Certno
  24434. order.Gend = res.Output.Setlinfo.Gend
  24435. order.Naty = res.Output.Setlinfo.Naty
  24436. order.Age = res.Output.Setlinfo.Age
  24437. order.Insutype = res.Output.Setlinfo.Insutype
  24438. order.PsnType = res.Output.Setlinfo.PsnType
  24439. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  24440. order.SetlTime = res.Output.Setlinfo.SetlTime
  24441. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  24442. if res.Output.Setlinfo.MedType == "140101" {
  24443. order.MedType = "14"
  24444. } else {
  24445. if res.Output.Setlinfo.MedType == "110104" {
  24446. order.MedType = "11"
  24447. } else {
  24448. order.MedType = res.Output.Setlinfo.MedType
  24449. }
  24450. }
  24451. if reg_type == 1112 {
  24452. order.MedType = "1112"
  24453. }
  24454. if reg_type == 1111 {
  24455. order.MedType = "1111"
  24456. }
  24457. order.ClrType = res.Output.Setlinfo.ClrType
  24458. if adminUser.CurrentOrgId == 10480 {
  24459. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  24460. order.ClrType = "11"
  24461. } else {
  24462. order.ClrType = "9903"
  24463. }
  24464. }
  24465. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  24466. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  24467. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  24468. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  24469. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  24470. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  24471. order.HifpPay = res.Output.Setlinfo.HifpPay
  24472. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  24473. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  24474. order.HifesPay = res.Output.Setlinfo.HifesPay
  24475. order.HifobPay = res.Output.Setlinfo.HifobPay
  24476. order.MafPay = res.Output.Setlinfo.MafPay
  24477. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  24478. order.OthPay = res.Output.Setlinfo.OthPay
  24479. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  24480. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  24481. order.AcctPay = res.Output.Setlinfo.AcctPay
  24482. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  24483. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  24484. order.Balc = res.Output.Setlinfo.Balc
  24485. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  24486. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  24487. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  24488. //order.ClrType = res.Output.Setlinfo.ClrType
  24489. order.ClrWay = res.Output.Setlinfo.ClrWay
  24490. order.Creator = order.Creator
  24491. order.Modify = roles.AdminUserId
  24492. order.RequestLog = src_resquest
  24493. order.FaPiaoNumber = fapiao_number
  24494. order.FaPiaoCode = fapiao_code
  24495. order.SickName = sickConfig.ClassName
  24496. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  24497. //detailStr := string(setlDetail)
  24498. //order.SetlDetail = detailStr
  24499. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  24500. err = service.UpDateOrder(order)
  24501. if err == nil {
  24502. //判断是否使用了押金
  24503. if dec_way == "true" {
  24504. tmpstring := strconv.FormatInt(order.ID, 10)
  24505. order.Decimal = decimal
  24506. service.UpDateOrder(order)
  24507. //扣押金
  24508. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  24509. if errmsg != nil {
  24510. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  24511. return
  24512. }
  24513. }
  24514. c.ServeSuccessJSON(map[string]interface{}{
  24515. "msg": "结算成功",
  24516. })
  24517. } else {
  24518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  24519. return
  24520. }
  24521. }
  24522. } else {
  24523. adminUser := c.GetAdminUserInfo()
  24524. errlog := &models.HisOrderError{
  24525. UserOrgId: adminUser.CurrentOrgId,
  24526. Ctime: time.Now().Unix(),
  24527. Mtime: time.Now().Unix(),
  24528. ErrMsg: res.ErrMsg,
  24529. Status: 1,
  24530. PatientId: id,
  24531. RecordTime: recordDateTime,
  24532. Stage: 4,
  24533. }
  24534. service.CreateErrMsgLog(errlog)
  24535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  24536. return
  24537. }
  24538. } else {
  24539. adminUser := c.GetAdminUserInfo()
  24540. errlog := &models.HisOrderError{
  24541. UserOrgId: adminUser.CurrentOrgId,
  24542. Ctime: time.Now().Unix(),
  24543. Mtime: time.Now().Unix(),
  24544. ErrMsg: res.ErrMsg,
  24545. Status: 1,
  24546. PatientId: id,
  24547. RecordTime: recordDateTime,
  24548. Stage: 4,
  24549. }
  24550. service.CreateErrMsgLog(errlog)
  24551. c.ServeSuccessJSON(map[string]interface{}{
  24552. "failed_code": -10,
  24553. "msg": res.ErrMsg,
  24554. })
  24555. return
  24556. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  24557. //return
  24558. }
  24559. }
  24560. }
  24561. } else if tempOrder.ID > 0 {
  24562. if tempOrder.IsPre == 1 {
  24563. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  24564. var rf []*ResultFive
  24565. json.Unmarshal([]byte(his.Iinfo), &rf)
  24566. chrg_bchno := tempOrder.Number
  24567. cert_no := his.Certno
  24568. var insutypes []string
  24569. var insutype string
  24570. var is390 int = 0
  24571. var is310 int = 0
  24572. for _, item := range rf {
  24573. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24574. insutypes = append(insutypes, item.Insutype)
  24575. }
  24576. }
  24577. if len(insutypes) == 1 {
  24578. insutype = insutypes[0]
  24579. } else {
  24580. for _, i := range insutypes {
  24581. if i == "390" {
  24582. is390 = 1
  24583. }
  24584. if i == "310" {
  24585. is310 = 1
  24586. }
  24587. }
  24588. }
  24589. if is390 == 1 {
  24590. insutype = "390"
  24591. }
  24592. if is310 == 1 {
  24593. insutype = "310"
  24594. }
  24595. if len(insutypes) == 0 {
  24596. insutype = "310"
  24597. }
  24598. if len(insutypes) == 2 {
  24599. insutype = strconv.FormatInt(his.SocialType, 10)
  24600. }
  24601. //insutype = "390"
  24602. if his.IdCardType == 1 {
  24603. // cert_no = his.MedicalInsuranceNumber
  24604. cert_no = his.Certno
  24605. } else {
  24606. cert_no = his.Certno
  24607. }
  24608. var res ResultSeven
  24609. var ahres ResultSevenAH
  24610. var resSeven10265 ResultSeven10265
  24611. var gzresSeven10265Two GZResultSeven10265Two
  24612. var src_resquest string
  24613. var result2 string
  24614. if miConfig.MdtrtareaAdmvs == "450721" {
  24615. res2 := c.GetoleInfo()
  24616. if res2.Infcode == 0 {
  24617. var result string
  24618. var request_log string
  24619. var result_log string
  24620. if res2.Output.MdtrtCertType == "02" {
  24621. 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)
  24622. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  24623. } else if res2.Output.MdtrtCertType == "01" {
  24624. 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)
  24625. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  24626. } else {
  24627. 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)
  24628. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  24629. }
  24630. var dat map[string]interface{}
  24631. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24632. fmt.Println(dat)
  24633. } else {
  24634. fmt.Println(err)
  24635. }
  24636. userJSONBytes, _ := json.Marshal(dat)
  24637. var res5 ResultTwo
  24638. //var resTwo10265 ResultTwo10265
  24639. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  24640. utils.ErrorLog("解析失败:%v", err)
  24641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24642. return
  24643. }
  24644. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  24645. if res5.Infcode == -1 {
  24646. c.ServeSuccessJSON(map[string]interface{}{
  24647. "failed_code": -10,
  24648. "msg": res5.ErrMsg,
  24649. })
  24650. return
  24651. }
  24652. var insutypes []string
  24653. var insutype string
  24654. var is390 int = 0
  24655. var is310 int = 0
  24656. for _, item := range res5.Output.Iinfo {
  24657. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24658. insutypes = append(insutypes, item.Insutype)
  24659. }
  24660. }
  24661. if len(insutypes) == 1 {
  24662. insutype = insutypes[0]
  24663. } else {
  24664. for _, i := range insutypes {
  24665. if i == "390" {
  24666. is390 = 1
  24667. }
  24668. if i == "310" {
  24669. is310 = 1
  24670. }
  24671. }
  24672. }
  24673. if is390 == 1 {
  24674. insutype = "390"
  24675. }
  24676. if is310 == 1 {
  24677. insutype = "310"
  24678. }
  24679. if len(insutypes) == 0 {
  24680. insutype = "310"
  24681. }
  24682. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  24683. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  24684. infoStr := string(Iinfos)
  24685. idetinfoStr := string(Idetinfos)
  24686. psn := &models.HisPsn{
  24687. PsnNo: res5.Output.Baseinfo.PsnNo,
  24688. PatientId: id,
  24689. Certno: res5.Output.Baseinfo.Certno,
  24690. Gend: res5.Output.Baseinfo.Gend,
  24691. Naty: res5.Output.Baseinfo.Naty,
  24692. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  24693. PsnName: res5.Output.Baseinfo.PsnName,
  24694. Idetinfo: idetinfoStr,
  24695. Insuinfo: infoStr,
  24696. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  24697. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  24698. VerifyNumber: res2.Output.EcToken,
  24699. }
  24700. service.CreateHisPsn(psn)
  24701. if res2.Output.MdtrtCertType == "01" {
  24702. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24703. token := res2.Output.EcToken
  24704. 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)
  24705. } else if res2.Output.MdtrtCertType == "02" {
  24706. 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)
  24707. } else {
  24708. 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)
  24709. }
  24710. var dat2 map[string]interface{}
  24711. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  24712. fmt.Println(dat2)
  24713. } else {
  24714. fmt.Println(err)
  24715. }
  24716. userJSONBytes3, _ := json.Marshal(dat2)
  24717. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24718. utils.ErrorLog("解析失败:%v", err)
  24719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24720. return
  24721. }
  24722. saveLog(result2, src_resquest, "2207", "结算")
  24723. } else {
  24724. c.ServeSuccessJSON(map[string]interface{}{
  24725. "failed_code": -10,
  24726. "msg": res2.ErrMsg,
  24727. })
  24728. return
  24729. }
  24730. } else if miConfig.MdtrtareaAdmvs == "421300" {
  24731. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24732. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24733. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24734. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24735. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24736. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24737. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  24738. resp, requestErr := http.Get(api)
  24739. if requestErr != nil {
  24740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24741. return
  24742. }
  24743. body, ioErr := ioutil.ReadAll(resp.Body)
  24744. if ioErr != nil {
  24745. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24747. return
  24748. }
  24749. var respJSON map[string]interface{}
  24750. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24751. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24753. return
  24754. }
  24755. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24756. result, _ := json.Marshal(respJSON)
  24757. fmt.Println("log")
  24758. fmt.Println(string(result))
  24759. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24760. utils.ErrorLog("解析失败:%v", err)
  24761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24762. return
  24763. }
  24764. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24765. if reg_type == 11 && his.Insutype == "390" {
  24766. reg_type = 110104
  24767. }
  24768. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24769. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24770. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24771. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24772. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24773. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24774. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  24775. resp, requestErr := http.Get(api)
  24776. if requestErr != nil {
  24777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24778. return
  24779. }
  24780. body, ioErr := ioutil.ReadAll(resp.Body)
  24781. if ioErr != nil {
  24782. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24784. return
  24785. }
  24786. var respJSON map[string]interface{}
  24787. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24788. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24790. return
  24791. }
  24792. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24793. result, _ := json.Marshal(respJSON)
  24794. fmt.Println("log")
  24795. fmt.Println(string(result))
  24796. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24797. utils.ErrorLog("解析失败:%v", err)
  24798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24799. return
  24800. }
  24801. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24802. if reg_type == 11 && his.Insutype == "390" {
  24803. reg_type = 110104
  24804. }
  24805. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24806. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24807. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24808. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24809. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24810. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24811. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  24812. resp, requestErr := http.Get(api)
  24813. if requestErr != nil {
  24814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24815. return
  24816. }
  24817. body, ioErr := ioutil.ReadAll(resp.Body)
  24818. if ioErr != nil {
  24819. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24821. return
  24822. }
  24823. var respJSON map[string]interface{}
  24824. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24825. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24827. return
  24828. }
  24829. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24830. result, _ := json.Marshal(respJSON)
  24831. fmt.Println("log")
  24832. fmt.Println(string(result))
  24833. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24834. utils.ErrorLog("解析失败:%v", err)
  24835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24836. return
  24837. }
  24838. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24839. if reg_type == 11 && his.Insutype == "390" {
  24840. reg_type = 110104
  24841. }
  24842. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24843. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24844. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24845. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24846. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24847. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24848. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  24849. resp, requestErr := http.Get(api)
  24850. if requestErr != nil {
  24851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24852. return
  24853. }
  24854. body, ioErr := ioutil.ReadAll(resp.Body)
  24855. if ioErr != nil {
  24856. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24858. return
  24859. }
  24860. var respJSON map[string]interface{}
  24861. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24862. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24864. return
  24865. }
  24866. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24867. result, _ := json.Marshal(respJSON)
  24868. fmt.Println("log")
  24869. fmt.Println(string(result))
  24870. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24871. utils.ErrorLog("解析失败:%v", err)
  24872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24873. return
  24874. }
  24875. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24876. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  24877. if result3101.Infcode == "0" {
  24878. if len(result3101.Output.Result) > 0 {
  24879. var errMsgs []string
  24880. for _, item := range result3101.Output.Result {
  24881. errMsgs = append(errMsgs, item.VolaCont)
  24882. }
  24883. c.ServeSuccessJSON(map[string]interface{}{
  24884. "failed_code": -10,
  24885. "msg": errMsgs,
  24886. })
  24887. return
  24888. } else {
  24889. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24890. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24891. bas := strings.Split(psn_info.CardInfo, "|")
  24892. if his.IdCardType == 1 {
  24893. cert_no = bas[2]
  24894. } else if his.IdCardType == 3 {
  24895. cert_no = his.Certno
  24896. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  24897. } else if his.IdCardType == 4 {
  24898. cert_no = his.Certno
  24899. psn_info.VerifyNumber = psn_info.VerifyNumber
  24900. }
  24901. //江苏地区国家医保医疗类别
  24902. //职工透析:医疗类别选特殊情况门诊9933
  24903. //居民血透门慢: 医疗类别选门诊慢病1402
  24904. //var med_type string
  24905. //if his.Insutype == "310" {
  24906. // if reg_type == 14 {
  24907. // med_type = "9933"
  24908. // } else if reg_type == 11 {
  24909. // med_type = "11"
  24910. //
  24911. // }
  24912. //} else if his.Insutype == "390" {
  24913. // if reg_type == 14 {
  24914. // med_type = "1402"
  24915. // } else if reg_type == 11 {
  24916. // med_type = "11"
  24917. // }
  24918. //}
  24919. var api string
  24920. if miConfig.MdtrtareaAdmvs == "320921" {
  24921. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24922. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24923. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24924. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24925. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24926. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24927. "&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
  24928. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24929. } else {
  24930. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24931. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24932. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24933. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24934. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24935. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24936. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24937. "&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
  24938. }
  24939. resp, requestErr := http.Get(api)
  24940. if requestErr != nil {
  24941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24942. return
  24943. }
  24944. body, ioErr := ioutil.ReadAll(resp.Body)
  24945. if ioErr != nil {
  24946. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24948. return
  24949. }
  24950. var respJSON map[string]interface{}
  24951. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24954. return
  24955. }
  24956. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24957. result, _ := json.Marshal(respJSON)
  24958. fmt.Println("log")
  24959. fmt.Println(string(result))
  24960. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  24961. utils.ErrorLog("解析失败:%v", err)
  24962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24963. return
  24964. }
  24965. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24966. res.Output = resSeven10265.Output
  24967. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24968. res.ErrMsg = resSeven10265.ErrMsg
  24969. res.Cainfo = resSeven10265.Cainfo
  24970. res.WarnMsg = resSeven10265.WarnMsg
  24971. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24972. res.Infcode = infocode
  24973. }
  24974. }
  24975. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24976. psn_info, _ := service.GetPsnByPatientId(id)
  24977. var verify_number string
  24978. if psn_info.IdCardType == 4 {
  24979. verify_number = psn_info.VerifyNumber
  24980. } else if psn_info.IdCardType == 1 {
  24981. bas := strings.Split(psn_info.CardInfo, "|")
  24982. cardNumber := bas[2]
  24983. verify_number = cardNumber
  24984. } else {
  24985. verify_number = psn_info.Certno
  24986. psn_info.IdCardType = 2
  24987. }
  24988. var api string
  24989. new_chrg_bchno := chrg_bchno
  24990. if adminUser.CurrentOrgId == 10265 {
  24991. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  24992. new_chrg_bchno = "0000"
  24993. }
  24994. }
  24995. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24996. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  24997. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24998. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24999. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  25000. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25001. "&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
  25002. resp, requestErr := http.Get(api)
  25003. if requestErr != nil {
  25004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25005. return
  25006. }
  25007. body, ioErr := ioutil.ReadAll(resp.Body)
  25008. if ioErr != nil {
  25009. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25011. return
  25012. }
  25013. var respJSON map[string]interface{}
  25014. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25017. return
  25018. }
  25019. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25020. result, _ := json.Marshal(respJSON)
  25021. fmt.Println("log")
  25022. fmt.Println(string(result))
  25023. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  25024. utils.ErrorLog("解析失败:%v", err)
  25025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25026. return
  25027. }
  25028. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25029. res.Output = resSeven10265.Output
  25030. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25031. res.ErrMsg = resSeven10265.ErrMsg
  25032. res.Cainfo = resSeven10265.Cainfo
  25033. res.WarnMsg = resSeven10265.WarnMsg
  25034. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25035. res.Infcode = infocode
  25036. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25037. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25038. var cert_no string
  25039. if his.IdCardType == 1 {
  25040. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25041. } else {
  25042. cert_no = psn_info.VerifyNumber
  25043. }
  25044. 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)
  25045. var dat map[string]interface{}
  25046. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25047. fmt.Println(dat)
  25048. } else {
  25049. fmt.Println(err)
  25050. }
  25051. saveLog(result2, src_resquest, "2207", "结算")
  25052. userJSONBytes, _ := json.Marshal(dat)
  25053. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25054. utils.ErrorLog("解析失败:%v", err)
  25055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25056. return
  25057. }
  25058. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25059. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25060. var cert_no string
  25061. var card_sn string
  25062. if his.IdCardType == 1 {
  25063. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25064. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25065. bas := strings.Split(psn_info.CardInfo, "|")
  25066. card_sn = bas[3]
  25067. } else if his.IdCardType == 2 {
  25068. cert_no = his.IdCardNo
  25069. } else {
  25070. cert_no = psn_info.VerifyNumber
  25071. }
  25072. var rf []*ResultFive
  25073. json.Unmarshal([]byte(his.Iinfo), &rf)
  25074. var psn_type string
  25075. for _, item := range rf {
  25076. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  25077. psn_type = item.PsnType
  25078. }
  25079. }
  25080. 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)
  25081. var dat map[string]interface{}
  25082. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25083. fmt.Println(dat)
  25084. } else {
  25085. fmt.Println(err)
  25086. }
  25087. saveLog(result2, src_resquest, "2207", "结算")
  25088. userJSONBytes, _ := json.Marshal(dat)
  25089. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25090. utils.ErrorLog("解析失败:%v", err)
  25091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25092. return
  25093. }
  25094. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25095. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25096. if his.IdCardType == 1 {
  25097. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25098. bas := strings.Split(psn_info.CardInfo, "|")
  25099. cert_no = bas[2]
  25100. } else if his.IdCardType == 3 {
  25101. cert_no = his.Certno
  25102. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  25103. } else if his.IdCardType == 4 {
  25104. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25105. cert_no = his.Certno
  25106. psn_info.VerifyNumber = psn_info.VerifyNumber
  25107. } else {
  25108. cert_no = his.Certno
  25109. psn_info.VerifyNumber = his.Certno
  25110. }
  25111. var api string
  25112. var med_type string
  25113. if his.Insutype == "390" {
  25114. if reg_type == 992102 {
  25115. med_type = "992102"
  25116. }
  25117. if reg_type == 140104 {
  25118. med_type = "140104"
  25119. }
  25120. if reg_type == 14 {
  25121. med_type = "14"
  25122. }
  25123. } else if his.Insutype == "310" {
  25124. if reg_type == 992102 {
  25125. med_type = "992102"
  25126. }
  25127. if reg_type == 14 {
  25128. med_type = "14"
  25129. }
  25130. }
  25131. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25132. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25133. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25134. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25135. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  25136. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25137. "&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
  25138. resp, requestErr := http.Get(api)
  25139. if requestErr != nil {
  25140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25141. return
  25142. }
  25143. body, ioErr := ioutil.ReadAll(resp.Body)
  25144. if ioErr != nil {
  25145. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25147. return
  25148. }
  25149. var respJSON map[string]interface{}
  25150. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25151. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25153. return
  25154. }
  25155. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25156. if status == "0" {
  25157. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25158. c.ServeSuccessJSON(map[string]interface{}{
  25159. "failed_code": -10,
  25160. "msg": err_msg,
  25161. })
  25162. return
  25163. }
  25164. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25165. result, _ := json.Marshal(respJSON)
  25166. fmt.Println("log")
  25167. fmt.Println(string(result))
  25168. if err := json.Unmarshal(result, &ahres); err != nil {
  25169. utils.ErrorLog("解析失败:%v", err)
  25170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25171. return
  25172. }
  25173. res.InfRefmsgid = ahres.InfRefmsgid
  25174. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  25175. // 创建对应的Time类型
  25176. t := time.UnixMilli(timestamp)
  25177. // 格式化成指定的日期字符串
  25178. str := t.Format("2006-01-02 15:04:05")
  25179. res.Output.Setlinfo.SetlTime = str
  25180. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  25181. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  25182. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  25183. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  25184. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  25185. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  25186. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  25187. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  25188. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  25189. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  25190. res.Output.Setlinfo.ClrType = "11"
  25191. } else {
  25192. res.Output.Setlinfo.ClrType = "9903"
  25193. }
  25194. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  25195. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  25196. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  25197. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  25198. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  25199. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  25200. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  25201. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  25202. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  25203. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  25204. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  25205. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  25206. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  25207. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  25208. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  25209. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  25210. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  25211. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  25212. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  25213. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  25214. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  25215. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  25216. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  25217. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  25218. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  25219. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  25220. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  25221. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  25222. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  25223. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  25224. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  25225. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  25226. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  25227. res.Output.Setldetail = ahres.Output.Setldetail
  25228. res.ErrMsg = ahres.ErrMsg
  25229. res.Cainfo = ahres.Cainfo
  25230. res.WarnMsg = ahres.WarnMsg
  25231. res.Infcode = ahres.Infcode
  25232. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25233. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25234. var cert_no string
  25235. if his.IdCardType == 1 {
  25236. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25237. } else if his.IdCardType == 2 {
  25238. cert_no = his.IdCardNo
  25239. } else {
  25240. cert_no = psn_info.VerifyNumber
  25241. }
  25242. 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, "")
  25243. var dat map[string]interface{}
  25244. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25245. fmt.Println(dat)
  25246. } else {
  25247. fmt.Println(err)
  25248. }
  25249. saveLog(result2, src_resquest, "2207", "结算")
  25250. userJSONBytes, _ := json.Marshal(dat)
  25251. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25252. utils.ErrorLog("解析失败:%v", err)
  25253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25254. return
  25255. }
  25256. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25257. psn_info, _ := service.GetPsnByPatientId(id)
  25258. var verify_number string
  25259. if psn_info.IdCardType == 4 {
  25260. verify_number = psn_info.VerifyNumber
  25261. } else if psn_info.IdCardType == 1 {
  25262. bas := strings.Split(psn_info.CardInfo, "|")
  25263. cardNumber := bas[2]
  25264. verify_number = cardNumber
  25265. } else {
  25266. verify_number = psn_info.Certno
  25267. psn_info.IdCardType = 2
  25268. }
  25269. var api string
  25270. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  25271. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  25272. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25273. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25274. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  25275. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  25276. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  25277. resp, requestErr := http.Get(api)
  25278. if requestErr != nil {
  25279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25280. return
  25281. }
  25282. body, ioErr := ioutil.ReadAll(resp.Body)
  25283. if ioErr != nil {
  25284. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25286. return
  25287. }
  25288. var respJSON map[string]interface{}
  25289. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25290. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25292. return
  25293. }
  25294. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25295. result, _ := json.Marshal(respJSON)
  25296. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25297. utils.ErrorLog("解析失败:%v", err)
  25298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25299. return
  25300. }
  25301. } else {
  25302. var src_resquest string
  25303. if miConfig.Code == "H15049901371" {
  25304. //赤峰地区国家医保医疗类别
  25305. //职工透析:医疗类别选特殊情况门诊990502
  25306. //居民定额血透门慢: 医疗类别选门诊慢病140104
  25307. var med_type string
  25308. if his.Insutype == "390" {
  25309. if reg_type == 14 {
  25310. med_type = "9933"
  25311. } else if reg_type == 11 {
  25312. med_type = "11"
  25313. }
  25314. } else if his.Insutype == "310" {
  25315. if reg_type == 14 {
  25316. med_type = "990502"
  25317. } else if reg_type == 11 {
  25318. med_type = "11"
  25319. }
  25320. }
  25321. 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)
  25322. } else {
  25323. if his.IdCardType == 4 {
  25324. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  25325. token := psn_info.VerifyNumber
  25326. 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)
  25327. } else {
  25328. 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)
  25329. }
  25330. }
  25331. var dat map[string]interface{}
  25332. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25333. fmt.Println(dat)
  25334. } else {
  25335. fmt.Println(err)
  25336. }
  25337. saveLog(result2, src_resquest, "2207", "结算")
  25338. userJSONBytes, _ := json.Marshal(dat)
  25339. if miConfig.Code == "H15049901371" {
  25340. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  25341. utils.ErrorLog("解析失败:%v", err)
  25342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25343. return
  25344. }
  25345. res.InfRefmsgid = resSeven10265.InfRefmsgid
  25346. res.Output = resSeven10265.Output
  25347. res.ErrMsg = resSeven10265.ErrMsg
  25348. res.Cainfo = resSeven10265.Cainfo
  25349. res.WarnMsg = resSeven10265.WarnMsg
  25350. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  25351. res.Infcode = infocode
  25352. } else {
  25353. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25354. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  25355. utils.ErrorLog("解析失败:%v", err)
  25356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25357. return
  25358. }
  25359. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  25360. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  25361. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  25362. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  25363. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  25364. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  25365. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  25366. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  25367. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  25368. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25369. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25370. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25371. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25372. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  25373. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  25374. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  25375. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  25376. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  25377. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  25378. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  25379. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  25380. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  25381. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  25382. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  25383. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  25384. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  25385. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  25386. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  25387. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  25388. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  25389. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  25390. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  25391. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  25392. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  25393. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  25394. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  25395. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  25396. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  25397. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  25398. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  25399. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  25400. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  25401. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  25402. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  25403. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  25404. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  25405. res.ErrMsg = gzresSeven10265Two.ErrMsg
  25406. res.Cainfo = gzresSeven10265Two.Cainfo
  25407. res.WarnMsg = gzresSeven10265Two.WarnMsg
  25408. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  25409. //res.Infcode = infocode
  25410. } else {
  25411. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25412. utils.ErrorLog("解析失败:%v", err)
  25413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25414. return
  25415. }
  25416. }
  25417. }
  25418. }
  25419. if res.Infcode == -1 {
  25420. errlog := &models.HisOrderError{
  25421. UserOrgId: adminUser.CurrentOrgId,
  25422. Ctime: time.Now().Unix(),
  25423. Mtime: time.Now().Unix(),
  25424. Number: chrg_bchno,
  25425. ErrMsg: res.ErrMsg,
  25426. Status: 1,
  25427. PatientId: id,
  25428. RecordTime: recordDateTime,
  25429. Stage: 6,
  25430. }
  25431. service.CreateErrMsgLog(errlog)
  25432. c.ServeSuccessJSON(map[string]interface{}{
  25433. "failed_code": -10,
  25434. "msg": res.ErrMsg,
  25435. })
  25436. return
  25437. } else {
  25438. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  25439. order.OrderStatus = 2
  25440. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  25441. order.SetlId = res.Output.Setlinfo.SetlID
  25442. order.PsnNo = res.Output.Setlinfo.PsnNo
  25443. order.PsnName = res.Output.Setlinfo.PsnName
  25444. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  25445. order.Certno = res.Output.Setlinfo.Certno
  25446. order.Gend = res.Output.Setlinfo.Gend
  25447. order.Naty = res.Output.Setlinfo.Naty
  25448. order.Age = res.Output.Setlinfo.Age
  25449. order.Insutype = res.Output.Setlinfo.Insutype
  25450. order.PsnType = res.Output.Setlinfo.PsnType
  25451. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  25452. order.SetlTime = res.Output.Setlinfo.SetlTime
  25453. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  25454. order.PayWays = pay_ways
  25455. order.AcctUsedFlag = acct_used_flag
  25456. order.WechatPay = wechat_pay
  25457. order.AliPay = ali_pay
  25458. order.JifenPay = jifen_pay
  25459. order.BandCardPay = band_card_pay
  25460. order.CashPay = cash_pay
  25461. order.OthDesc = oth_desc
  25462. //order.MedType = res.Output.Setlinfo.MedType
  25463. if reg_type == 1112 {
  25464. order.MedType = "1112"
  25465. }
  25466. if reg_type == 1111 {
  25467. order.MedType = "1111"
  25468. }
  25469. order.ClrType = res.Output.Setlinfo.ClrType
  25470. if adminUser.CurrentOrgId == 10480 {
  25471. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  25472. order.ClrType = "11"
  25473. } else {
  25474. order.ClrType = "9903"
  25475. }
  25476. }
  25477. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  25478. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  25479. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  25480. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  25481. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  25482. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  25483. order.HifpPay = res.Output.Setlinfo.HifpPay
  25484. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  25485. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  25486. order.HifesPay = res.Output.Setlinfo.HifesPay
  25487. order.HifobPay = res.Output.Setlinfo.HifobPay
  25488. order.MafPay = res.Output.Setlinfo.MafPay
  25489. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  25490. order.OthPay = res.Output.Setlinfo.OthPay
  25491. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  25492. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  25493. order.AcctPay = res.Output.Setlinfo.AcctPay
  25494. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  25495. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  25496. order.Balc = res.Output.Setlinfo.Balc
  25497. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  25498. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  25499. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  25500. order.ClrWay = res.Output.Setlinfo.ClrWay
  25501. order.Creator = order.Creator
  25502. order.Modify = roles.AdminUserId
  25503. order.RequestLog = src_resquest
  25504. order.Diagnosis = diagnosis_id
  25505. order.FaPiaoNumber = fapiao_number
  25506. order.FaPiaoCode = fapiao_code
  25507. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  25508. detailStr := string(setlDetail)
  25509. order.SetlDetail = detailStr
  25510. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  25511. err = service.UpDateOrder(order)
  25512. if err == nil {
  25513. //判断是否使用了押金
  25514. if dec_way == "true" {
  25515. tmpstring := strconv.FormatInt(order.ID, 10)
  25516. //扣押金
  25517. order.Decimal = decimal
  25518. service.UpDateOrder(order)
  25519. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  25520. if errmsg != nil {
  25521. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  25522. return
  25523. }
  25524. }
  25525. c.ServeSuccessJSON(map[string]interface{}{
  25526. "msg": "结算成功",
  25527. })
  25528. } else {
  25529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  25530. return
  25531. }
  25532. }
  25533. }
  25534. }
  25535. }
  25536. // 上传明细-预结算-
  25537. func (c *HisApiController) GetPreUploadInfo() {
  25538. id, _ := c.GetInt64("id")
  25539. record_time := c.GetString("record_time")
  25540. his_patient_id, _ := c.GetInt64("his_patient_id")
  25541. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  25542. admin_user_id, _ := c.GetInt64("admin_user_id")
  25543. diagnosis_id := c.GetString("diagnosis")
  25544. sick_type, _ := c.GetInt64("sick_type")
  25545. reg_type, _ := c.GetInt64("p_type")
  25546. begin_time := c.GetString("begin_time")
  25547. acct_used_flag := c.GetString("acct_used_flag")
  25548. id_str := c.GetString("ids")
  25549. ids_arr := strings.Split(id_str, ",")
  25550. timeLayout := "2006-01-02"
  25551. loc, _ := time.LoadLocation("Local")
  25552. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  25553. if err != nil {
  25554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25555. return
  25556. }
  25557. recordDateTime := theTime.Unix()
  25558. adminUser := c.GetAdminUserInfo()
  25559. diagnosis_ids := strings.Split(diagnosis_id, ",")
  25560. var config []*models.HisXtDiagnoseConfig
  25561. for _, item := range diagnosis_ids {
  25562. id, _ := strconv.ParseInt(item, 10, 64)
  25563. diagnosisConfig, _ := service.FindDiagnoseById(id)
  25564. config = append(config, &diagnosisConfig)
  25565. }
  25566. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  25567. sickConfig, _ := service.FindSickById(sick_type)
  25568. var prescriptions []*models.HisPrescription
  25569. var start_time int64
  25570. var end_time int64
  25571. var isSuccess bool = true
  25572. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25573. fmt.Println(his_patient_id)
  25574. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  25575. timestamp := time.Now().Unix()
  25576. tempTime := time.Unix(timestamp, 0)
  25577. timeFormat := tempTime.Format("20060102150405")
  25578. chrgBchno := rand.Intn(100000) + 10000
  25579. new_chrg_bchno := ""
  25580. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  25581. new_chrg_bchno = chrg_bchno
  25582. if adminUser.CurrentOrgId == 10265 {
  25583. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  25584. new_chrg_bchno = "0000"
  25585. }
  25586. }
  25587. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25588. var patientPrescription models.HisPrescriptionInfo
  25589. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  25590. if patientPrescription.ID == 0 {
  25591. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  25592. }
  25593. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25594. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  25595. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  25596. strconv.FormatInt(his.PatientId, 10)
  25597. var res2406 Result2406
  25598. //安徽单病种处理
  25599. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  25600. data := make(map[string]interface{})
  25601. client := &http.Client{}
  25602. data["psn_no"] = his.PsnNo
  25603. data["mdtrt_id"] = his.Number
  25604. data["operator"] = roles.UserName
  25605. data["cert_no"] = his.IdCardNo
  25606. data["org_name"] = miConfig.OrgName
  25607. data["psn_name"] = his.Name
  25608. data["ipt_otp_no"] = his.IptOtpNo
  25609. data["ipt_psn_sp_flag_type"] = "0901"
  25610. data["ipt_psn_sp_flag"] = "1"
  25611. data["fixmedins_code"] = miConfig.Code
  25612. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25613. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25614. data["url"] = miConfig.Url
  25615. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  25616. bytesData, _ := json.Marshal(data)
  25617. var req *http.Request
  25618. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  25619. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  25620. resp, _ := client.Do(req)
  25621. defer resp.Body.Close()
  25622. body, ioErr := ioutil.ReadAll(resp.Body)
  25623. if ioErr != nil {
  25624. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25626. return
  25627. }
  25628. var respJSON map[string]interface{}
  25629. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25630. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25632. return
  25633. }
  25634. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25635. if status == "0" {
  25636. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25637. c.ServeSuccessJSON(map[string]interface{}{
  25638. "failed_code": -10,
  25639. "msg": err_msg,
  25640. })
  25641. return
  25642. }
  25643. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25644. userJSONBytes, _ := json.Marshal(respJSON)
  25645. fmt.Println("log")
  25646. fmt.Println(string(userJSONBytes))
  25647. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  25648. utils.ErrorLog("解析失败:%v", err)
  25649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25650. return
  25651. }
  25652. }
  25653. if res2406.Infcode != 0 {
  25654. adminUser := c.GetAdminUserInfo()
  25655. errlog := &models.HisOrderError{
  25656. UserOrgId: adminUser.CurrentOrgId,
  25657. Ctime: time.Now().Unix(),
  25658. Mtime: time.Now().Unix(),
  25659. ErrMsg: res2406.ErrMsg,
  25660. Status: 1,
  25661. PatientId: id,
  25662. RecordTime: recordDateTime,
  25663. Stage: 3,
  25664. }
  25665. service.CreateErrMsgLog(errlog)
  25666. c.ServeSuccessJSON(map[string]interface{}{
  25667. "failed_code": -10,
  25668. "msg": res2406.ErrMsg,
  25669. })
  25670. return
  25671. }
  25672. var res2 ResultSix
  25673. var res3 GZResultSix
  25674. var resSix10265 ResultSix10265
  25675. //var time_stamp string
  25676. if miConfig.MdtrtareaAdmvs == "421300" {
  25677. data := make(map[string]interface{})
  25678. client := &http.Client{}
  25679. data["psn_no"] = his.PsnNo
  25680. data["mdtrt_id"] = his.Number
  25681. data["department"] = department.Name
  25682. data["org_name"] = miConfig.OrgName
  25683. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25684. data["doctor_id"] = doctor_info.DoctorNumber
  25685. data["doctor_name"] = roles.UserName
  25686. data["fixmedins_code"] = miConfig.Code
  25687. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25688. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25689. data["secret_key"] = miConfig.SecretKey
  25690. data["sick_code"] = sickConfig.CountryCode
  25691. data["sick_name"] = sickConfig.ClassName
  25692. data["begin_time"] = begin_time
  25693. data["dept"] = strconv.FormatInt(department.ID, 10)
  25694. data["config"] = config
  25695. data["opter"] = roles.UserName
  25696. fmt.Println(data)
  25697. bytesData, _ := json.Marshal(data)
  25698. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  25699. resp, _ := client.Do(req)
  25700. defer resp.Body.Close()
  25701. body, ioErr := ioutil.ReadAll(resp.Body)
  25702. if ioErr != nil {
  25703. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25705. return
  25706. }
  25707. var respJSON map[string]interface{}
  25708. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25709. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25711. return
  25712. }
  25713. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25714. userJSONBytes, _ := json.Marshal(respJSON)
  25715. fmt.Println("log")
  25716. fmt.Println(string(userJSONBytes))
  25717. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25718. utils.ErrorLog("解析失败:%v", err)
  25719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25720. return
  25721. }
  25722. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25723. data := make(map[string]interface{})
  25724. client := &http.Client{}
  25725. data["psn_no"] = his.PsnNo
  25726. data["mdtrt_id"] = his.Number
  25727. data["department"] = department.Name
  25728. data["org_name"] = miConfig.OrgName
  25729. if reg_type == 11 && his.Insutype == "390" {
  25730. data["med_type"] = "110104"
  25731. } else {
  25732. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25733. }
  25734. data["doctor_id"] = doctor_info.DoctorNumber
  25735. data["doctor_name"] = roles.UserName
  25736. data["fixmedins_code"] = miConfig.Code
  25737. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25738. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25739. data["secret_key"] = miConfig.SecretKey
  25740. data["sick_code"] = sickConfig.CountryCode
  25741. data["sick_name"] = sickConfig.ClassName
  25742. data["begin_time"] = begin_time
  25743. data["dept"] = strconv.FormatInt(department.ID, 10)
  25744. data["config"] = config
  25745. data["opter"] = roles.UserName
  25746. fmt.Println(data)
  25747. bytesData, _ := json.Marshal(data)
  25748. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  25749. resp, _ := client.Do(req)
  25750. defer resp.Body.Close()
  25751. body, ioErr := ioutil.ReadAll(resp.Body)
  25752. if ioErr != nil {
  25753. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25755. return
  25756. }
  25757. var respJSON map[string]interface{}
  25758. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25761. return
  25762. }
  25763. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25764. userJSONBytes, _ := json.Marshal(respJSON)
  25765. fmt.Println("log")
  25766. fmt.Println(string(userJSONBytes))
  25767. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25768. utils.ErrorLog("解析失败:%v", err)
  25769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25770. return
  25771. }
  25772. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25773. data := make(map[string]interface{})
  25774. client := &http.Client{}
  25775. data["psn_no"] = his.PsnNo
  25776. data["mdtrt_id"] = his.Number
  25777. data["department"] = department.Name
  25778. data["org_name"] = miConfig.OrgName
  25779. if reg_type == 11 && his.Insutype == "390" {
  25780. data["med_type"] = "110104"
  25781. } else {
  25782. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25783. }
  25784. data["doctor_id"] = doctor_info.DoctorNumber
  25785. data["doctor_name"] = roles.UserName
  25786. data["fixmedins_code"] = miConfig.Code
  25787. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25788. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25789. data["secret_key"] = miConfig.SecretKey
  25790. data["sick_code"] = sickConfig.CountryCode
  25791. data["sick_name"] = sickConfig.ClassName
  25792. data["begin_time"] = begin_time
  25793. data["dept"] = strconv.FormatInt(department.ID, 10)
  25794. data["config"] = config
  25795. data["opter"] = roles.UserName
  25796. fmt.Println(data)
  25797. bytesData, _ := json.Marshal(data)
  25798. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25799. resp, _ := client.Do(req)
  25800. defer resp.Body.Close()
  25801. body, ioErr := ioutil.ReadAll(resp.Body)
  25802. if ioErr != nil {
  25803. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25805. return
  25806. }
  25807. var respJSON map[string]interface{}
  25808. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25809. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25811. return
  25812. }
  25813. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25814. userJSONBytes, _ := json.Marshal(respJSON)
  25815. fmt.Println("log")
  25816. fmt.Println(string(userJSONBytes))
  25817. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25818. utils.ErrorLog("解析失败:%v", err)
  25819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25820. return
  25821. }
  25822. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25823. data := make(map[string]interface{})
  25824. client := &http.Client{}
  25825. data["psn_no"] = his.PsnNo
  25826. data["mdtrt_id"] = his.Number
  25827. data["department"] = department.Name
  25828. data["org_name"] = miConfig.OrgName
  25829. if reg_type == 11 && his.Insutype == "390" {
  25830. data["med_type"] = "110104"
  25831. } else {
  25832. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25833. }
  25834. data["doctor_id"] = doctor_info.DoctorNumber
  25835. data["doctor_name"] = roles.UserName
  25836. data["fixmedins_code"] = miConfig.Code
  25837. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25838. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25839. data["secret_key"] = miConfig.SecretKey
  25840. data["sick_code"] = sickConfig.CountryCode
  25841. data["sick_name"] = sickConfig.ClassName
  25842. data["begin_time"] = begin_time
  25843. data["dept"] = strconv.FormatInt(department.ID, 10)
  25844. data["config"] = config
  25845. data["opter"] = roles.UserName
  25846. fmt.Println(data)
  25847. bytesData, _ := json.Marshal(data)
  25848. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  25849. resp, _ := client.Do(req)
  25850. defer resp.Body.Close()
  25851. body, ioErr := ioutil.ReadAll(resp.Body)
  25852. if ioErr != nil {
  25853. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25855. return
  25856. }
  25857. var respJSON map[string]interface{}
  25858. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25859. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25861. return
  25862. }
  25863. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25864. userJSONBytes, _ := json.Marshal(respJSON)
  25865. fmt.Println("log")
  25866. fmt.Println(string(userJSONBytes))
  25867. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25868. utils.ErrorLog("解析失败:%v", err)
  25869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25870. return
  25871. }
  25872. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25873. data := make(map[string]interface{})
  25874. client := &http.Client{}
  25875. data["psn_no"] = his.PsnNo
  25876. data["mdtrt_id"] = his.Number
  25877. data["doctor"] = roles.UserName
  25878. data["department"] = department.Name
  25879. data["org_name"] = miConfig.OrgName
  25880. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25881. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  25882. data["fixmedins_code"] = miConfig.Code
  25883. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25884. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25885. data["secret_key"] = miConfig.SecretKey
  25886. data["sick_code"] = sickConfig.CountryCode
  25887. data["sick_name"] = sickConfig.ClassName
  25888. data["begin_time"] = begin_time
  25889. data["dept"] = strconv.FormatInt(department.ID, 10)
  25890. data["config"] = config
  25891. data["url"] = miConfig.Url
  25892. data["ak"] = miConfig.AccessKey
  25893. data["cainfo"] = miConfig.Cainfo
  25894. bytesData, _ := json.Marshal(data)
  25895. var req *http.Request
  25896. if miConfig.MdtrtareaAdmvs == "320921" {
  25897. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25898. } else {
  25899. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  25900. }
  25901. resp, _ := client.Do(req)
  25902. defer resp.Body.Close()
  25903. body, ioErr := ioutil.ReadAll(resp.Body)
  25904. if ioErr != nil {
  25905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25907. return
  25908. }
  25909. var respJSON map[string]interface{}
  25910. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25913. return
  25914. }
  25915. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  25916. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  25917. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  25918. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25919. userJSONBytes, _ := json.Marshal(respJSON)
  25920. fmt.Println("log")
  25921. fmt.Println(string(userJSONBytes))
  25922. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  25923. utils.ErrorLog("解析失败:%v", err)
  25924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25925. return
  25926. }
  25927. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25928. res2.Output = resSix10265.Output
  25929. res2.ErrMsg = resSix10265.ErrMsg
  25930. res2.Cainfo = resSix10265.Cainfo
  25931. res2.WarnMsg = resSix10265.WarnMsg
  25932. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25933. res2.Infcode = infocode
  25934. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25935. data := make(map[string]interface{})
  25936. client := &http.Client{}
  25937. data["psn_no"] = his.PsnNo
  25938. data["mdtrt_id"] = his.Number
  25939. data["doctor"] = roles.UserName
  25940. data["department"] = department.Name
  25941. data["org_name"] = miConfig.OrgName
  25942. data["med_type"] = strconv.FormatInt(reg_type, 10)
  25943. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  25944. data["fixmedins_code"] = miConfig.Code
  25945. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  25946. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  25947. data["secret_key"] = miConfig.SecretKey
  25948. data["sick_code"] = sickConfig.CountryCode
  25949. data["sick_name"] = sickConfig.ClassName
  25950. data["begin_time"] = begin_time
  25951. data["dept"] = strconv.FormatInt(department.ID, 10)
  25952. data["config"] = config
  25953. //data["url"] = miConfig.Url
  25954. //data["ak"] = miConfig.AccessKey
  25955. data["cainfo"] = miConfig.Cainfo
  25956. fmt.Println(data)
  25957. bytesData, _ := json.Marshal(data)
  25958. var req *http.Request
  25959. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  25960. resp, _ := client.Do(req)
  25961. defer resp.Body.Close()
  25962. body, ioErr := ioutil.ReadAll(resp.Body)
  25963. if ioErr != nil {
  25964. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25966. return
  25967. }
  25968. var respJSON map[string]interface{}
  25969. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  25970. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25972. return
  25973. }
  25974. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  25975. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  25976. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  25977. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25978. userJSONBytes, _ := json.Marshal(respJSON)
  25979. fmt.Println("log")
  25980. fmt.Println(string(userJSONBytes))
  25981. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  25982. utils.ErrorLog("解析失败:%v", err)
  25983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25984. return
  25985. }
  25986. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25987. res2.Output = resSix10265.Output
  25988. res2.ErrMsg = resSix10265.ErrMsg
  25989. res2.Cainfo = resSix10265.Cainfo
  25990. res2.WarnMsg = resSix10265.WarnMsg
  25991. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25992. res2.Infcode = infocode
  25993. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25994. 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)
  25995. saveLog(result, requestLog, "2203", "上传就诊信息")
  25996. var respJSON2 map[string]interface{}
  25997. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  25998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26000. return
  26001. }
  26002. userJSONBytes2, _ := json.Marshal(respJSON2)
  26003. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26004. utils.ErrorLog("解析失败:%v", err)
  26005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26006. return
  26007. }
  26008. } else if miConfig.MdtrtareaAdmvs == "360302" {
  26009. var result string
  26010. var requestLog string
  26011. 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, "")
  26012. saveLog(result, requestLog, "2203", "上传就诊信息")
  26013. var respJSON2 map[string]interface{}
  26014. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26017. return
  26018. }
  26019. userJSONBytes2, _ := json.Marshal(respJSON2)
  26020. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26021. utils.ErrorLog("解析失败:%v", err)
  26022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26023. return
  26024. }
  26025. } else if miConfig.MdtrtareaAdmvs == "341203" {
  26026. data := make(map[string]interface{})
  26027. client := &http.Client{}
  26028. data["psn_no"] = his.PsnNo
  26029. data["mdtrt_id"] = his.Number
  26030. data["operator"] = roles.UserName
  26031. data["department"] = department.Name
  26032. data["org_name"] = miConfig.OrgName
  26033. var med_type string
  26034. if his.Insutype == "390" {
  26035. if reg_type == 992102 {
  26036. med_type = "992102"
  26037. data["sick_code"] = "ZDZ940"
  26038. data["sick_name"] = "慢性肾衰竭"
  26039. }
  26040. if reg_type == 140104 {
  26041. med_type = "140104"
  26042. data["sick_code"] = sickConfig.CountryCode
  26043. data["sick_name"] = sickConfig.ClassName
  26044. }
  26045. if reg_type == 14 {
  26046. med_type = "140104"
  26047. data["sick_code"] = sickConfig.CountryCode
  26048. data["sick_name"] = sickConfig.ClassName
  26049. }
  26050. } else if his.Insutype == "310" {
  26051. if reg_type == 992102 {
  26052. med_type = "992102"
  26053. data["sick_code"] = "ZDZ940"
  26054. data["sick_name"] = "慢性肾衰竭"
  26055. }
  26056. if reg_type == 140104 {
  26057. med_type = "140104"
  26058. data["sick_code"] = sickConfig.CountryCode
  26059. data["sick_name"] = sickConfig.ClassName
  26060. }
  26061. if reg_type == 14 {
  26062. med_type = "14"
  26063. data["sick_code"] = sickConfig.CountryCode
  26064. data["sick_name"] = sickConfig.ClassName
  26065. }
  26066. }
  26067. data["med_type"] = med_type
  26068. data["doctor_number"] = doctor_info.DoctorNumber
  26069. data["doctor_name"] = doctor_info.UserName
  26070. data["fixmedins_code"] = miConfig.Code
  26071. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26072. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26073. data["secret_key"] = miConfig.SecretKey
  26074. data["begin_time"] = begin_time
  26075. data["dept"] = strconv.FormatInt(department.ID, 10)
  26076. data["config"] = config
  26077. data["url"] = miConfig.Url
  26078. data["ak"] = miConfig.AccessKey
  26079. data["cainfo"] = miConfig.Cainfo
  26080. bytesData, _ := json.Marshal(data)
  26081. var req *http.Request
  26082. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  26083. resp, _ := client.Do(req)
  26084. defer resp.Body.Close()
  26085. body, ioErr := ioutil.ReadAll(resp.Body)
  26086. if ioErr != nil {
  26087. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26089. return
  26090. }
  26091. var respJSON map[string]interface{}
  26092. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26093. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26095. return
  26096. }
  26097. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26098. if status == "0" {
  26099. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26100. c.ServeSuccessJSON(map[string]interface{}{
  26101. "failed_code": -10,
  26102. "msg": err_msg,
  26103. })
  26104. return
  26105. }
  26106. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26107. userJSONBytes, _ := json.Marshal(respJSON)
  26108. fmt.Println("log")
  26109. fmt.Println(string(userJSONBytes))
  26110. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26111. utils.ErrorLog("解析失败:%v", err)
  26112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26113. return
  26114. }
  26115. } else if miConfig.MdtrtareaAdmvs == "430800" {
  26116. var result string
  26117. var requestLog string
  26118. 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, "")
  26119. saveLog(result, requestLog, "2203", "上传就诊信息")
  26120. var respJSON2 map[string]interface{}
  26121. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26122. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26124. return
  26125. }
  26126. userJSONBytes2, _ := json.Marshal(respJSON2)
  26127. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26128. utils.ErrorLog("解析失败:%v", err)
  26129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26130. return
  26131. }
  26132. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26133. data := make(map[string]interface{})
  26134. client := &http.Client{}
  26135. data["psn_no"] = his.PsnNo
  26136. data["mdtrt_id"] = his.Number
  26137. data["doctor"] = roles.UserName
  26138. data["department"] = department.Name
  26139. data["org_name"] = miConfig.OrgName
  26140. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26141. data["doctor_id"] = doctor_info.DoctorNumber
  26142. data["fixmedins_code"] = miConfig.Code
  26143. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26144. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26145. data["secret_key"] = miConfig.SecretKey
  26146. data["sick_code"] = sickConfig.CountryCode
  26147. data["sick_name"] = sickConfig.ClassName
  26148. data["begin_time"] = begin_time
  26149. data["new_doctor_name"] = doctor_info.UserName
  26150. data["dept"] = strconv.FormatInt(department.ID, 10)
  26151. data["config"] = config
  26152. bytesData, _ := json.Marshal(data)
  26153. var req *http.Request
  26154. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/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. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26170. userJSONBytes, _ := json.Marshal(respJSON)
  26171. fmt.Println("log")
  26172. fmt.Println(string(userJSONBytes))
  26173. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26174. utils.ErrorLog("解析失败:%v", err)
  26175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26176. return
  26177. }
  26178. } else {
  26179. var result string
  26180. var requestLog string
  26181. if miConfig.MdtrtareaAdmvs == "440781" { //
  26182. 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)
  26183. } else {
  26184. if miConfig.Code == "H15049901371" {
  26185. //赤峰地区国家医保医疗类别
  26186. //职工透析:医疗类别选特殊情况门诊990502
  26187. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26188. var med_type string
  26189. if his.Insutype == "390" {
  26190. if reg_type == 14 {
  26191. med_type = "9933"
  26192. } else if reg_type == 11 {
  26193. med_type = "11"
  26194. }
  26195. } else if his.Insutype == "310" {
  26196. if reg_type == 14 {
  26197. med_type = "990502"
  26198. } else if reg_type == 11 {
  26199. med_type = "11"
  26200. }
  26201. }
  26202. 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)
  26203. } else {
  26204. 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)
  26205. }
  26206. saveLog(result, requestLog, "2203", "上传就诊信息")
  26207. var respJSON2 map[string]interface{}
  26208. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26209. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26211. return
  26212. }
  26213. userJSONBytes2, _ := json.Marshal(respJSON2)
  26214. if miConfig.Code == "H15049901371" {
  26215. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  26216. utils.ErrorLog("解析失败:%v", err)
  26217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26218. return
  26219. }
  26220. res2.InfRefmsgid = resSix10265.InfRefmsgid
  26221. res2.Output = resSix10265.Output
  26222. res2.ErrMsg = resSix10265.ErrMsg
  26223. res2.Cainfo = resSix10265.Cainfo
  26224. res2.WarnMsg = resSix10265.WarnMsg
  26225. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  26226. res2.Infcode = infocode
  26227. } else {
  26228. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26229. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  26230. utils.ErrorLog("解析失败:%v", err)
  26231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26232. return
  26233. }
  26234. res2.Infcode = res3.Infcode
  26235. } else {
  26236. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26237. utils.ErrorLog("解析失败:%v", err)
  26238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26239. return
  26240. }
  26241. }
  26242. }
  26243. }
  26244. }
  26245. if res2.Infcode == -1 {
  26246. adminUser := c.GetAdminUserInfo()
  26247. errlog := &models.HisOrderError{
  26248. UserOrgId: adminUser.CurrentOrgId,
  26249. Ctime: time.Now().Unix(),
  26250. Mtime: time.Now().Unix(),
  26251. ErrMsg: res2.ErrMsg,
  26252. Status: 1,
  26253. PatientId: id,
  26254. RecordTime: recordDateTime,
  26255. Stage: 3,
  26256. }
  26257. service.CreateErrMsgLog(errlog)
  26258. c.ServeSuccessJSON(map[string]interface{}{
  26259. "failed_code": -10,
  26260. "msg": res2.ErrMsg,
  26261. })
  26262. return
  26263. }
  26264. if res2.Infcode != 0 {
  26265. adminUser := c.GetAdminUserInfo()
  26266. errlog := &models.HisOrderError{
  26267. UserOrgId: adminUser.CurrentOrgId,
  26268. Ctime: time.Now().Unix(),
  26269. Mtime: time.Now().Unix(),
  26270. ErrMsg: res2.ErrMsg,
  26271. Status: 1,
  26272. PatientId: id,
  26273. RecordTime: recordDateTime,
  26274. Stage: 3,
  26275. }
  26276. service.CreateErrMsgLog(errlog)
  26277. c.ServeSuccessJSON(map[string]interface{}{
  26278. "failed_code": -10,
  26279. "msg": res2.ErrMsg,
  26280. })
  26281. return
  26282. } else {
  26283. his.Diagnosis = diagnosis_id
  26284. his.SickType = sickConfig.ID
  26285. his.PType = fmt.Sprintf("%d", reg_type)
  26286. service.UpdateHisPatientThree(&his)
  26287. data := make(map[string]interface{})
  26288. if settle_accounts_type == 1 { //日结
  26289. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  26290. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  26291. } else {
  26292. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  26293. }
  26294. data["pre"] = prescriptions
  26295. } else { //月结
  26296. start_time_str := c.GetString("start_time")
  26297. end_time_str := c.GetString("end_time")
  26298. timeLayout := "2006-01-02"
  26299. loc, _ := time.LoadLocation("Local")
  26300. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  26301. if err != nil {
  26302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26303. return
  26304. }
  26305. recordStartTime := theStartTime.Unix()
  26306. start_time = recordStartTime
  26307. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  26308. if err != nil {
  26309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26310. return
  26311. }
  26312. recordEndTime := theEndTime.Unix()
  26313. end_time = recordEndTime
  26314. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  26315. data["pre"] = prescriptions
  26316. }
  26317. client := &http.Client{}
  26318. data["psn_no"] = his.PsnNo
  26319. data["mdtrt_id"] = his.Number
  26320. data["chrg_bchno"] = new_chrg_bchno
  26321. data["org_name"] = miConfig.OrgName
  26322. data["doctor"] = doctor_info.UserName
  26323. data["doctor_id"] = doctor_info.DoctorNumber
  26324. data["dept"] = department.Name
  26325. data["fixmedins_code"] = miConfig.Code
  26326. data["opter"] = roles.UserName
  26327. data["dept_code"] = department.Number
  26328. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26329. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26330. data["secret_key"] = miConfig.SecretKey
  26331. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  26332. data["url"] = miConfig.Url
  26333. data["ak"] = miConfig.AccessKey
  26334. data["new_doctor_name"] = patientPrescription.Doctor
  26335. if his.Insutype == "390" {
  26336. if reg_type == 992102 {
  26337. data["diag_code"] = "ZDZ940"
  26338. }
  26339. if reg_type == 140104 {
  26340. data["diag_code"] = sickConfig.CountryCode
  26341. }
  26342. if reg_type == 14 {
  26343. data["diag_code"] = sickConfig.CountryCode
  26344. }
  26345. } else if his.Insutype == "310" {
  26346. if reg_type == 992102 {
  26347. data["diag_code"] = "ZDZ940"
  26348. }
  26349. if reg_type == 14 {
  26350. data["diag_code"] = sickConfig.CountryCode
  26351. }
  26352. }
  26353. data["cainfo"] = miConfig.Cainfo
  26354. data["opter"] = roles.UserName
  26355. var ids []int64
  26356. for _, item := range prescriptions {
  26357. ids = append(ids, item.ID)
  26358. }
  26359. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26360. if config.IsOpen == 1 { //对接了医保,走医保流程
  26361. var res ResultFour
  26362. var resFour10265 ResultFour10265
  26363. if miConfig.MdtrtareaAdmvs == "421300" {
  26364. bytesData, _ := json.Marshal(data)
  26365. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  26366. resp, _ := client.Do(req)
  26367. defer resp.Body.Close()
  26368. body, ioErr := ioutil.ReadAll(resp.Body)
  26369. if ioErr != nil {
  26370. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26372. return
  26373. }
  26374. var respJSON map[string]interface{}
  26375. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26376. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26378. return
  26379. }
  26380. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26381. userJSONBytes, _ := json.Marshal(respJSON)
  26382. fmt.Println("log")
  26383. fmt.Println(string(userJSONBytes))
  26384. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26385. utils.ErrorLog("解析失败:%v", err)
  26386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26387. return
  26388. }
  26389. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26390. bytesData, _ := json.Marshal(data)
  26391. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  26392. resp, _ := client.Do(req)
  26393. defer resp.Body.Close()
  26394. body, ioErr := ioutil.ReadAll(resp.Body)
  26395. if ioErr != nil {
  26396. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26398. return
  26399. }
  26400. var respJSON map[string]interface{}
  26401. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26402. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26404. return
  26405. }
  26406. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26407. userJSONBytes, _ := json.Marshal(respJSON)
  26408. fmt.Println("log")
  26409. fmt.Println(string(userJSONBytes))
  26410. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26411. utils.ErrorLog("解析失败:%v", err)
  26412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26413. return
  26414. }
  26415. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26416. bytesData, _ := json.Marshal(data)
  26417. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  26418. resp, _ := client.Do(req)
  26419. defer resp.Body.Close()
  26420. body, ioErr := ioutil.ReadAll(resp.Body)
  26421. if ioErr != nil {
  26422. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26424. return
  26425. }
  26426. var respJSON map[string]interface{}
  26427. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26428. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26430. return
  26431. }
  26432. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26433. userJSONBytes, _ := json.Marshal(respJSON)
  26434. fmt.Println("log")
  26435. fmt.Println(string(userJSONBytes))
  26436. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26437. utils.ErrorLog("解析失败:%v", err)
  26438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26439. return
  26440. }
  26441. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26442. bytesData, _ := json.Marshal(data)
  26443. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  26444. resp, _ := client.Do(req)
  26445. defer resp.Body.Close()
  26446. body, ioErr := ioutil.ReadAll(resp.Body)
  26447. if ioErr != nil {
  26448. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26450. return
  26451. }
  26452. var respJSON map[string]interface{}
  26453. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26454. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26456. return
  26457. }
  26458. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26459. userJSONBytes, _ := json.Marshal(respJSON)
  26460. fmt.Println("log")
  26461. fmt.Println(string(userJSONBytes))
  26462. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26463. utils.ErrorLog("解析失败:%v", err)
  26464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26465. return
  26466. }
  26467. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26468. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26469. if result3101.Infcode == "0" {
  26470. if len(result3101.Output.Result) > 0 {
  26471. var errMsgs []string
  26472. for _, item := range result3101.Output.Result {
  26473. errMsgs = append(errMsgs, item.VolaCont)
  26474. }
  26475. c.ServeSuccessJSON(map[string]interface{}{
  26476. "failed_code": -10,
  26477. "msg": errMsgs,
  26478. })
  26479. return
  26480. } else {
  26481. if miConfig.MdtrtareaAdmvs == "320921" {
  26482. data["doctor_id"] = "D320923012139"
  26483. } else {
  26484. data["doctor_id"] = "D371621008686"
  26485. }
  26486. bytesData, _ := json.Marshal(data)
  26487. var req *http.Request
  26488. if miConfig.MdtrtareaAdmvs == "320921" {
  26489. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26490. } else {
  26491. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26492. }
  26493. resp, _ := client.Do(req)
  26494. defer resp.Body.Close()
  26495. body, ioErr := ioutil.ReadAll(resp.Body)
  26496. if ioErr != nil {
  26497. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26499. return
  26500. }
  26501. var respJSON map[string]interface{}
  26502. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26503. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26505. return
  26506. }
  26507. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26508. userJSONBytes, _ := json.Marshal(respJSON)
  26509. fmt.Println("log")
  26510. fmt.Println(string(userJSONBytes))
  26511. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26512. utils.ErrorLog("解析失败:%v", err)
  26513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26514. return
  26515. }
  26516. res.InfRefmsgid = resFour10265.InfRefmsgid
  26517. res.Output = resFour10265.Output
  26518. res.ErrMsg = resFour10265.ErrMsg
  26519. res.Cainfo = resFour10265.Cainfo
  26520. res.WarnMsg = resFour10265.WarnMsg
  26521. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26522. res.Infcode = infocode
  26523. }
  26524. }
  26525. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26526. var pagesize int = 5
  26527. var start int = 1
  26528. var stop int
  26529. var pagecount int
  26530. var curpage int
  26531. data["doctor_id"] = doctor_info.DoctorNumber
  26532. var res2 ResultFour
  26533. //var result res.
  26534. //总页数,向上取整,注意除之前要先转换类型为float64
  26535. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  26536. for curpage = 1; curpage <= pagecount; curpage++ {
  26537. if curpage == 1 {
  26538. start = 1
  26539. } else {
  26540. start = (curpage-1)*pagesize + 1
  26541. }
  26542. stop = curpage * pagesize
  26543. if stop > len(prescriptions) {
  26544. stop = len(prescriptions)
  26545. }
  26546. //var requestLog string
  26547. data["pre"] = prescriptions[start-1 : stop]
  26548. fmt.Println(data["pre"])
  26549. bytesData, _ := json.Marshal(data)
  26550. var req *http.Request
  26551. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  26552. resp, _ := client.Do(req)
  26553. defer resp.Body.Close()
  26554. body, ioErr := ioutil.ReadAll(resp.Body)
  26555. if ioErr != nil {
  26556. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26558. return
  26559. }
  26560. var respJSON map[string]interface{}
  26561. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26562. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26564. return
  26565. }
  26566. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26567. userJSONBytes, _ := json.Marshal(respJSON)
  26568. fmt.Println("log")
  26569. fmt.Println(string(userJSONBytes))
  26570. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26571. utils.ErrorLog("解析失败:%v", err)
  26572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26573. return
  26574. }
  26575. res.InfRefmsgid = resFour10265.InfRefmsgid
  26576. res.Output = resFour10265.Output
  26577. res.ErrMsg = resFour10265.ErrMsg
  26578. res.Cainfo = resFour10265.Cainfo
  26579. res.WarnMsg = resFour10265.WarnMsg
  26580. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26581. res.Infcode = infocode
  26582. if infocode == 0 {
  26583. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  26584. } else {
  26585. isSuccess = false
  26586. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  26587. res.Infcode = -1
  26588. res.ErrMsg = resFour10265.ErrMsg
  26589. errlog := &models.HisOrderError{
  26590. UserOrgId: adminUser.CurrentOrgId,
  26591. Ctime: time.Now().Unix(),
  26592. Mtime: time.Now().Unix(),
  26593. Number: chrg_bchno,
  26594. ErrMsg: "",
  26595. Status: 1,
  26596. PatientId: id,
  26597. RecordTime: recordDateTime,
  26598. Stage: 4,
  26599. }
  26600. service.CreateErrMsgLog(errlog)
  26601. }
  26602. }
  26603. if isSuccess {
  26604. res.Infcode = 0
  26605. res.Output.Result = res2.Output.Result
  26606. } else {
  26607. order := &models.HisOrder{
  26608. UserOrgId: adminUser.CurrentOrgId,
  26609. HisPatientId: his.ID,
  26610. PatientId: his.PatientId,
  26611. SettleAccountsDate: recordDateTime,
  26612. Ctime: time.Now().Unix(),
  26613. Mtime: time.Now().Unix(),
  26614. MdtrtId: his.Number,
  26615. PsnNo: his.PsnNo,
  26616. MedType: strconv.FormatInt(reg_type, 10),
  26617. Status: 1,
  26618. Number: chrg_bchno,
  26619. Infcode: res.Infcode,
  26620. WarnMsg: res.WarnMsg,
  26621. Cainfo: res.Cainfo,
  26622. ErrMsg: res.ErrMsg,
  26623. RespondTime: res.RefmsgTime,
  26624. InfRefmsgid: res.InfRefmsgid,
  26625. OrderStatus: 1,
  26626. IsMedicineInsurance: 1,
  26627. SettleType: settle_accounts_type,
  26628. SettleStartTime: start_time,
  26629. SettleEndTime: end_time,
  26630. Creator: roles.AdminUserId,
  26631. Modify: roles.AdminUserId,
  26632. PType: 2,
  26633. Diagnosis: diagnosis_id,
  26634. }
  26635. err = service.CreateOrder(order)
  26636. if err != nil {
  26637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  26638. return
  26639. }
  26640. c.ServeSuccessJSON(map[string]interface{}{
  26641. "failed_code": -10,
  26642. "msg": res2.ErrMsg,
  26643. })
  26644. return
  26645. }
  26646. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26647. 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)
  26648. var dat map[string]interface{}
  26649. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26650. fmt.Println(dat)
  26651. } else {
  26652. fmt.Println(err)
  26653. }
  26654. saveLog(result, request_log, "2204", "上传费用明细")
  26655. userJSONBytes, _ := json.Marshal(dat)
  26656. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26657. utils.ErrorLog("解析失败:%v", err)
  26658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26659. return
  26660. }
  26661. } else if miConfig.MdtrtareaAdmvs == "360302" {
  26662. 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, "", "")
  26663. var dat map[string]interface{}
  26664. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26665. fmt.Println(dat)
  26666. } else {
  26667. fmt.Println(err)
  26668. }
  26669. saveLog(result, request_log, "2204", "上传费用明细")
  26670. userJSONBytes, _ := json.Marshal(dat)
  26671. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26672. utils.ErrorLog("解析失败:%v", err)
  26673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26674. return
  26675. }
  26676. } else if miConfig.MdtrtareaAdmvs == "341203" {
  26677. bytesData, _ := json.Marshal(data)
  26678. var req *http.Request
  26679. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  26680. resp, _ := client.Do(req)
  26681. defer resp.Body.Close()
  26682. body, ioErr := ioutil.ReadAll(resp.Body)
  26683. if ioErr != nil {
  26684. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26686. return
  26687. }
  26688. var respJSON map[string]interface{}
  26689. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26690. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26692. return
  26693. }
  26694. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26695. if status == "0" {
  26696. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26697. c.ServeSuccessJSON(map[string]interface{}{
  26698. "failed_code": -10,
  26699. "msg": err_msg,
  26700. })
  26701. return
  26702. }
  26703. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26704. userJSONBytes, _ := json.Marshal(respJSON)
  26705. fmt.Println("log")
  26706. fmt.Println(string(userJSONBytes))
  26707. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26708. utils.ErrorLog("解析失败:%v", err)
  26709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26710. return
  26711. }
  26712. } else if miConfig.MdtrtareaAdmvs == "430800" {
  26713. 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, "", "")
  26714. var dat map[string]interface{}
  26715. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26716. fmt.Println(dat)
  26717. } else {
  26718. fmt.Println(err)
  26719. }
  26720. saveLog(result, request_log, "2204", "上传费用明细")
  26721. userJSONBytes, _ := json.Marshal(dat)
  26722. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26723. utils.ErrorLog("解析失败:%v", err)
  26724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26725. return
  26726. }
  26727. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26728. bytesData, _ := json.Marshal(data)
  26729. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  26730. resp, _ := client.Do(req)
  26731. defer resp.Body.Close()
  26732. body, ioErr := ioutil.ReadAll(resp.Body)
  26733. if ioErr != nil {
  26734. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26736. return
  26737. }
  26738. var respJSON map[string]interface{}
  26739. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26740. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26742. return
  26743. }
  26744. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26745. userJSONBytes, _ := json.Marshal(respJSON)
  26746. fmt.Println("log")
  26747. fmt.Println(string(userJSONBytes))
  26748. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26749. utils.ErrorLog("解析失败:%v", err)
  26750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26751. return
  26752. }
  26753. } else {
  26754. if miConfig.MdtrtareaAdmvs == "441202" {
  26755. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26756. if result3101.Infcode == 0 {
  26757. if len(result3101.Output.Result) > 0 {
  26758. var errMsgs []string
  26759. for _, item := range result3101.Output.Result {
  26760. errMsgs = append(errMsgs, item.VolaCont)
  26761. }
  26762. c.ServeSuccessJSON(map[string]interface{}{
  26763. "failed_code": -10,
  26764. "msg": errMsgs,
  26765. })
  26766. return
  26767. } else {
  26768. 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)
  26769. var dat map[string]interface{}
  26770. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26771. fmt.Println(dat)
  26772. } else {
  26773. fmt.Println(err)
  26774. }
  26775. saveLog(result, request_log, "2204", "上传费用明细")
  26776. userJSONBytes, _ := json.Marshal(dat)
  26777. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26778. utils.ErrorLog("解析失败:%v", err)
  26779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26780. return
  26781. }
  26782. }
  26783. } else {
  26784. c.ServeSuccessJSON(map[string]interface{}{
  26785. "failed_code": -10,
  26786. "msg": result3101.ErrMsg,
  26787. })
  26788. return
  26789. }
  26790. } else if miConfig.MdtrtareaAdmvs == "440205" {
  26791. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26792. if result3101.Infcode == 0 {
  26793. if len(result3101.Output.Result) > 0 {
  26794. var errMsgs []string
  26795. for _, item := range result3101.Output.Result {
  26796. errMsgs = append(errMsgs, item.VolaCont)
  26797. }
  26798. c.ServeSuccessJSON(map[string]interface{}{
  26799. "failed_code": -10,
  26800. "msg": errMsgs,
  26801. })
  26802. return
  26803. } else {
  26804. 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)
  26805. var dat map[string]interface{}
  26806. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26807. fmt.Println(dat)
  26808. } else {
  26809. fmt.Println(err)
  26810. }
  26811. saveLog(result, request_log, "2204", "上传费用明细")
  26812. userJSONBytes, _ := json.Marshal(dat)
  26813. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26814. utils.ErrorLog("解析失败:%v", err)
  26815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26816. return
  26817. }
  26818. }
  26819. } else {
  26820. c.ServeSuccessJSON(map[string]interface{}{
  26821. "failed_code": -10,
  26822. "msg": result3101.ErrMsg,
  26823. })
  26824. return
  26825. }
  26826. } else {
  26827. if miConfig.Code == "H15049901371" {
  26828. 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)
  26829. var dat map[string]interface{}
  26830. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26831. fmt.Println(dat)
  26832. } else {
  26833. fmt.Println(err)
  26834. }
  26835. saveLog(result, request_log, "2204", "上传费用明细")
  26836. userJSONBytes, _ := json.Marshal(dat)
  26837. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26838. utils.ErrorLog("解析失败:%v", err)
  26839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26840. return
  26841. }
  26842. res.InfRefmsgid = resFour10265.InfRefmsgid
  26843. res.Output = resFour10265.Output
  26844. res.ErrMsg = resFour10265.ErrMsg
  26845. res.Cainfo = resFour10265.Cainfo
  26846. res.WarnMsg = resFour10265.WarnMsg
  26847. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26848. res.Infcode = infocode
  26849. } else {
  26850. 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)
  26851. var dat map[string]interface{}
  26852. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26853. fmt.Println(dat)
  26854. } else {
  26855. fmt.Println(err)
  26856. }
  26857. saveLog(result, request_log, "2204", "上传费用明细")
  26858. userJSONBytes, _ := json.Marshal(dat)
  26859. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26860. utils.ErrorLog("解析失败:%v", err)
  26861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26862. return
  26863. }
  26864. }
  26865. }
  26866. }
  26867. var total_two float64
  26868. if res.Infcode == -1 {
  26869. errlog := &models.HisOrderError{
  26870. UserOrgId: adminUser.CurrentOrgId,
  26871. Ctime: time.Now().Unix(),
  26872. Mtime: time.Now().Unix(),
  26873. Number: chrg_bchno,
  26874. ErrMsg: res.ErrMsg,
  26875. Status: 1,
  26876. PatientId: id,
  26877. RecordTime: recordDateTime,
  26878. Stage: 4,
  26879. }
  26880. service.CreateErrMsgLog(errlog)
  26881. c.ServeSuccessJSON(map[string]interface{}{
  26882. "failed_code": -10,
  26883. "msg": res.ErrMsg,
  26884. })
  26885. return
  26886. }
  26887. if res.Infcode == 0 {
  26888. order := &models.HisOrder{
  26889. UserOrgId: adminUser.CurrentOrgId,
  26890. HisPatientId: his.ID,
  26891. PatientId: his.PatientId,
  26892. SettleAccountsDate: recordDateTime,
  26893. Ctime: time.Now().Unix(),
  26894. Mtime: time.Now().Unix(),
  26895. MdtrtId: his.Number,
  26896. PsnNo: his.PsnNo,
  26897. MedType: strconv.FormatInt(reg_type, 10),
  26898. Status: 1,
  26899. Number: chrg_bchno,
  26900. Infcode: res.Infcode,
  26901. WarnMsg: res.WarnMsg,
  26902. Cainfo: res.Cainfo,
  26903. ErrMsg: res.ErrMsg,
  26904. RespondTime: res.RefmsgTime,
  26905. InfRefmsgid: res.InfRefmsgid,
  26906. OrderStatus: 1,
  26907. IsMedicineInsurance: 1,
  26908. SettleType: settle_accounts_type,
  26909. SettleStartTime: start_time,
  26910. SettleEndTime: end_time,
  26911. Creator: roles.AdminUserId,
  26912. Modify: roles.AdminUserId,
  26913. PType: 2,
  26914. Diagnosis: diagnosis_id,
  26915. }
  26916. err = service.CreateOrder(order)
  26917. if err != nil {
  26918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  26919. return
  26920. }
  26921. for _, item := range res.Output.Result {
  26922. temp := strings.Split(item.FeedetlSn, "-")
  26923. var advice_id int64 = 0
  26924. var project_id int64 = 0
  26925. var types int64 = 0
  26926. id, _ := strconv.ParseInt(temp[2], 10, 64)
  26927. types, _ = strconv.ParseInt(temp[1], 10, 64)
  26928. if temp[1] == "1" {
  26929. advice_id = id
  26930. project_id = 0
  26931. } else if temp[1] == "2" {
  26932. advice_id = 0
  26933. project_id = id
  26934. }
  26935. total_two = total_two + item.DetItemFeeSumamt
  26936. info := &models.HisOrderInfo{
  26937. OrderNumber: order.Number,
  26938. FeedetlSn: item.FeedetlSn,
  26939. UploadDate: time.Now().Unix(),
  26940. AdviceId: advice_id,
  26941. DetItemFeeSumamt: item.DetItemFeeSumamt,
  26942. Cnt: item.Cnt,
  26943. Pric: float64(item.Pric),
  26944. PatientId: his.PatientId,
  26945. PricUplmtAmt: item.PricUplmtAmt,
  26946. SelfpayProp: item.SelfpayProp,
  26947. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  26948. OverlmtAmt: item.OverlmtAmt,
  26949. PreselfpayAmt: item.PreselfpayAmt,
  26950. BasMednFlag: item.BasMednFlag,
  26951. MedChrgitmType: item.MedChrgitmType,
  26952. HiNegoDrugFlag: item.HiNegoDrugFlag,
  26953. Status: 1,
  26954. Memo: item.Memo,
  26955. Mtime: time.Now().Unix(),
  26956. InscpScpAmt: item.InscpScpAmt,
  26957. DrtReimFlag: item.DrtReimFlag,
  26958. Ctime: time.Now().Unix(),
  26959. ListSpItemFlag: item.ListSpItemFlag,
  26960. ChldMedcFlag: item.ChldMedcFlag,
  26961. LmtUsedFlag: item.LmtUsedFlag,
  26962. ChrgitmLv: item.ChrgitmLv,
  26963. UserOrgId: adminUser.CurrentOrgId,
  26964. HisPatientId: his.ID,
  26965. OrderId: order.ID,
  26966. ProjectId: project_id,
  26967. Type: types,
  26968. }
  26969. service.CreateOrderInfo(info)
  26970. }
  26971. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  26972. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  26973. var total float64
  26974. for _, item := range prescriptions {
  26975. if item.Type == 1 { //药品
  26976. for _, subItem := range item.HisDoctorAdviceInfo {
  26977. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  26978. total_one := price * subItem.PrescribingNumber
  26979. fmt.Println("subItem")
  26980. fmt.Println(subItem.Price)
  26981. fmt.Println("price")
  26982. fmt.Println(price)
  26983. fmt.Println("total_one")
  26984. fmt.Println(total_one)
  26985. total = total + total_one
  26986. fmt.Println(total)
  26987. }
  26988. }
  26989. if item.Type == 2 { //项目
  26990. for _, subItem := range item.HisPrescriptionProject {
  26991. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  26992. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  26993. total_one := price * cnt
  26994. total = total + total_one
  26995. }
  26996. }
  26997. }
  26998. allTotal := fmt.Sprintf("%.2f", total)
  26999. if res.Infcode == 0 {
  27000. var rf []*ResultFive
  27001. json.Unmarshal([]byte(his.Iinfo), &rf)
  27002. chrg_bchno := chrg_bchno
  27003. cert_no := his.Certno
  27004. var insutypes []string
  27005. var insutype string
  27006. var is390 int = 0
  27007. var is310 int = 0
  27008. for _, item := range rf {
  27009. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27010. insutypes = append(insutypes, item.Insutype)
  27011. }
  27012. }
  27013. if len(insutypes) == 1 {
  27014. insutype = insutypes[0]
  27015. } else {
  27016. for _, i := range insutypes {
  27017. if i == "390" {
  27018. is390 = 1
  27019. }
  27020. if i == "310" {
  27021. is310 = 1
  27022. }
  27023. }
  27024. }
  27025. if is390 == 1 {
  27026. insutype = "390"
  27027. }
  27028. if is310 == 1 {
  27029. insutype = "310"
  27030. }
  27031. if len(insutypes) == 0 {
  27032. insutype = "390"
  27033. }
  27034. if len(insutypes) == 2 {
  27035. insutype = strconv.FormatInt(his.SocialType, 10)
  27036. }
  27037. //insutype = "390"
  27038. if his.IdCardType == 1 {
  27039. cert_no = his.MedicalInsuranceNumber
  27040. } else {
  27041. cert_no = his.Certno
  27042. }
  27043. var res ResultSeven
  27044. var ahres ResultSevenAH
  27045. var resSeven10265 ResultSeven10265
  27046. var resSeven10265Two ResultSeven10265Two
  27047. var gzresSeven10265Two GZResultSeven10265Two
  27048. if miConfig.MdtrtareaAdmvs == "421300" {
  27049. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  27050. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27051. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27052. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27053. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27054. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27055. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27056. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  27057. resp, requestErr := http.Get(api)
  27058. if requestErr != nil {
  27059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27060. return
  27061. }
  27062. body, ioErr := ioutil.ReadAll(resp.Body)
  27063. if ioErr != nil {
  27064. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27066. return
  27067. }
  27068. var respJSON map[string]interface{}
  27069. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27070. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27072. return
  27073. }
  27074. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27075. result, _ := json.Marshal(respJSON)
  27076. fmt.Println("log")
  27077. fmt.Println(string(result))
  27078. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27079. utils.ErrorLog("解析失败:%v", err)
  27080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27081. return
  27082. }
  27083. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27084. if reg_type == 11 && his.Insutype == "390" {
  27085. reg_type = 110104
  27086. }
  27087. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27088. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27089. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27090. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27091. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27092. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27093. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  27094. resp, requestErr := http.Get(api)
  27095. if requestErr != nil {
  27096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27097. return
  27098. }
  27099. body, ioErr := ioutil.ReadAll(resp.Body)
  27100. if ioErr != nil {
  27101. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27103. return
  27104. }
  27105. var respJSON map[string]interface{}
  27106. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27107. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27109. return
  27110. }
  27111. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27112. result, _ := json.Marshal(respJSON)
  27113. fmt.Println("log")
  27114. fmt.Println(string(result))
  27115. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27116. utils.ErrorLog("解析失败:%v", err)
  27117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27118. return
  27119. }
  27120. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27121. if reg_type == 11 && his.Insutype == "390" {
  27122. reg_type = 110104
  27123. }
  27124. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27125. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27126. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27127. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27128. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27129. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27130. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  27131. resp, requestErr := http.Get(api)
  27132. if requestErr != nil {
  27133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27134. return
  27135. }
  27136. body, ioErr := ioutil.ReadAll(resp.Body)
  27137. if ioErr != nil {
  27138. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27140. return
  27141. }
  27142. var respJSON map[string]interface{}
  27143. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27146. return
  27147. }
  27148. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27149. result, _ := json.Marshal(respJSON)
  27150. fmt.Println("log")
  27151. fmt.Println(string(result))
  27152. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27153. utils.ErrorLog("解析失败:%v", err)
  27154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27155. return
  27156. }
  27157. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27158. if reg_type == 11 && his.Insutype == "390" {
  27159. reg_type = 110104
  27160. }
  27161. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27162. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27163. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27164. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27165. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27166. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27167. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  27168. resp, requestErr := http.Get(api)
  27169. if requestErr != nil {
  27170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27171. return
  27172. }
  27173. body, ioErr := ioutil.ReadAll(resp.Body)
  27174. if ioErr != nil {
  27175. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27177. return
  27178. }
  27179. var respJSON map[string]interface{}
  27180. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27181. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27183. return
  27184. }
  27185. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27186. result, _ := json.Marshal(respJSON)
  27187. fmt.Println("log")
  27188. fmt.Println(string(result))
  27189. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27190. utils.ErrorLog("解析失败:%v", err)
  27191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27192. return
  27193. }
  27194. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27195. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  27196. if result3101.Infcode == "0" {
  27197. if len(result3101.Output.Result) > 0 {
  27198. var errMsgs []string
  27199. for _, item := range result3101.Output.Result {
  27200. errMsgs = append(errMsgs, item.VolaCont)
  27201. }
  27202. c.ServeSuccessJSON(map[string]interface{}{
  27203. "failed_code": -10,
  27204. "msg": errMsgs,
  27205. })
  27206. return
  27207. } else {
  27208. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27209. if his.IdCardType != 4 {
  27210. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27211. bas := strings.Split(psn_info.CardInfo, "|")
  27212. if his.IdCardType == 1 {
  27213. cert_no = bas[2]
  27214. } else {
  27215. cert_no = bas[1]
  27216. }
  27217. } else {
  27218. cert_no = his.Certno
  27219. }
  27220. //江苏地区国家医保医疗类别
  27221. //职工透析:医疗类别选特殊情况门诊9933
  27222. //居民血透门慢: 医疗类别选门诊慢病1402
  27223. //var med_type string
  27224. //if his.Insutype == "310" {
  27225. // if reg_type == 14 {
  27226. // med_type = "9933"
  27227. // } else if reg_type == 11 {
  27228. // med_type = "11"
  27229. //
  27230. // }
  27231. //} else if his.Insutype == "390" {
  27232. // if reg_type == 14 {
  27233. // med_type = "1402"
  27234. // } else if reg_type == 11 {
  27235. // med_type = "11"
  27236. // }
  27237. //}
  27238. var api string
  27239. if miConfig.MdtrtareaAdmvs == "320921" {
  27240. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27241. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27242. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27243. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27244. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27245. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27246. "&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
  27247. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27248. } else {
  27249. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27250. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27251. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27252. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27253. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27254. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27255. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27256. "&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
  27257. }
  27258. resp, requestErr := http.Get(api)
  27259. if requestErr != nil {
  27260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27261. return
  27262. }
  27263. body, ioErr := ioutil.ReadAll(resp.Body)
  27264. if ioErr != nil {
  27265. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27267. return
  27268. }
  27269. var respJSON map[string]interface{}
  27270. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27273. return
  27274. }
  27275. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27276. result, _ := json.Marshal(respJSON)
  27277. fmt.Println("log")
  27278. fmt.Println(string(result))
  27279. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  27280. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27281. utils.ErrorLog("解析失败:%v", err)
  27282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27283. return
  27284. }
  27285. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27286. res.Output = resSeven10265.Output
  27287. res.ErrMsg = resSeven10265.ErrMsg
  27288. res.Cainfo = resSeven10265.Cainfo
  27289. res.WarnMsg = resSeven10265.WarnMsg
  27290. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27291. res.Infcode = infocode
  27292. } else {
  27293. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  27294. utils.ErrorLog("解析失败:%v", err)
  27295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27296. return
  27297. }
  27298. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  27299. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  27300. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  27301. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  27302. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  27303. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  27304. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  27305. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  27306. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  27307. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  27308. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  27309. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  27310. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  27311. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  27312. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  27313. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27314. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  27315. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  27316. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  27317. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  27318. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  27319. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27320. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  27321. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  27322. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  27323. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  27324. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  27325. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  27326. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  27327. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  27328. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27329. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  27330. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  27331. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  27332. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27333. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27334. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27335. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27336. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  27337. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  27338. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  27339. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  27340. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  27341. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  27342. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  27343. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  27344. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  27345. res.ErrMsg = resSeven10265Two.ErrMsg
  27346. res.Cainfo = resSeven10265Two.Cainfo
  27347. res.WarnMsg = resSeven10265Two.WarnMsg
  27348. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27349. res.Infcode = infocode
  27350. }
  27351. }
  27352. }
  27353. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27354. psn_info, _ := service.GetPsnByPatientId(id)
  27355. var verify_number string
  27356. if psn_info.IdCardType == 4 {
  27357. verify_number = psn_info.VerifyNumber
  27358. } else if psn_info.IdCardType == 1 {
  27359. bas := strings.Split(psn_info.CardInfo, "|")
  27360. cardNumber := bas[2]
  27361. verify_number = cardNumber
  27362. } else {
  27363. psn_info.IdCardType = 2
  27364. verify_number = psn_info.Certno
  27365. }
  27366. var api string
  27367. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27368. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  27369. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27370. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27371. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  27372. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27373. "&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
  27374. resp, requestErr := http.Get(api)
  27375. if requestErr != nil {
  27376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27377. return
  27378. }
  27379. body, ioErr := ioutil.ReadAll(resp.Body)
  27380. if ioErr != nil {
  27381. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27383. return
  27384. }
  27385. var respJSON map[string]interface{}
  27386. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27387. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27389. return
  27390. }
  27391. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27392. result, _ := json.Marshal(respJSON)
  27393. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27394. utils.ErrorLog("解析失败:%v", err)
  27395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27396. return
  27397. }
  27398. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27399. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  27400. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  27401. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  27402. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  27403. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  27404. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  27405. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  27406. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  27407. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  27408. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  27409. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  27410. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  27411. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  27412. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  27413. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  27414. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  27415. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  27416. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  27417. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  27418. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27419. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  27420. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  27421. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  27422. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  27423. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  27424. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  27425. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  27426. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  27427. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  27428. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  27429. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  27430. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  27431. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  27432. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27433. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  27434. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  27435. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  27436. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  27437. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  27438. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  27439. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  27440. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  27441. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  27442. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  27443. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  27444. res.ErrMsg = resSeven10265.ErrMsg
  27445. res.Cainfo = resSeven10265.Cainfo
  27446. res.WarnMsg = resSeven10265.WarnMsg
  27447. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27448. res.Infcode = infocode
  27449. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27450. acct_used_flag := "1"
  27451. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  27452. var result string
  27453. var request_log string
  27454. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  27455. 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)
  27456. } else {
  27457. 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)
  27458. }
  27459. var dat map[string]interface{}
  27460. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27461. fmt.Println(dat)
  27462. } else {
  27463. fmt.Println(err)
  27464. }
  27465. saveLog(result, request_log, "2206", "预结算")
  27466. userJSONBytes, _ := json.Marshal(dat)
  27467. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27468. utils.ErrorLog("解析失败:%v", err)
  27469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27470. return
  27471. }
  27472. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27473. var result string
  27474. var request_log string
  27475. if his.IdCardType == 2 {
  27476. 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, "")
  27477. } else if his.IdCardType == 1 {
  27478. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27479. bas := strings.Split(psn_info.CardInfo, "|")
  27480. basNumber := bas[2]
  27481. card_sn := bas[3]
  27482. var rf []*ResultFive
  27483. json.Unmarshal([]byte(his.Iinfo), &rf)
  27484. var psn_type string
  27485. for _, item := range rf {
  27486. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27487. psn_type = item.PsnType
  27488. }
  27489. }
  27490. 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)
  27491. } else {
  27492. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27493. //bas := strings.Split(psn_info.CardInfo, "|")
  27494. //basNumber := bas[2]
  27495. //card_sn := bas[3]
  27496. var rf []*ResultFive
  27497. json.Unmarshal([]byte(his.Iinfo), &rf)
  27498. var psn_type string
  27499. for _, item := range rf {
  27500. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  27501. psn_type = item.PsnType
  27502. }
  27503. }
  27504. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27505. 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)
  27506. }
  27507. var dat map[string]interface{}
  27508. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27509. fmt.Println(dat)
  27510. } else {
  27511. fmt.Println(err)
  27512. }
  27513. saveLog(result, request_log, "2206", "预结算")
  27514. userJSONBytes, _ := json.Marshal(dat)
  27515. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27516. utils.ErrorLog("解析失败:%v", err)
  27517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27518. return
  27519. }
  27520. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27521. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27522. if his.IdCardType == 4 {
  27523. psn_info.VerifyNumber = psn_info.VerifyNumber
  27524. cert_no = psn_info.Certno
  27525. } else if his.IdCardType == 2 {
  27526. cert_no = psn_info.Certno
  27527. psn_info.VerifyNumber = psn_info.Certno
  27528. } else {
  27529. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27530. bas := strings.Split(psn_info.CardInfo, "|")
  27531. if his.IdCardType == 1 {
  27532. cert_no = bas[2]
  27533. } else {
  27534. cert_no = bas[1]
  27535. }
  27536. }
  27537. var api string
  27538. var med_type string
  27539. if his.Insutype == "390" {
  27540. if reg_type == 992102 {
  27541. med_type = "992102"
  27542. }
  27543. if reg_type == 140104 {
  27544. med_type = "140104"
  27545. }
  27546. if reg_type == 14 {
  27547. med_type = "140104"
  27548. }
  27549. } else if his.Insutype == "310" {
  27550. if reg_type == 992102 {
  27551. med_type = "992102"
  27552. }
  27553. if reg_type == 14 {
  27554. med_type = "14"
  27555. }
  27556. }
  27557. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27558. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27559. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27560. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27561. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27562. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27563. "&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
  27564. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27565. resp, requestErr := http.Get(api)
  27566. if requestErr != nil {
  27567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27568. return
  27569. }
  27570. body, ioErr := ioutil.ReadAll(resp.Body)
  27571. if ioErr != nil {
  27572. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27574. return
  27575. }
  27576. var respJSON map[string]interface{}
  27577. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27578. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27580. return
  27581. }
  27582. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27583. if status == "0" {
  27584. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27585. c.ServeSuccessJSON(map[string]interface{}{
  27586. "failed_code": -10,
  27587. "msg": err_msg,
  27588. })
  27589. return
  27590. }
  27591. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27592. result, _ := json.Marshal(respJSON)
  27593. fmt.Println("log")
  27594. fmt.Println(string(result))
  27595. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  27596. utils.ErrorLog("解析失败:%v", err)
  27597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27598. return
  27599. }
  27600. res.InfRefmsgid = ahres.InfRefmsgid
  27601. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27602. // 创建对应的Time类型
  27603. t := time.UnixMilli(timestamp)
  27604. // 格式化成指定的日期字符串
  27605. str := t.Format("2006-01-02 15:04:05")
  27606. res.Output.Setlinfo.SetlTime = str
  27607. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  27608. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  27609. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27610. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  27611. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  27612. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  27613. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27614. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  27615. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  27616. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  27617. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  27618. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  27619. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  27620. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  27621. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  27622. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  27623. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  27624. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  27625. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  27626. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27627. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  27628. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  27629. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  27630. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  27631. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27632. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  27633. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  27634. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  27635. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  27636. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  27637. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  27638. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  27639. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  27640. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  27641. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  27642. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  27643. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  27644. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  27645. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  27646. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27647. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  27648. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  27649. //res.Output.Setldetail = ahres.Output.Setldetail
  27650. res.ErrMsg = ahres.ErrMsg
  27651. res.Cainfo = ahres.Cainfo
  27652. res.WarnMsg = ahres.WarnMsg
  27653. res.Infcode = ahres.Infcode
  27654. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27655. var result string
  27656. var request_log string
  27657. if his.IdCardType == 2 {
  27658. 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")
  27659. } else if his.IdCardType == 1 {
  27660. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27661. bas := strings.Split(psn_info.CardInfo, "|")
  27662. basNumber := bas[2]
  27663. card_sn := bas[3]
  27664. 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")
  27665. } else {
  27666. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27667. 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")
  27668. }
  27669. var dat map[string]interface{}
  27670. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27671. fmt.Println(dat)
  27672. } else {
  27673. fmt.Println(err)
  27674. }
  27675. saveLog(result, request_log, "2206", "预结算")
  27676. userJSONBytes, _ := json.Marshal(dat)
  27677. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27678. utils.ErrorLog("解析失败:%v", err)
  27679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27680. return
  27681. }
  27682. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27683. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27684. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27685. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27686. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27687. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27688. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27689. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  27690. resp, requestErr := http.Get(api)
  27691. if requestErr != nil {
  27692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27693. return
  27694. }
  27695. body, ioErr := ioutil.ReadAll(resp.Body)
  27696. if ioErr != nil {
  27697. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27699. return
  27700. }
  27701. var respJSON map[string]interface{}
  27702. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27705. return
  27706. }
  27707. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27708. result, _ := json.Marshal(respJSON)
  27709. fmt.Println("log")
  27710. fmt.Println(string(result))
  27711. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27712. utils.ErrorLog("解析失败:%v", err)
  27713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27714. return
  27715. }
  27716. } else {
  27717. if miConfig.MdtrtareaAdmvs == "441202" {
  27718. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  27719. if result3101.Infcode == 0 {
  27720. if len(result3101.Output.Result) > 0 {
  27721. var errMsgs []string
  27722. for _, item := range result3101.Output.Result {
  27723. errMsgs = append(errMsgs, item.VolaCont)
  27724. }
  27725. c.ServeSuccessJSON(map[string]interface{}{
  27726. "failed_code": -10,
  27727. "msg": errMsgs,
  27728. })
  27729. return
  27730. } else {
  27731. var result string
  27732. var request_log string
  27733. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27734. allTotal = fmt.Sprintf("%.2f", total_two)
  27735. if his.IdCardType == 4 {
  27736. 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)
  27737. } else {
  27738. 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)
  27739. }
  27740. var dat map[string]interface{}
  27741. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27742. fmt.Println(dat)
  27743. } else {
  27744. fmt.Println(err)
  27745. }
  27746. saveLog(result, request_log, "2206", "预结算")
  27747. //userJSONBytes, _ := json.Marshal(dat)
  27748. //
  27749. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27750. // utils.ErrorLog("解析失败:%v", err)
  27751. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27752. // return
  27753. //}
  27754. userJSONBytes, _ := json.Marshal(dat)
  27755. if miConfig.Code == "H15049901371" {
  27756. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27757. utils.ErrorLog("解析失败:%v", err)
  27758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27759. return
  27760. }
  27761. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27762. res.Output = resSeven10265.Output
  27763. res.ErrMsg = resSeven10265.ErrMsg
  27764. res.Cainfo = resSeven10265.Cainfo
  27765. res.WarnMsg = resSeven10265.WarnMsg
  27766. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27767. res.Infcode = infocode
  27768. } else {
  27769. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27770. utils.ErrorLog("解析失败:%v", err)
  27771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27772. return
  27773. }
  27774. }
  27775. }
  27776. } else {
  27777. c.ServeSuccessJSON(map[string]interface{}{
  27778. "failed_code": -10,
  27779. "msg": result3101.ErrMsg,
  27780. })
  27781. return
  27782. }
  27783. } else if miConfig.MdtrtareaAdmvs == "440205" {
  27784. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  27785. if result3101.Infcode == 0 {
  27786. if len(result3101.Output.Result) > 0 {
  27787. var errMsgs []string
  27788. for _, item := range result3101.Output.Result {
  27789. errMsgs = append(errMsgs, item.VolaCont)
  27790. }
  27791. c.ServeSuccessJSON(map[string]interface{}{
  27792. "failed_code": -10,
  27793. "msg": errMsgs,
  27794. })
  27795. return
  27796. } else {
  27797. var result string
  27798. var request_log string
  27799. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27800. allTotal = fmt.Sprintf("%.2f", total_two)
  27801. if his.IdCardType == 4 {
  27802. 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)
  27803. } else {
  27804. 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)
  27805. }
  27806. var dat map[string]interface{}
  27807. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27808. fmt.Println(dat)
  27809. } else {
  27810. fmt.Println(err)
  27811. }
  27812. saveLog(result, request_log, "2206", "预结算")
  27813. //userJSONBytes, _ := json.Marshal(dat)
  27814. //
  27815. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27816. // utils.ErrorLog("解析失败:%v", err)
  27817. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27818. // return
  27819. //}
  27820. userJSONBytes, _ := json.Marshal(dat)
  27821. if miConfig.Code == "H15049901371" {
  27822. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27823. utils.ErrorLog("解析失败:%v", err)
  27824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27825. return
  27826. }
  27827. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27828. res.Output = resSeven10265.Output
  27829. res.ErrMsg = resSeven10265.ErrMsg
  27830. res.Cainfo = resSeven10265.Cainfo
  27831. res.WarnMsg = resSeven10265.WarnMsg
  27832. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27833. res.Infcode = infocode
  27834. } else {
  27835. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27836. utils.ErrorLog("解析失败:%v", err)
  27837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27838. return
  27839. }
  27840. }
  27841. }
  27842. } else {
  27843. c.ServeSuccessJSON(map[string]interface{}{
  27844. "failed_code": -10,
  27845. "msg": result3101.ErrMsg,
  27846. })
  27847. return
  27848. }
  27849. } else {
  27850. var result string
  27851. var request_log string
  27852. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27853. allTotal = fmt.Sprintf("%.2f", total_two)
  27854. if his.IdCardType == 4 {
  27855. 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)
  27856. } else {
  27857. 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)
  27858. }
  27859. var dat map[string]interface{}
  27860. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27861. fmt.Println(dat)
  27862. } else {
  27863. fmt.Println(err)
  27864. }
  27865. saveLog(result, request_log, "2206", "预结算")
  27866. //userJSONBytes, _ := json.Marshal(dat)
  27867. //
  27868. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27869. // utils.ErrorLog("解析失败:%v", err)
  27870. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27871. // return
  27872. //}
  27873. userJSONBytes, _ := json.Marshal(dat)
  27874. if miConfig.Code == "H15049901371" {
  27875. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27876. utils.ErrorLog("解析失败:%v", err)
  27877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27878. return
  27879. }
  27880. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27881. res.Output = resSeven10265.Output
  27882. res.ErrMsg = resSeven10265.ErrMsg
  27883. res.Cainfo = resSeven10265.Cainfo
  27884. res.WarnMsg = resSeven10265.WarnMsg
  27885. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27886. res.Infcode = infocode
  27887. } else {
  27888. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27889. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  27890. utils.ErrorLog("解析失败:%v", err)
  27891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27892. return
  27893. }
  27894. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  27895. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  27896. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  27897. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27898. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  27899. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  27900. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  27901. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27902. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  27903. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27904. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27905. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27906. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27907. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27908. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27909. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  27910. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  27911. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  27912. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  27913. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  27914. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27915. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  27916. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  27917. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  27918. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  27919. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  27920. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  27921. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  27922. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  27923. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27924. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  27925. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  27926. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  27927. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27928. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27929. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27930. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27931. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27932. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27933. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27934. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27935. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27936. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27937. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27938. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27939. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27940. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27941. res.Cainfo = gzresSeven10265Two.Cainfo
  27942. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27943. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27944. //res.Infcode = infocode
  27945. } else {
  27946. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27947. utils.ErrorLog("解析失败:%v", err)
  27948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27949. return
  27950. }
  27951. }
  27952. }
  27953. }
  27954. }
  27955. utils.ErrorLog("解析失败:%v", res.Infcode)
  27956. if res.Infcode == -1 {
  27957. errlog := &models.HisOrderError{
  27958. UserOrgId: adminUser.CurrentOrgId,
  27959. Ctime: time.Now().Unix(),
  27960. Mtime: time.Now().Unix(),
  27961. Number: chrg_bchno,
  27962. ErrMsg: res.ErrMsg,
  27963. Status: 1,
  27964. PatientId: id,
  27965. RecordTime: recordDateTime,
  27966. Stage: 20,
  27967. }
  27968. service.CreateErrMsgLog(errlog)
  27969. c.ServeSuccessJSON(map[string]interface{}{
  27970. "failed_code": -10,
  27971. "msg": res.ErrMsg,
  27972. })
  27973. return
  27974. }
  27975. if res.Infcode != 0 {
  27976. errlog := &models.HisOrderError{
  27977. UserOrgId: adminUser.CurrentOrgId,
  27978. Ctime: time.Now().Unix(),
  27979. Mtime: time.Now().Unix(),
  27980. Number: chrg_bchno,
  27981. ErrMsg: res.ErrMsg,
  27982. Status: 1,
  27983. PatientId: id,
  27984. RecordTime: recordDateTime,
  27985. Stage: 20,
  27986. }
  27987. service.CreateErrMsgLog(errlog)
  27988. c.ServeSuccessJSON(map[string]interface{}{
  27989. "failed_code": -10,
  27990. "msg": res.ErrMsg,
  27991. })
  27992. return
  27993. } else {
  27994. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27995. order.OrderStatus = 1
  27996. order.IsPre = 1
  27997. order.Status = 1
  27998. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27999. order.SetlId = res.Output.Setlinfo.SetlID
  28000. order.PsnNo = res.Output.Setlinfo.PsnNo
  28001. order.PsnName = res.Output.Setlinfo.PsnName
  28002. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  28003. order.Certno = res.Output.Setlinfo.Certno
  28004. order.Gend = res.Output.Setlinfo.Gend
  28005. order.Naty = res.Output.Setlinfo.Naty
  28006. order.Age = res.Output.Setlinfo.Age
  28007. order.Insutype = res.Output.Setlinfo.Insutype
  28008. order.PsnType = res.Output.Setlinfo.PsnType
  28009. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  28010. order.SetlTime = res.Output.Setlinfo.SetlTime
  28011. order.AcctUsedFlag = acct_used_flag
  28012. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  28013. if res.Output.Setlinfo.MedType == "140101" {
  28014. order.MedType = "14"
  28015. } else {
  28016. if res.Output.Setlinfo.MedType == "110104" {
  28017. order.MedType = "11"
  28018. } else {
  28019. order.MedType = res.Output.Setlinfo.MedType
  28020. }
  28021. }
  28022. if res.Output.Setlinfo.MedType == "992102" {
  28023. order.MedType = "992102"
  28024. }
  28025. if res.Output.Setlinfo.MedType == "140104" {
  28026. order.MedType = "140104"
  28027. }
  28028. if res.Output.Setlinfo.MedType == "14" {
  28029. order.MedType = "14"
  28030. }
  28031. if reg_type == 1112 {
  28032. order.MedType = "1112"
  28033. }
  28034. if reg_type == 1111 {
  28035. order.MedType = "1111"
  28036. }
  28037. order.ClrType = res.Output.Setlinfo.ClrType
  28038. if adminUser.CurrentOrgId == 10480 {
  28039. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  28040. order.ClrType = "11"
  28041. } else {
  28042. order.ClrType = "9903"
  28043. }
  28044. }
  28045. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  28046. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  28047. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  28048. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  28049. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  28050. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  28051. order.HifpPay = res.Output.Setlinfo.HifpPay
  28052. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  28053. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  28054. order.HifesPay = res.Output.Setlinfo.HifesPay
  28055. order.HifobPay = res.Output.Setlinfo.HifobPay
  28056. order.MafPay = res.Output.Setlinfo.MafPay
  28057. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  28058. order.OthPay = res.Output.Setlinfo.OthPay
  28059. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  28060. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  28061. order.AcctPay = res.Output.Setlinfo.AcctPay
  28062. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  28063. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  28064. order.Balc = res.Output.Setlinfo.Balc
  28065. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  28066. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  28067. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  28068. order.ClrWay = res.Output.Setlinfo.ClrWay
  28069. order.Creator = order.Creator
  28070. order.Modify = roles.AdminUserId
  28071. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  28072. //detailStr := string(setlDetail)
  28073. //order.SetlDetail = detailStr
  28074. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  28075. err = service.UpDateOrder(order)
  28076. if err == nil {
  28077. c.ServeSuccessJSON(map[string]interface{}{
  28078. "msg": "预结算成功",
  28079. })
  28080. } else {
  28081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  28082. return
  28083. }
  28084. }
  28085. } else {
  28086. adminUser := c.GetAdminUserInfo()
  28087. errlog := &models.HisOrderError{
  28088. UserOrgId: adminUser.CurrentOrgId,
  28089. Ctime: time.Now().Unix(),
  28090. Mtime: time.Now().Unix(),
  28091. ErrMsg: res.ErrMsg,
  28092. Status: 1,
  28093. PatientId: id,
  28094. RecordTime: recordDateTime,
  28095. Stage: 4,
  28096. }
  28097. service.CreateErrMsgLog(errlog)
  28098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  28099. return
  28100. }
  28101. } else {
  28102. if miConfig.MdtrtareaAdmvs == "150499" {
  28103. order := &models.HisOrder{
  28104. UserOrgId: adminUser.CurrentOrgId,
  28105. HisPatientId: his.ID,
  28106. PatientId: his.PatientId,
  28107. SettleAccountsDate: recordDateTime,
  28108. Ctime: time.Now().Unix(),
  28109. Mtime: time.Now().Unix(),
  28110. MdtrtId: his.Number,
  28111. PsnNo: his.PsnNo,
  28112. MedType: strconv.FormatInt(reg_type, 10),
  28113. Status: 1,
  28114. Number: chrg_bchno,
  28115. Infcode: res.Infcode,
  28116. WarnMsg: res.WarnMsg,
  28117. Cainfo: res.Cainfo,
  28118. ErrMsg: res.ErrMsg,
  28119. RespondTime: res.RefmsgTime,
  28120. InfRefmsgid: res.InfRefmsgid,
  28121. OrderStatus: 1,
  28122. IsMedicineInsurance: 1,
  28123. SettleType: settle_accounts_type,
  28124. SettleStartTime: start_time,
  28125. SettleEndTime: end_time,
  28126. Creator: roles.AdminUserId,
  28127. Modify: roles.AdminUserId,
  28128. PType: 2,
  28129. Diagnosis: diagnosis_id,
  28130. }
  28131. err = service.CreateOrder(order)
  28132. if err != nil {
  28133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  28134. return
  28135. }
  28136. }
  28137. adminUser := c.GetAdminUserInfo()
  28138. errlog := &models.HisOrderError{
  28139. UserOrgId: adminUser.CurrentOrgId,
  28140. Ctime: time.Now().Unix(),
  28141. Mtime: time.Now().Unix(),
  28142. ErrMsg: res.ErrMsg,
  28143. Status: 1,
  28144. PatientId: id,
  28145. RecordTime: recordDateTime,
  28146. Stage: 4,
  28147. }
  28148. service.CreateErrMsgLog(errlog)
  28149. c.ServeSuccessJSON(map[string]interface{}{
  28150. "failed_code": -10,
  28151. "msg": res.ErrMsg,
  28152. })
  28153. return
  28154. }
  28155. }
  28156. }
  28157. }
  28158. // 退款
  28159. func (c *HisApiController) Refund() {
  28160. order_id, _ := c.GetInt64("order_id")
  28161. admin_user_id, _ := c.GetInt64("admin_user_id")
  28162. adminUser := c.GetAdminUserInfo()
  28163. var order models.HisOrder
  28164. order, _ = service.GetHisOrderByID(order_id)
  28165. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  28166. if fapiao.ID > 0 {
  28167. c.ServeSuccessJSON(map[string]interface{}{
  28168. "failed_code": -10,
  28169. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  28170. })
  28171. return
  28172. }
  28173. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28174. if order.ID == 0 {
  28175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28176. return
  28177. }
  28178. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  28179. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28180. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28181. if config.IsOpen == 1 { //对接了医保,走医保流程
  28182. var res ResultSixteen
  28183. var ahres ResultSevenAH
  28184. var resSixteen10265 ResultSixteen10265
  28185. var resSixteen10265Two ResultSixteen10265Two
  28186. var gz ResultgzSixteen10265Two
  28187. var src_resquest string
  28188. var result string
  28189. if miConfig.MdtrtareaAdmvs == "421300" {
  28190. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  28191. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28192. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28193. resp3, requestErr3 := http.Get(api3)
  28194. if requestErr3 != nil {
  28195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28196. return
  28197. }
  28198. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28199. if ioErr3 != nil {
  28200. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28202. return
  28203. }
  28204. var respJSON3 map[string]interface{}
  28205. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28206. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28208. return
  28209. }
  28210. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28211. userJSONBytes3, _ := json.Marshal(respJSON3)
  28212. fmt.Println("log")
  28213. fmt.Println(string(userJSONBytes3))
  28214. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28215. utils.ErrorLog("解析失败:%v", err)
  28216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28217. return
  28218. }
  28219. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28220. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  28221. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28222. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28223. resp3, requestErr3 := http.Get(api3)
  28224. if requestErr3 != nil {
  28225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28226. return
  28227. }
  28228. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28229. if ioErr3 != nil {
  28230. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28232. return
  28233. }
  28234. var respJSON3 map[string]interface{}
  28235. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28236. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28238. return
  28239. }
  28240. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28241. userJSONBytes3, _ := json.Marshal(respJSON3)
  28242. fmt.Println("log")
  28243. fmt.Println(string(userJSONBytes3))
  28244. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28245. utils.ErrorLog("解析失败:%v", err)
  28246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28247. return
  28248. }
  28249. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28250. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  28251. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28252. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28253. resp3, requestErr3 := http.Get(api3)
  28254. if requestErr3 != nil {
  28255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28256. return
  28257. }
  28258. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28259. if ioErr3 != nil {
  28260. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28262. return
  28263. }
  28264. var respJSON3 map[string]interface{}
  28265. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28266. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28268. return
  28269. }
  28270. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28271. userJSONBytes3, _ := json.Marshal(respJSON3)
  28272. fmt.Println("log")
  28273. fmt.Println(string(userJSONBytes3))
  28274. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28275. utils.ErrorLog("解析失败:%v", err)
  28276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28277. return
  28278. }
  28279. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28280. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  28281. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28282. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28283. resp3, requestErr3 := http.Get(api3)
  28284. if requestErr3 != nil {
  28285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28286. return
  28287. }
  28288. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28289. if ioErr3 != nil {
  28290. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28292. return
  28293. }
  28294. var respJSON3 map[string]interface{}
  28295. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28296. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28298. return
  28299. }
  28300. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28301. userJSONBytes3, _ := json.Marshal(respJSON3)
  28302. fmt.Println("log")
  28303. fmt.Println(string(userJSONBytes3))
  28304. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28305. utils.ErrorLog("解析失败:%v", err)
  28306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28307. return
  28308. }
  28309. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28310. var api3 string
  28311. if miConfig.MdtrtareaAdmvs == "320921" {
  28312. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  28313. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28314. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28315. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28316. } else {
  28317. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28318. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  28319. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28320. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28321. }
  28322. resp3, requestErr3 := http.Get(api3)
  28323. if requestErr3 != nil {
  28324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28325. return
  28326. }
  28327. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28328. if ioErr3 != nil {
  28329. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28331. return
  28332. }
  28333. var respJSON3 map[string]interface{}
  28334. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28335. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28337. return
  28338. }
  28339. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28340. userJSONBytes3, _ := json.Marshal(respJSON3)
  28341. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  28342. utils.ErrorLog("解析失败:%v", err)
  28343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28344. return
  28345. }
  28346. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  28347. res.Output = resSixteen10265.Output
  28348. res.ErrMsg = resSixteen10265.ErrMsg
  28349. res.Cainfo = resSixteen10265.Cainfo
  28350. res.WarnMsg = resSixteen10265.WarnMsg
  28351. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  28352. res.Infcode = infocode
  28353. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28354. var api3 string
  28355. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  28356. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28357. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28358. resp3, requestErr3 := http.Get(api3)
  28359. if requestErr3 != nil {
  28360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28361. return
  28362. }
  28363. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28364. if ioErr3 != nil {
  28365. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28367. return
  28368. }
  28369. var respJSON3 map[string]interface{}
  28370. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28371. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28373. return
  28374. }
  28375. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28376. userJSONBytes3, _ := json.Marshal(respJSON3)
  28377. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  28378. utils.ErrorLog("解析失败:%v", err)
  28379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28380. return
  28381. }
  28382. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  28383. res.Output = resSixteen10265.Output
  28384. res.ErrMsg = resSixteen10265.ErrMsg
  28385. res.Cainfo = resSixteen10265.Cainfo
  28386. res.WarnMsg = resSixteen10265.WarnMsg
  28387. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  28388. res.Infcode = infocode
  28389. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28390. 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)
  28391. var dat map[string]interface{}
  28392. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28393. fmt.Println(dat)
  28394. } else {
  28395. fmt.Println(err)
  28396. }
  28397. saveLog(result, src_resquest, "2208", "退费")
  28398. userJSONBytes, _ := json.Marshal(dat)
  28399. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28400. utils.ErrorLog("解析失败:%v", err)
  28401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28402. return
  28403. }
  28404. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28405. 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, "")
  28406. var dat map[string]interface{}
  28407. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28408. fmt.Println(dat)
  28409. } else {
  28410. fmt.Println(err)
  28411. }
  28412. saveLog(result, src_resquest, "2208", "退费")
  28413. userJSONBytes, _ := json.Marshal(dat)
  28414. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28415. utils.ErrorLog("解析失败:%v", err)
  28416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28417. return
  28418. }
  28419. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28420. var api3 string
  28421. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  28422. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28423. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28424. resp3, requestErr3 := http.Get(api3)
  28425. if requestErr3 != nil {
  28426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28427. return
  28428. }
  28429. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28430. if ioErr3 != nil {
  28431. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28433. return
  28434. }
  28435. var respJSON3 map[string]interface{}
  28436. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28437. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28439. return
  28440. }
  28441. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  28442. if status == "0" {
  28443. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  28444. c.ServeSuccessJSON(map[string]interface{}{
  28445. "failed_code": -10,
  28446. "msg": err_msg,
  28447. })
  28448. return
  28449. }
  28450. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28451. userJSONBytes3, _ := json.Marshal(respJSON3)
  28452. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28453. // utils.ErrorLog("解析失败:%v", err)
  28454. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28455. // return
  28456. //}
  28457. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  28458. utils.ErrorLog("解析失败:%v", err)
  28459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28460. return
  28461. }
  28462. res.InfRefmsgid = ahres.InfRefmsgid
  28463. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28464. // 创建对应的Time类型
  28465. t := time.UnixMilli(timestamp)
  28466. // 格式化成指定的日期字符串
  28467. str := t.Format("2006-01-02 15:04:05")
  28468. res.Output.Setlinfo.SetlTime = str
  28469. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  28470. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  28471. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28472. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  28473. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  28474. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  28475. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28476. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  28477. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  28478. //
  28479. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  28480. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  28481. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  28482. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28483. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  28484. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  28485. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  28486. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  28487. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  28488. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  28489. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28490. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  28491. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  28492. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  28493. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  28494. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  28495. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  28496. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  28497. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  28498. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  28499. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  28500. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  28501. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  28502. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  28503. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  28504. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  28505. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  28506. //res.Output.Setldetail = ahres.Output.Setldetail
  28507. res.ErrMsg = ahres.ErrMsg
  28508. res.Cainfo = ahres.Cainfo
  28509. res.WarnMsg = ahres.WarnMsg
  28510. res.Infcode = ahres.Infcode
  28511. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28512. 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, "")
  28513. var dat map[string]interface{}
  28514. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28515. fmt.Println(dat)
  28516. } else {
  28517. fmt.Println(err)
  28518. }
  28519. saveLog(result, src_resquest, "2208", "退费")
  28520. userJSONBytes, _ := json.Marshal(dat)
  28521. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28522. utils.ErrorLog("解析失败:%v", err)
  28523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28524. return
  28525. }
  28526. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28527. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  28528. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28529. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28530. resp3, requestErr3 := http.Get(api3)
  28531. if requestErr3 != nil {
  28532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28533. return
  28534. }
  28535. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28536. if ioErr3 != nil {
  28537. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28539. return
  28540. }
  28541. var respJSON3 map[string]interface{}
  28542. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28543. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28545. return
  28546. }
  28547. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28548. userJSONBytes3, _ := json.Marshal(respJSON3)
  28549. fmt.Println("log")
  28550. fmt.Println(string(userJSONBytes3))
  28551. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28552. utils.ErrorLog("解析失败:%v", err)
  28553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28554. return
  28555. }
  28556. } else {
  28557. if miConfig.Code == "H15049901371" {
  28558. 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)
  28559. var dat map[string]interface{}
  28560. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28561. fmt.Println(dat)
  28562. } else {
  28563. fmt.Println(err)
  28564. }
  28565. saveLog(result, src_resquest, "2208", "退费")
  28566. if strings.Contains(result, "Post") {
  28567. res.Infcode = -1
  28568. res.ErrMsg = result
  28569. }
  28570. userJSONBytes, _ := json.Marshal(dat)
  28571. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  28572. utils.ErrorLog("解析失败:%v", err)
  28573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28574. return
  28575. }
  28576. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  28577. res.Output = resSixteen10265.Output
  28578. res.ErrMsg = resSixteen10265.ErrMsg
  28579. res.Cainfo = resSixteen10265.Cainfo
  28580. res.WarnMsg = resSixteen10265.WarnMsg
  28581. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  28582. res.Infcode = infocode
  28583. } else {
  28584. 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)
  28585. var dat map[string]interface{}
  28586. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28587. fmt.Println(dat)
  28588. } else {
  28589. fmt.Println(err)
  28590. }
  28591. saveLog(result, src_resquest, "2208", "退费")
  28592. userJSONBytes, _ := json.Marshal(dat)
  28593. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28594. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  28595. utils.ErrorLog("解析失败:%v", err)
  28596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28597. return
  28598. }
  28599. res.Infcode = gz.Infcode
  28600. } else {
  28601. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28602. utils.ErrorLog("解析失败:%v", err)
  28603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28604. return
  28605. }
  28606. }
  28607. if strings.Contains(result, "Post") {
  28608. res.Infcode = -1
  28609. res.ErrMsg = result
  28610. }
  28611. }
  28612. }
  28613. if res.Infcode == -1 {
  28614. c.ServeSuccessJSON(map[string]interface{}{
  28615. "failed_code": -10,
  28616. "msg": res.ErrMsg,
  28617. })
  28618. return
  28619. }
  28620. if res.Infcode != -1 {
  28621. var res2 ResultSix
  28622. var resSix10265 ResultSix10265
  28623. if miConfig.MdtrtareaAdmvs == "421300" {
  28624. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  28625. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28626. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28627. resp3, requestErr3 := http.Get(api3)
  28628. if requestErr3 != nil {
  28629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28630. return
  28631. }
  28632. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28633. if ioErr3 != nil {
  28634. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28636. return
  28637. }
  28638. var respJSON3 map[string]interface{}
  28639. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28640. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28642. return
  28643. }
  28644. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28645. userJSONBytes3, _ := json.Marshal(respJSON3)
  28646. fmt.Println("log")
  28647. fmt.Println(string(userJSONBytes3))
  28648. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28649. utils.ErrorLog("解析失败:%v", err)
  28650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28651. return
  28652. }
  28653. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28654. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  28655. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28656. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28657. resp3, requestErr3 := http.Get(api3)
  28658. if requestErr3 != nil {
  28659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28660. return
  28661. }
  28662. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28663. if ioErr3 != nil {
  28664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28666. return
  28667. }
  28668. var respJSON3 map[string]interface{}
  28669. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28670. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28672. return
  28673. }
  28674. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28675. userJSONBytes3, _ := json.Marshal(respJSON3)
  28676. fmt.Println("log")
  28677. fmt.Println(string(userJSONBytes3))
  28678. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28679. utils.ErrorLog("解析失败:%v", err)
  28680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28681. return
  28682. }
  28683. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28684. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  28685. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28686. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28687. resp3, requestErr3 := http.Get(api3)
  28688. if requestErr3 != nil {
  28689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28690. return
  28691. }
  28692. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28693. if ioErr3 != nil {
  28694. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28696. return
  28697. }
  28698. var respJSON3 map[string]interface{}
  28699. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28700. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28702. return
  28703. }
  28704. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28705. userJSONBytes3, _ := json.Marshal(respJSON3)
  28706. fmt.Println("log")
  28707. fmt.Println(string(userJSONBytes3))
  28708. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28709. utils.ErrorLog("解析失败:%v", err)
  28710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28711. return
  28712. }
  28713. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28714. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  28715. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28716. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28717. resp3, requestErr3 := http.Get(api3)
  28718. if requestErr3 != nil {
  28719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28720. return
  28721. }
  28722. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28723. if ioErr3 != nil {
  28724. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28726. return
  28727. }
  28728. var respJSON3 map[string]interface{}
  28729. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28732. return
  28733. }
  28734. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28735. userJSONBytes3, _ := json.Marshal(respJSON3)
  28736. fmt.Println("log")
  28737. fmt.Println(string(userJSONBytes3))
  28738. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28739. utils.ErrorLog("解析失败:%v", err)
  28740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28741. return
  28742. }
  28743. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28744. var api3 string
  28745. if miConfig.MdtrtareaAdmvs == "320921" {
  28746. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  28747. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28748. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28749. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28750. } else {
  28751. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28752. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  28753. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28754. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28755. }
  28756. resp3, requestErr3 := http.Get(api3)
  28757. if requestErr3 != nil {
  28758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28759. return
  28760. }
  28761. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28762. if ioErr3 != nil {
  28763. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28765. return
  28766. }
  28767. var respJSON3 map[string]interface{}
  28768. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28769. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28771. return
  28772. }
  28773. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28774. userJSONBytes3, _ := json.Marshal(respJSON3)
  28775. fmt.Println("log")
  28776. fmt.Println(string(userJSONBytes3))
  28777. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  28778. utils.ErrorLog("解析失败:%v", err)
  28779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28780. return
  28781. }
  28782. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28783. res2.Output = resSix10265.Output
  28784. res2.ErrMsg = resSix10265.ErrMsg
  28785. res2.Cainfo = resSix10265.Cainfo
  28786. res2.WarnMsg = resSix10265.WarnMsg
  28787. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28788. res2.Infcode = infocode
  28789. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28790. var api3 string
  28791. new_chrg_bchno := order.Number
  28792. if adminUser.CurrentOrgId == 10265 {
  28793. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  28794. new_chrg_bchno = "0000"
  28795. }
  28796. }
  28797. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  28798. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28799. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28800. resp3, requestErr3 := http.Get(api3)
  28801. if requestErr3 != nil {
  28802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28803. return
  28804. }
  28805. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28806. if ioErr3 != nil {
  28807. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28809. return
  28810. }
  28811. var respJSON3 map[string]interface{}
  28812. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28813. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28815. return
  28816. }
  28817. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28818. userJSONBytes3, _ := json.Marshal(respJSON3)
  28819. fmt.Println("log")
  28820. fmt.Println(string(userJSONBytes3))
  28821. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  28822. utils.ErrorLog("解析失败:%v", err)
  28823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28824. return
  28825. }
  28826. res2.InfRefmsgid = resSix10265.InfRefmsgid
  28827. res2.Output = resSix10265.Output
  28828. res2.ErrMsg = resSix10265.ErrMsg
  28829. res2.Cainfo = resSix10265.Cainfo
  28830. res2.WarnMsg = resSix10265.WarnMsg
  28831. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28832. res2.Infcode = infocode
  28833. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28834. 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)
  28835. var dat map[string]interface{}
  28836. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28837. fmt.Println(dat)
  28838. } else {
  28839. fmt.Println(err)
  28840. }
  28841. saveLog(result2, src_request, "2205", "撤销明细")
  28842. userJSONBytes, _ := json.Marshal(dat)
  28843. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28844. utils.ErrorLog("解析失败:%v", err)
  28845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28846. return
  28847. }
  28848. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28849. 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, "")
  28850. var dat map[string]interface{}
  28851. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28852. fmt.Println(dat)
  28853. } else {
  28854. fmt.Println(err)
  28855. }
  28856. saveLog(result2, src_request, "2205", "撤销明细")
  28857. userJSONBytes, _ := json.Marshal(dat)
  28858. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28859. utils.ErrorLog("解析失败:%v", err)
  28860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28861. return
  28862. }
  28863. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28864. var api3 string
  28865. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  28866. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28867. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28868. resp3, requestErr3 := http.Get(api3)
  28869. if requestErr3 != nil {
  28870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28871. return
  28872. }
  28873. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28874. if ioErr3 != nil {
  28875. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28877. return
  28878. }
  28879. var respJSON3 map[string]interface{}
  28880. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28883. return
  28884. }
  28885. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  28886. if status == "0" {
  28887. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  28888. c.ServeSuccessJSON(map[string]interface{}{
  28889. "failed_code": -10,
  28890. "msg": err_msg,
  28891. })
  28892. return
  28893. }
  28894. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28895. userJSONBytes3, _ := json.Marshal(respJSON3)
  28896. fmt.Println("log")
  28897. fmt.Println(string(userJSONBytes3))
  28898. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28899. utils.ErrorLog("解析失败:%v", err)
  28900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28901. return
  28902. }
  28903. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28904. 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, "")
  28905. var dat map[string]interface{}
  28906. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28907. fmt.Println(dat)
  28908. } else {
  28909. fmt.Println(err)
  28910. }
  28911. saveLog(result2, src_request, "2205", "撤销明细")
  28912. userJSONBytes, _ := json.Marshal(dat)
  28913. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28914. utils.ErrorLog("解析失败:%v", err)
  28915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28916. return
  28917. }
  28918. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28919. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  28920. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  28921. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28922. resp3, requestErr3 := http.Get(api3)
  28923. if requestErr3 != nil {
  28924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28925. return
  28926. }
  28927. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  28928. if ioErr3 != nil {
  28929. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  28930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28931. return
  28932. }
  28933. var respJSON3 map[string]interface{}
  28934. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  28935. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28937. return
  28938. }
  28939. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28940. userJSONBytes3, _ := json.Marshal(respJSON3)
  28941. fmt.Println("log")
  28942. fmt.Println(string(userJSONBytes3))
  28943. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  28944. utils.ErrorLog("解析失败:%v", err)
  28945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28946. return
  28947. }
  28948. } else {
  28949. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28950. res2.Infcode = 0
  28951. } else {
  28952. 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)
  28953. var dat map[string]interface{}
  28954. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28955. fmt.Println(dat)
  28956. } else {
  28957. fmt.Println(err)
  28958. }
  28959. saveLog(result2, src_request, "2205", "撤销明细")
  28960. userJSONBytes, _ := json.Marshal(dat)
  28961. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28962. utils.ErrorLog("解析失败:%v", err)
  28963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28964. return
  28965. }
  28966. }
  28967. }
  28968. if res2.Infcode == -1 {
  28969. c.ServeSuccessJSON(map[string]interface{}{
  28970. "failed_code": -10,
  28971. "msg": res2.ErrMsg,
  28972. })
  28973. return
  28974. }
  28975. if res2.Infcode == 0 {
  28976. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  28977. if err == nil {
  28978. //当押金不为零时产生退费记录
  28979. if order.Decimal != 0 {
  28980. tmp := strconv.FormatInt(order.ID, 10)
  28981. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  28982. if err != nil {
  28983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28984. return
  28985. }
  28986. }
  28987. c.ServeSuccessJSON(map[string]interface{}{
  28988. "msg": "退费成功",
  28989. })
  28990. } else {
  28991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28992. return
  28993. }
  28994. } else {
  28995. c.ServeSuccessJSON(map[string]interface{}{
  28996. "failed_code": -10,
  28997. "msg": res2.ErrMsg,
  28998. })
  28999. }
  29000. } else {
  29001. c.ServeSuccessJSON(map[string]interface{}{
  29002. "failed_code": -10,
  29003. "msg": res.ErrMsg,
  29004. })
  29005. }
  29006. }
  29007. }
  29008. func (c *HisApiController) RefundNumber() {
  29009. record_time := c.GetString("record_time")
  29010. //patient_id, _ := c.GetInt64("patient_id")
  29011. admin_user_id, _ := c.GetInt64("admin_user_id")
  29012. his_patient_id, _ := c.GetInt64("id")
  29013. timeLayout := "2006-01-02"
  29014. loc, _ := time.LoadLocation("Local")
  29015. adminUser := c.GetAdminUserInfo()
  29016. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  29017. fmt.Println(err)
  29018. if err != nil {
  29019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29020. return
  29021. }
  29022. recordDateTime := theTime.Unix()
  29023. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  29024. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  29025. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  29026. //order, _ := service.GetHisOrderByID(order_id)
  29027. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29028. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29029. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29030. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  29031. if count > 0 {
  29032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  29033. return
  29034. }
  29035. if config.IsOpen == 1 { //对接了医保,走医保流程
  29036. var res2 ResultSix
  29037. var res3 GZResultSix
  29038. var resSix10265 ResultSix10265
  29039. if miConfig.MdtrtareaAdmvs == "421300" {
  29040. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  29041. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29042. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29043. resp3, requestErr3 := http.Get(api3)
  29044. if requestErr3 != nil {
  29045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29046. return
  29047. }
  29048. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29049. if ioErr3 != nil {
  29050. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29052. return
  29053. }
  29054. var respJSON3 map[string]interface{}
  29055. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29056. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29058. return
  29059. }
  29060. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29061. userJSONBytes3, _ := json.Marshal(respJSON3)
  29062. fmt.Println("log")
  29063. fmt.Println(string(userJSONBytes3))
  29064. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29065. utils.ErrorLog("解析失败:%v", err)
  29066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29067. return
  29068. }
  29069. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29070. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  29071. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29072. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29073. resp3, requestErr3 := http.Get(api3)
  29074. if requestErr3 != nil {
  29075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29076. return
  29077. }
  29078. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29079. if ioErr3 != nil {
  29080. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29082. return
  29083. }
  29084. var respJSON3 map[string]interface{}
  29085. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29086. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29088. return
  29089. }
  29090. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29091. userJSONBytes3, _ := json.Marshal(respJSON3)
  29092. fmt.Println("log")
  29093. fmt.Println(string(userJSONBytes3))
  29094. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29095. utils.ErrorLog("解析失败:%v", err)
  29096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29097. return
  29098. }
  29099. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29100. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  29101. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29102. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29103. resp3, requestErr3 := http.Get(api3)
  29104. if requestErr3 != nil {
  29105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29106. return
  29107. }
  29108. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29109. if ioErr3 != nil {
  29110. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29112. return
  29113. }
  29114. var respJSON3 map[string]interface{}
  29115. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29116. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29118. return
  29119. }
  29120. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29121. userJSONBytes3, _ := json.Marshal(respJSON3)
  29122. fmt.Println("log")
  29123. fmt.Println(string(userJSONBytes3))
  29124. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29125. utils.ErrorLog("解析失败:%v", err)
  29126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29127. return
  29128. }
  29129. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29130. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  29131. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29132. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29133. resp3, requestErr3 := http.Get(api3)
  29134. if requestErr3 != nil {
  29135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29136. return
  29137. }
  29138. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29139. if ioErr3 != nil {
  29140. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29142. return
  29143. }
  29144. var respJSON3 map[string]interface{}
  29145. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29148. return
  29149. }
  29150. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29151. userJSONBytes3, _ := json.Marshal(respJSON3)
  29152. fmt.Println("log")
  29153. fmt.Println(string(userJSONBytes3))
  29154. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29155. utils.ErrorLog("解析失败:%v", err)
  29156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29157. return
  29158. }
  29159. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29160. var api3 string
  29161. if miConfig.MdtrtareaAdmvs == "320921" {
  29162. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  29163. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29164. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29165. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29166. } else {
  29167. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29168. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  29169. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29170. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29171. }
  29172. resp3, requestErr3 := http.Get(api3)
  29173. if requestErr3 != nil {
  29174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29175. return
  29176. }
  29177. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29178. if ioErr3 != nil {
  29179. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29181. return
  29182. }
  29183. var respJSON3 map[string]interface{}
  29184. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29185. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29187. return
  29188. }
  29189. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29190. userJSONBytes3, _ := json.Marshal(respJSON3)
  29191. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  29192. utils.ErrorLog("解析失败:%v", err)
  29193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29194. return
  29195. }
  29196. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29197. res2.Output = resSix10265.Output
  29198. res2.ErrMsg = resSix10265.ErrMsg
  29199. res2.Cainfo = resSix10265.Cainfo
  29200. res2.WarnMsg = resSix10265.WarnMsg
  29201. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29202. res2.Infcode = infocode
  29203. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29204. var api3 string
  29205. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  29206. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29207. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29208. resp3, requestErr3 := http.Get(api3)
  29209. if requestErr3 != nil {
  29210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29211. return
  29212. }
  29213. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29214. if ioErr3 != nil {
  29215. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29217. return
  29218. }
  29219. var respJSON3 map[string]interface{}
  29220. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29221. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29223. return
  29224. }
  29225. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29226. userJSONBytes3, _ := json.Marshal(respJSON3)
  29227. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  29228. utils.ErrorLog("解析失败:%v", err)
  29229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29230. return
  29231. }
  29232. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29233. res2.Output = resSix10265.Output
  29234. res2.ErrMsg = resSix10265.ErrMsg
  29235. res2.Cainfo = resSix10265.Cainfo
  29236. res2.WarnMsg = resSix10265.WarnMsg
  29237. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29238. res2.Infcode = infocode
  29239. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29240. 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)
  29241. var dat map[string]interface{}
  29242. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29243. fmt.Println(dat)
  29244. } else {
  29245. fmt.Println(err)
  29246. }
  29247. saveLog(result, request, "2202", "退号")
  29248. userJSONBytes, _ := json.Marshal(dat)
  29249. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29250. utils.ErrorLog("解析失败:%v", err)
  29251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29252. return
  29253. }
  29254. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29255. 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, "")
  29256. var dat map[string]interface{}
  29257. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29258. fmt.Println(dat)
  29259. } else {
  29260. fmt.Println(err)
  29261. }
  29262. saveLog(result, request, "2202", "退号")
  29263. userJSONBytes, _ := json.Marshal(dat)
  29264. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29265. utils.ErrorLog("解析失败:%v", err)
  29266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29267. return
  29268. }
  29269. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29270. var api3 string
  29271. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  29272. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29273. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29274. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29275. resp3, requestErr3 := http.Get(api3)
  29276. if requestErr3 != nil {
  29277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29278. return
  29279. }
  29280. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29281. if ioErr3 != nil {
  29282. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29284. return
  29285. }
  29286. var respJSON3 map[string]interface{}
  29287. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29290. return
  29291. }
  29292. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  29293. if status == "0" {
  29294. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  29295. c.ServeSuccessJSON(map[string]interface{}{
  29296. "failed_code": -10,
  29297. "msg": err_msg,
  29298. })
  29299. return
  29300. }
  29301. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29302. userJSONBytes3, _ := json.Marshal(respJSON3)
  29303. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29304. utils.ErrorLog("解析失败:%v", err)
  29305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29306. return
  29307. }
  29308. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  29309. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29310. 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, "")
  29311. var dat map[string]interface{}
  29312. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29313. fmt.Println(dat)
  29314. } else {
  29315. fmt.Println(err)
  29316. }
  29317. saveLog(result, request, "2202", "退号")
  29318. userJSONBytes, _ := json.Marshal(dat)
  29319. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29320. utils.ErrorLog("解析失败:%v", err)
  29321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29322. return
  29323. }
  29324. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29325. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  29326. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29327. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  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. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29348. utils.ErrorLog("解析失败:%v", err)
  29349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29350. return
  29351. }
  29352. } else {
  29353. var api3 string
  29354. if miConfig.Code == "H15049901371" {
  29355. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  29356. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29357. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29358. } else {
  29359. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  29360. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29361. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  29362. }
  29363. resp3, requestErr3 := http.Get(api3)
  29364. if requestErr3 != nil {
  29365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29366. return
  29367. }
  29368. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29369. if ioErr3 != nil {
  29370. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29372. return
  29373. }
  29374. var respJSON3 map[string]interface{}
  29375. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29376. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29378. return
  29379. }
  29380. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29381. userJSONBytes3, _ := json.Marshal(respJSON3)
  29382. if miConfig.Code == "H15049901371" {
  29383. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  29384. utils.ErrorLog("解析失败:%v", err)
  29385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29386. return
  29387. }
  29388. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29389. res2.Output = resSix10265.Output
  29390. res2.ErrMsg = resSix10265.ErrMsg
  29391. res2.Cainfo = resSix10265.Cainfo
  29392. res2.WarnMsg = resSix10265.WarnMsg
  29393. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29394. res2.Infcode = infocode
  29395. } else {
  29396. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  29397. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  29398. utils.ErrorLog("解析失败:%v", err)
  29399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29400. return
  29401. }
  29402. res2.Infcode = res3.Infcode
  29403. } else {
  29404. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29405. utils.ErrorLog("解析失败:%v", err)
  29406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29407. return
  29408. }
  29409. }
  29410. }
  29411. }
  29412. if res2.Infcode == -1 {
  29413. c.ServeSuccessJSON(map[string]interface{}{
  29414. "failed_code": -10,
  29415. "msg": res2.ErrMsg,
  29416. })
  29417. return
  29418. }
  29419. if res2.Infcode == 0 {
  29420. if err == nil {
  29421. c.ServeSuccessJSON(map[string]interface{}{
  29422. "msg": "退号成功",
  29423. })
  29424. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  29425. } else {
  29426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29427. return
  29428. }
  29429. }
  29430. } else {
  29431. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  29432. //if err == nil {
  29433. // c.ServeSuccessJSON(map[string]interface{}{
  29434. // "msg": "退费成功",
  29435. // })
  29436. //} else {
  29437. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29438. // return
  29439. //}
  29440. }
  29441. }
  29442. func (c *HisApiController) RefundDetail() {
  29443. order_id, _ := c.GetInt64("order_id")
  29444. admin_user_id, _ := c.GetInt64("admin_user_id")
  29445. //his_patient_id, _ := c.GetInt64("his_patient_id")
  29446. number := c.GetString("number")
  29447. record_time := c.GetString("record_time")
  29448. patient_id, _ := c.GetInt64("patient_id")
  29449. //med_type, _ := c.GetInt64("med_type")
  29450. timeLayout := "2006-01-02"
  29451. loc, _ := time.LoadLocation("Local")
  29452. adminUser := c.GetAdminUserInfo()
  29453. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29454. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  29455. fmt.Println(err)
  29456. if err != nil {
  29457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29458. return
  29459. }
  29460. recordDateTime := theTime.Unix()
  29461. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29462. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  29463. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29464. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29465. var order models.HisOrder
  29466. order, _ = service.GetHisOrderByID(order_id)
  29467. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  29468. if config.IsOpen == 1 { //对接了医保,走医保流程
  29469. var res2 ResultSix
  29470. if miConfig.MdtrtareaAdmvs == "421300" {
  29471. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  29472. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29473. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29474. resp3, requestErr3 := http.Get(api3)
  29475. if requestErr3 != nil {
  29476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29477. return
  29478. }
  29479. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29480. if ioErr3 != nil {
  29481. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29483. return
  29484. }
  29485. var respJSON3 map[string]interface{}
  29486. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29487. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29489. return
  29490. }
  29491. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29492. userJSONBytes3, _ := json.Marshal(respJSON3)
  29493. fmt.Println("log")
  29494. fmt.Println(string(userJSONBytes3))
  29495. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29496. utils.ErrorLog("解析失败:%v", err)
  29497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29498. return
  29499. }
  29500. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29501. if err == nil {
  29502. c.ServeSuccessJSON(map[string]interface{}{
  29503. "msg": "撤销明细成功",
  29504. })
  29505. return
  29506. } else {
  29507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29508. return
  29509. }
  29510. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29511. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  29512. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29513. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29514. resp3, requestErr3 := http.Get(api3)
  29515. if requestErr3 != nil {
  29516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29517. return
  29518. }
  29519. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29520. if ioErr3 != nil {
  29521. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29523. return
  29524. }
  29525. var respJSON3 map[string]interface{}
  29526. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29527. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29529. return
  29530. }
  29531. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29532. userJSONBytes3, _ := json.Marshal(respJSON3)
  29533. fmt.Println("log")
  29534. fmt.Println(string(userJSONBytes3))
  29535. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29536. utils.ErrorLog("解析失败:%v", err)
  29537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29538. return
  29539. }
  29540. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29541. if err == nil {
  29542. c.ServeSuccessJSON(map[string]interface{}{
  29543. "msg": "撤销明细成功",
  29544. })
  29545. return
  29546. } else {
  29547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29548. return
  29549. }
  29550. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29551. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  29552. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29553. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29554. resp3, requestErr3 := http.Get(api3)
  29555. if requestErr3 != nil {
  29556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29557. return
  29558. }
  29559. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29560. if ioErr3 != nil {
  29561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29563. return
  29564. }
  29565. var respJSON3 map[string]interface{}
  29566. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29569. return
  29570. }
  29571. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29572. userJSONBytes3, _ := json.Marshal(respJSON3)
  29573. fmt.Println("log")
  29574. fmt.Println(string(userJSONBytes3))
  29575. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29576. utils.ErrorLog("解析失败:%v", err)
  29577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29578. return
  29579. }
  29580. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29581. if err == nil {
  29582. c.ServeSuccessJSON(map[string]interface{}{
  29583. "msg": "撤销明细成功",
  29584. })
  29585. return
  29586. } else {
  29587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29588. return
  29589. }
  29590. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29591. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  29592. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29593. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29594. resp3, requestErr3 := http.Get(api3)
  29595. if requestErr3 != nil {
  29596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29597. return
  29598. }
  29599. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29600. if ioErr3 != nil {
  29601. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29603. return
  29604. }
  29605. var respJSON3 map[string]interface{}
  29606. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29607. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29609. return
  29610. }
  29611. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29612. userJSONBytes3, _ := json.Marshal(respJSON3)
  29613. fmt.Println("log")
  29614. fmt.Println(string(userJSONBytes3))
  29615. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29616. utils.ErrorLog("解析失败:%v", err)
  29617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29618. return
  29619. }
  29620. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29621. if err == nil {
  29622. c.ServeSuccessJSON(map[string]interface{}{
  29623. "msg": "撤销明细成功",
  29624. })
  29625. return
  29626. } else {
  29627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29628. return
  29629. }
  29630. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29631. var resSix10265 ResultSix10265
  29632. var api3 string
  29633. if miConfig.MdtrtareaAdmvs == "320921" {
  29634. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  29635. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29636. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29637. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29638. } else {
  29639. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29640. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  29641. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29642. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29643. }
  29644. resp3, requestErr3 := http.Get(api3)
  29645. utils.ErrorLog("接口: %v", requestErr3)
  29646. if requestErr3 != nil {
  29647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29648. return
  29649. }
  29650. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29651. if ioErr3 != nil {
  29652. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29654. return
  29655. }
  29656. var respJSON3 map[string]interface{}
  29657. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29658. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29660. return
  29661. }
  29662. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29663. userJSONBytes3, _ := json.Marshal(respJSON3)
  29664. fmt.Println("log")
  29665. fmt.Println(string(userJSONBytes3))
  29666. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  29667. utils.ErrorLog("解析失败:%v", err)
  29668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29669. return
  29670. }
  29671. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29672. res2.Output = resSix10265.Output
  29673. res2.ErrMsg = resSix10265.ErrMsg
  29674. res2.Cainfo = resSix10265.Cainfo
  29675. res2.WarnMsg = resSix10265.WarnMsg
  29676. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29677. res2.Infcode = infocode
  29678. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29679. if err == nil {
  29680. c.ServeSuccessJSON(map[string]interface{}{
  29681. "msg": "撤销明细成功",
  29682. })
  29683. return
  29684. } else {
  29685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29686. return
  29687. }
  29688. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29689. var api3 string
  29690. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  29691. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29692. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29693. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  29694. resp3, requestErr3 := http.Get(api3)
  29695. utils.ErrorLog("接口: %v", requestErr3)
  29696. if requestErr3 != nil {
  29697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29698. return
  29699. }
  29700. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29701. if ioErr3 != nil {
  29702. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29704. return
  29705. }
  29706. var respJSON3 map[string]interface{}
  29707. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29708. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29710. return
  29711. }
  29712. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  29713. if status == "0" {
  29714. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  29715. c.ServeSuccessJSON(map[string]interface{}{
  29716. "failed_code": -10,
  29717. "msg": err_msg,
  29718. })
  29719. return
  29720. }
  29721. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29722. userJSONBytes3, _ := json.Marshal(respJSON3)
  29723. fmt.Println("log")
  29724. fmt.Println(string(userJSONBytes3))
  29725. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29726. utils.ErrorLog("解析失败:%v", err)
  29727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29728. return
  29729. }
  29730. fmt.Println(res2.Infcode)
  29731. if res2.Infcode == -1 {
  29732. c.ServeSuccessJSON(map[string]interface{}{
  29733. "failed_code": -10,
  29734. "msg": res2.ErrMsg,
  29735. })
  29736. return
  29737. }
  29738. if res2.Infcode == 0 {
  29739. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29740. if err == nil {
  29741. c.ServeSuccessJSON(map[string]interface{}{
  29742. "msg": "撤销明细成功",
  29743. })
  29744. return
  29745. } else {
  29746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29747. return
  29748. }
  29749. } else {
  29750. c.ServeSuccessJSON(map[string]interface{}{
  29751. "failed_code": -10,
  29752. "msg": res2.ErrMsg,
  29753. })
  29754. }
  29755. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29756. if err == nil {
  29757. c.ServeSuccessJSON(map[string]interface{}{
  29758. "msg": "撤销明细成功",
  29759. })
  29760. return
  29761. } else {
  29762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29763. return
  29764. }
  29765. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29766. var resSix10265 ResultSix10265
  29767. new_chrg_bchno := order.Number
  29768. if adminUser.CurrentOrgId == 10265 {
  29769. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  29770. new_chrg_bchno = "0000"
  29771. }
  29772. }
  29773. var api3 string
  29774. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  29775. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29776. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  29777. resp3, requestErr3 := http.Get(api3)
  29778. if requestErr3 != nil {
  29779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29780. return
  29781. }
  29782. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  29783. if ioErr3 != nil {
  29784. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  29785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29786. return
  29787. }
  29788. var respJSON3 map[string]interface{}
  29789. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  29790. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29792. return
  29793. }
  29794. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29795. userJSONBytes3, _ := json.Marshal(respJSON3)
  29796. fmt.Println("log")
  29797. fmt.Println(string(userJSONBytes3))
  29798. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  29799. utils.ErrorLog("解析失败:%v", err)
  29800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29801. return
  29802. }
  29803. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29804. res2.Output = resSix10265.Output
  29805. res2.ErrMsg = resSix10265.ErrMsg
  29806. res2.Cainfo = resSix10265.Cainfo
  29807. res2.WarnMsg = resSix10265.WarnMsg
  29808. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29809. res2.Infcode = infocode
  29810. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29811. if err == nil {
  29812. c.ServeSuccessJSON(map[string]interface{}{
  29813. "msg": "撤销明细成功",
  29814. })
  29815. return
  29816. } else {
  29817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29818. return
  29819. }
  29820. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29821. 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)
  29822. var dat map[string]interface{}
  29823. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29824. fmt.Println(dat)
  29825. } else {
  29826. fmt.Println(err)
  29827. }
  29828. saveLog(result2, src_request, "2205", "撤销明细")
  29829. userJSONBytes, _ := json.Marshal(dat)
  29830. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29831. utils.ErrorLog("解析失败:%v", err)
  29832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29833. return
  29834. }
  29835. if res2.Infcode == 0 {
  29836. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29837. if err == nil {
  29838. c.ServeSuccessJSON(map[string]interface{}{
  29839. "msg": "撤销明细成功",
  29840. })
  29841. return
  29842. } else {
  29843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29844. return
  29845. }
  29846. } else {
  29847. c.ServeSuccessJSON(map[string]interface{}{
  29848. "failed_code": -10,
  29849. "msg": res2.ErrMsg,
  29850. })
  29851. }
  29852. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29853. 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, "")
  29854. var dat map[string]interface{}
  29855. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29856. fmt.Println(dat)
  29857. } else {
  29858. fmt.Println(err)
  29859. }
  29860. saveLog(result2, src_request, "2205", "撤销明细")
  29861. userJSONBytes, _ := json.Marshal(dat)
  29862. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29863. utils.ErrorLog("解析失败:%v", err)
  29864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29865. return
  29866. }
  29867. if res2.Infcode == 0 {
  29868. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29869. if err == nil {
  29870. c.ServeSuccessJSON(map[string]interface{}{
  29871. "msg": "撤销明细成功",
  29872. })
  29873. return
  29874. } else {
  29875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29876. return
  29877. }
  29878. } else {
  29879. c.ServeSuccessJSON(map[string]interface{}{
  29880. "failed_code": -10,
  29881. "msg": res2.ErrMsg,
  29882. })
  29883. }
  29884. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29885. 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, "")
  29886. var dat map[string]interface{}
  29887. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29888. fmt.Println(dat)
  29889. } else {
  29890. fmt.Println(err)
  29891. }
  29892. saveLog(result2, src_request, "2205", "撤销明细")
  29893. userJSONBytes, _ := json.Marshal(dat)
  29894. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29895. utils.ErrorLog("解析失败:%v", err)
  29896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29897. return
  29898. }
  29899. if res2.Infcode == 0 {
  29900. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29901. if err == nil {
  29902. c.ServeSuccessJSON(map[string]interface{}{
  29903. "msg": "撤销明细成功",
  29904. })
  29905. return
  29906. } else {
  29907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29908. return
  29909. }
  29910. } else {
  29911. c.ServeSuccessJSON(map[string]interface{}{
  29912. "failed_code": -10,
  29913. "msg": res2.ErrMsg,
  29914. })
  29915. }
  29916. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29917. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  29918. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29919. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  29920. resp2, requestErr2 := http.Get(api2)
  29921. if requestErr2 != nil {
  29922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29923. return
  29924. }
  29925. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  29926. if ioErr2 != nil {
  29927. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  29928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29929. return
  29930. }
  29931. var respJSON2 map[string]interface{}
  29932. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  29933. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29935. return
  29936. }
  29937. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29938. userJSONBytes3, _ := json.Marshal(respJSON2)
  29939. fmt.Println("log")
  29940. fmt.Println(string(userJSONBytes3))
  29941. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29942. utils.ErrorLog("解析失败:%v", err)
  29943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29944. return
  29945. }
  29946. if res2.Infcode == 0 {
  29947. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29948. if err == nil {
  29949. c.ServeSuccessJSON(map[string]interface{}{
  29950. "msg": "撤销明细成功",
  29951. })
  29952. return
  29953. } else {
  29954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29955. return
  29956. }
  29957. } else {
  29958. c.ServeSuccessJSON(map[string]interface{}{
  29959. "failed_code": -10,
  29960. "msg": res2.ErrMsg,
  29961. })
  29962. }
  29963. } else {
  29964. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  29965. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  29966. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  29967. resp2, requestErr2 := http.Get(api2)
  29968. if requestErr2 != nil {
  29969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29970. return
  29971. }
  29972. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  29973. if ioErr2 != nil {
  29974. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  29975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29976. return
  29977. }
  29978. var respJSON2 map[string]interface{}
  29979. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  29980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29982. return
  29983. }
  29984. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29985. userJSONBytes3, _ := json.Marshal(respJSON2)
  29986. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  29987. utils.ErrorLog("解析失败:%v", err)
  29988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29989. return
  29990. }
  29991. if res2.Infcode == -1 {
  29992. c.ServeSuccessJSON(map[string]interface{}{
  29993. "failed_code": -10,
  29994. "msg": res2.ErrMsg,
  29995. })
  29996. return
  29997. } else {
  29998. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  29999. if err == nil {
  30000. c.ServeSuccessJSON(map[string]interface{}{
  30001. "msg": "撤销明细成功",
  30002. })
  30003. return
  30004. } else {
  30005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30006. return
  30007. }
  30008. }
  30009. }
  30010. } else {
  30011. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  30012. if err == nil {
  30013. c.ServeSuccessJSON(map[string]interface{}{
  30014. "msg": "退费成功",
  30015. })
  30016. } else {
  30017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30018. return
  30019. }
  30020. }
  30021. }
  30022. // 对账
  30023. func (c *HisApiController) GetCheckAccount() {
  30024. start_time := c.GetString("start_time")
  30025. end_time := c.GetString("end_time")
  30026. insutype := c.GetString("insutype")
  30027. clr_type := c.GetString("clr_type")
  30028. clr_org := c.GetString("clr_optins")
  30029. admin_user_id, _ := c.GetInt64("admin_user_id")
  30030. adminUser := c.GetAdminUserInfo()
  30031. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30032. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30033. if len(clr_org) == 0 {
  30034. clr_org = miConfig.InsuplcAdmdvs
  30035. }
  30036. timeLayout := "2006-01-02"
  30037. loc, _ := time.LoadLocation("Local")
  30038. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  30039. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  30040. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  30041. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  30042. fixmedins_setl_cnt := int64(len(orders))
  30043. var medfee_sumamt float64
  30044. var acct_pay float64
  30045. var fund_pay_sumamt float64
  30046. for _, item := range orders {
  30047. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30048. acct_pay = acct_pay + item.AcctPay
  30049. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  30050. }
  30051. var user_name string
  30052. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30053. if role.ID == 0 {
  30054. user_name = "xxx"
  30055. } else {
  30056. user_name = role.UserName
  30057. }
  30058. var res ResultEight
  30059. var res10188 ResultEightFor10188
  30060. if config.IsOpen == 1 {
  30061. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  30062. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  30063. "insutype=" + insutype +
  30064. "&clr_type=" + clr_type +
  30065. "&setl_optins=" + clr_org +
  30066. "&stmt_begndate=" + start_time +
  30067. "&stm_enddate=" + end_time +
  30068. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  30069. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  30070. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  30071. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  30072. "&fixmedins_code=" + miConfig.Code +
  30073. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30074. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30075. "&secret_key=" + miConfig.SecretKey +
  30076. "&org_name=" + miConfig.OrgName +
  30077. "&doctor=" + user_name +
  30078. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  30079. fmt.Println(api)
  30080. resp, requestErr := http.Get(api)
  30081. if requestErr != nil {
  30082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30083. return
  30084. }
  30085. body, ioErr := ioutil.ReadAll(resp.Body)
  30086. fmt.Println(body)
  30087. if ioErr != nil {
  30088. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30090. return
  30091. }
  30092. var respJSON map[string]interface{}
  30093. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30094. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30096. return
  30097. }
  30098. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30099. userJSONBytes, _ := json.Marshal(respJSON)
  30100. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30101. utils.ErrorLog("解析失败:%v", err)
  30102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30103. return
  30104. }
  30105. res.InfRefmsgid = res10188.InfRefmsgid
  30106. res.Output = res10188.Output
  30107. res.ErrMsg = res10188.ErrMsg
  30108. res.Cainfo = res10188.Cainfo
  30109. res.WarnMsg = res10188.WarnMsg
  30110. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  30111. res.Infcode = infocode
  30112. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30113. if clr_type != "9903" {
  30114. clr_type = "99" // 就诊 ID(来自2201接口返回)
  30115. }
  30116. if clr_type == "9903" {
  30117. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  30118. }
  30119. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  30120. "insutype=" + insutype +
  30121. "&clr_type=" + clr_type +
  30122. "&setl_optins=" + clr_org +
  30123. "&stmt_begndate=" + start_time +
  30124. "&stm_enddate=" + end_time +
  30125. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  30126. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  30127. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  30128. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  30129. "&fixmedins_code=" + miConfig.Code +
  30130. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30131. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30132. "&secret_key=" + miConfig.SecretKey +
  30133. "&org_name=" + miConfig.OrgName +
  30134. "&doctor=" + user_name
  30135. resp, requestErr := http.Get(api)
  30136. if requestErr != nil {
  30137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30138. return
  30139. }
  30140. body, ioErr := ioutil.ReadAll(resp.Body)
  30141. if ioErr != nil {
  30142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30144. return
  30145. }
  30146. var respJSON map[string]interface{}
  30147. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30150. return
  30151. }
  30152. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30153. result, _ := json.Marshal(respJSON)
  30154. fmt.Println("log")
  30155. fmt.Println(string(result))
  30156. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  30157. utils.ErrorLog("解析失败:%v", err)
  30158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30159. return
  30160. }
  30161. res.InfRefmsgid = res10188.InfRefmsgid
  30162. res.Output = res10188.Output
  30163. res.ErrMsg = res10188.ErrMsg
  30164. res.Cainfo = res10188.Cainfo
  30165. res.WarnMsg = res10188.WarnMsg
  30166. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  30167. res.Infcode = infocode
  30168. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30169. var baseParams models.BaseParams
  30170. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  30171. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  30172. baseParams.SecretKey = miConfig.SecretKey
  30173. baseParams.OrgName = miConfig.OrgName
  30174. baseParams.FixmedinsCode = miConfig.Code
  30175. baseParams.EncKey = miConfig.EncKey
  30176. baseParams.AppSecret = miConfig.AppSecret
  30177. baseParams.SignKey = miConfig.SignKey
  30178. baseParams.AppID = miConfig.Code
  30179. baseParams.Doctor = role.UserName
  30180. baseParams.RequestUrl = miConfig.Url
  30181. businessParams := models.BusinessParams{
  30182. Insutype: insutype,
  30183. ClrType: clr_type,
  30184. SetlOptins: clr_org,
  30185. StmtBegndate: start_time,
  30186. StmtEnddate: end_time,
  30187. MedfeeSumamt: medfee_sumamt,
  30188. FundPaySumamt: fund_pay_sumamt,
  30189. AcctPay: acct_pay,
  30190. FixmedinsSetlCnt: fixmedins_setl_cnt,
  30191. }
  30192. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  30193. fmt.Println(requestLog)
  30194. fmt.Println(result)
  30195. fmt.Println(err_msg)
  30196. var dat map[string]interface{}
  30197. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30198. fmt.Println(dat)
  30199. } else {
  30200. fmt.Println(err)
  30201. }
  30202. userJSONBytes, _ := json.Marshal(dat)
  30203. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30204. utils.ErrorLog("解析失败:%v", err)
  30205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30206. return
  30207. }
  30208. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30209. var baseParams models.BaseParams
  30210. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  30211. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  30212. baseParams.SecretKey = miConfig.SecretKey
  30213. baseParams.OrgName = miConfig.OrgName
  30214. baseParams.FixmedinsCode = miConfig.Code
  30215. baseParams.EncKey = miConfig.EncKey
  30216. baseParams.AppSecret = miConfig.AppSecret
  30217. baseParams.SignKey = miConfig.SignKey
  30218. baseParams.AppID = miConfig.Code
  30219. baseParams.Doctor = role.UserName
  30220. baseParams.RequestUrl = miConfig.Url
  30221. baseParams.AccessKey = miConfig.AccessKey
  30222. businessParams := models.BusinessParams{
  30223. Insutype: insutype,
  30224. ClrType: clr_type,
  30225. SetlOptins: "430822",
  30226. StmtBegndate: start_time,
  30227. StmtEnddate: end_time,
  30228. MedfeeSumamt: medfee_sumamt,
  30229. FundPaySumamt: fund_pay_sumamt,
  30230. AcctPay: acct_pay,
  30231. FixmedinsSetlCnt: fixmedins_setl_cnt,
  30232. }
  30233. 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)
  30234. fmt.Println(requestLog)
  30235. fmt.Println(result)
  30236. var dat map[string]interface{}
  30237. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30238. fmt.Println(dat)
  30239. } else {
  30240. fmt.Println(err)
  30241. }
  30242. userJSONBytes, _ := json.Marshal(dat)
  30243. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30244. utils.ErrorLog("解析失败:%v", err)
  30245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30246. return
  30247. }
  30248. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30249. var baseParams models.BaseParams
  30250. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  30251. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  30252. baseParams.SecretKey = miConfig.SecretKey
  30253. baseParams.OrgName = miConfig.OrgName
  30254. baseParams.FixmedinsCode = miConfig.Code
  30255. baseParams.EncKey = miConfig.EncKey
  30256. baseParams.AppSecret = miConfig.AppSecret
  30257. baseParams.SignKey = miConfig.SignKey
  30258. baseParams.AppID = miConfig.Code
  30259. baseParams.Doctor = role.UserName
  30260. baseParams.RequestUrl = miConfig.Url
  30261. businessParams := models.BusinessParams{
  30262. Insutype: insutype,
  30263. ClrType: clr_type,
  30264. SetlOptins: clr_org,
  30265. StmtBegndate: start_time,
  30266. StmtEnddate: end_time,
  30267. MedfeeSumamt: medfee_sumamt,
  30268. FundPaySumamt: fund_pay_sumamt,
  30269. AcctPay: acct_pay,
  30270. FixmedinsSetlCnt: fixmedins_setl_cnt,
  30271. }
  30272. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  30273. fmt.Println(requestLog)
  30274. fmt.Println(result)
  30275. fmt.Println(err_msg)
  30276. var dat map[string]interface{}
  30277. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30278. fmt.Println(dat)
  30279. } else {
  30280. fmt.Println(err)
  30281. }
  30282. userJSONBytes, _ := json.Marshal(dat)
  30283. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30284. utils.ErrorLog("解析失败:%v", err)
  30285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30286. return
  30287. }
  30288. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30289. if len(clr_type) == 0 {
  30290. clr_type = "11"
  30291. }
  30292. api := miConfig.Url + "gdyb/ten?" +
  30293. "insutype=" + insutype +
  30294. "&clr_type=" + clr_type +
  30295. "&setl_optins=" + clr_org +
  30296. "&stmt_begndate=" + start_time +
  30297. "&stm_enddate=" + end_time +
  30298. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  30299. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  30300. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  30301. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  30302. "&fixmedins_code=" + miConfig.Code +
  30303. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30304. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30305. "&secret_key=" + miConfig.SecretKey +
  30306. "&org_name=" + miConfig.OrgName +
  30307. "&doctor=" + user_name
  30308. fmt.Println(api)
  30309. resp, requestErr := http.Get(api)
  30310. if requestErr != nil {
  30311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30312. return
  30313. }
  30314. body, ioErr := ioutil.ReadAll(resp.Body)
  30315. fmt.Println(body)
  30316. if ioErr != nil {
  30317. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30319. return
  30320. }
  30321. var respJSON map[string]interface{}
  30322. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30323. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30325. return
  30326. }
  30327. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30328. userJSONBytes, _ := json.Marshal(respJSON)
  30329. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30330. utils.ErrorLog("解析失败:%v", err)
  30331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30332. return
  30333. }
  30334. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30335. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  30336. fixmedins_setl_cnt := int64(len(orders_two))
  30337. var medfee_sumamt float64
  30338. var acct_pay float64
  30339. var fund_pay_sumamt float64
  30340. for _, item := range orders_two {
  30341. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30342. acct_pay = acct_pay + item.AcctPay
  30343. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  30344. }
  30345. var baseParams models.BaseParams
  30346. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  30347. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  30348. baseParams.SecretKey = miConfig.SecretKey
  30349. baseParams.OrgName = miConfig.OrgName
  30350. baseParams.FixmedinsCode = miConfig.Code
  30351. baseParams.EncKey = miConfig.EncKey
  30352. baseParams.AppSecret = miConfig.AppSecret
  30353. baseParams.SignKey = miConfig.SignKey
  30354. baseParams.AppID = miConfig.Code
  30355. baseParams.Doctor = role.UserName
  30356. baseParams.RequestUrl = miConfig.Url
  30357. if clr_type == "9903" {
  30358. clr_type = "9994"
  30359. }
  30360. businessParams := models.BusinessParams{
  30361. Insutype: insutype,
  30362. ClrType: clr_type,
  30363. SetlOptins: "360302",
  30364. StmtBegndate: start_time,
  30365. StmtEnddate: end_time,
  30366. MedfeeSumamt: 0,
  30367. FundPaySumamt: 0,
  30368. AcctPay: 0,
  30369. FixmedinsSetlCnt: fixmedins_setl_cnt,
  30370. }
  30371. 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))
  30372. fmt.Println(requestLog)
  30373. fmt.Println(result)
  30374. var dat map[string]interface{}
  30375. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30376. fmt.Println(dat)
  30377. } else {
  30378. fmt.Println(err)
  30379. }
  30380. userJSONBytes, _ := json.Marshal(dat)
  30381. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30382. utils.ErrorLog("解析失败:%v", err)
  30383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30384. return
  30385. }
  30386. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30387. var api string
  30388. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  30389. "&clr_type=" + clr_type +
  30390. "&setl_optins=" + clr_org +
  30391. "&stmt_begndate=" + start_time +
  30392. "&stm_enddate=" + end_time +
  30393. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  30394. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  30395. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  30396. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  30397. "&fixmedins_code=" + miConfig.Code +
  30398. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30399. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30400. "&secret_key=" + miConfig.SecretKey +
  30401. "&org_name=" + miConfig.OrgName +
  30402. "&doctor=" + user_name + "&url=" + miConfig.Url
  30403. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30404. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30405. resp, requestErr := http.Get(api)
  30406. if requestErr != nil {
  30407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30408. return
  30409. }
  30410. body, ioErr := ioutil.ReadAll(resp.Body)
  30411. if ioErr != nil {
  30412. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30414. return
  30415. }
  30416. var respJSON map[string]interface{}
  30417. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30418. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30420. return
  30421. }
  30422. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30423. if status == "0" {
  30424. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30425. c.ServeSuccessJSON(map[string]interface{}{
  30426. "failed_code": -10,
  30427. "msg": err_msg,
  30428. })
  30429. return
  30430. }
  30431. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30432. userJSONBytes, _ := json.Marshal(respJSON)
  30433. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30434. utils.ErrorLog("解析失败:%v", err)
  30435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30436. return
  30437. }
  30438. } else {
  30439. if len(clr_type) == 0 {
  30440. clr_type = "11"
  30441. }
  30442. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  30443. "insutype=" + insutype +
  30444. "&clr_type=" + clr_type +
  30445. "&setl_optins=" + clr_org +
  30446. "&stmt_begndate=" + start_time +
  30447. "&stm_enddate=" + end_time +
  30448. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  30449. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  30450. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  30451. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  30452. "&fixmedins_code=" + miConfig.Code +
  30453. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30454. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30455. "&secret_key=" + miConfig.SecretKey +
  30456. "&org_name=" + miConfig.OrgName +
  30457. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  30458. fmt.Println(api)
  30459. resp, requestErr := http.Get(api)
  30460. if requestErr != nil {
  30461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30462. return
  30463. }
  30464. body, ioErr := ioutil.ReadAll(resp.Body)
  30465. fmt.Println(body)
  30466. if ioErr != nil {
  30467. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30469. return
  30470. }
  30471. var respJSON map[string]interface{}
  30472. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30475. return
  30476. }
  30477. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30478. userJSONBytes, _ := json.Marshal(respJSON)
  30479. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30480. utils.ErrorLog("解析失败:%v", err)
  30481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30482. return
  30483. }
  30484. }
  30485. if res.Infcode == 0 {
  30486. if res.Output.Stmtinfo.StmtRslt == "0" {
  30487. micc := &models.MedicalInsuranceCostCompare{
  30488. StartTime: startime.Unix(),
  30489. EndTime: endtime.Unix(),
  30490. Insutype: insutype,
  30491. CheckType: 1,
  30492. Num: fixmedins_setl_cnt,
  30493. Mtime: time.Now().Unix(),
  30494. Status: 1,
  30495. UserOrgId: adminUser.CurrentOrgId,
  30496. CostTotal: medfee_sumamt,
  30497. FuncTotal: fund_pay_sumamt,
  30498. PsnPay: acct_pay,
  30499. Creator: admin_user_id,
  30500. Ctime: time.Now().Unix(),
  30501. ClrType: clr_type,
  30502. }
  30503. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  30504. if err == nil {
  30505. c.ServeSuccessJSON(map[string]interface{}{
  30506. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  30507. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  30508. })
  30509. } else {
  30510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30511. }
  30512. } else {
  30513. c.ServeSuccessJSON(map[string]interface{}{
  30514. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  30515. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  30516. })
  30517. }
  30518. } else {
  30519. c.ServeSuccessJSON(map[string]interface{}{
  30520. "failed_code": -10,
  30521. "msg": res.ErrMsg,
  30522. })
  30523. }
  30524. }
  30525. }
  30526. func (c *HisApiController) Check310() {
  30527. adminUser := c.GetAdminUserInfo()
  30528. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30529. var user_name string
  30530. user_name = "高慧裕"
  30531. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  30532. "insutype=" + "310" +
  30533. "&clr_type=" + "" +
  30534. "&setl_optins=" + "441202" +
  30535. "&stmt_begndate=" + "2022-03-01" +
  30536. "&stm_enddate=" + "2022-03-31" +
  30537. "&medfee_sumamt=" + "194930.12" +
  30538. "&fund_pay_sumamt=" + "188741.46" +
  30539. "&acct_pay=" + "0" +
  30540. "&fixmedins_setl_cnt=" + "452" +
  30541. "&fixmedins_code=" + miConfig.Code +
  30542. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30543. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30544. "&secret_key=" + miConfig.SecretKey +
  30545. "&org_name=" + miConfig.OrgName +
  30546. "&doctor=" + user_name
  30547. fmt.Println(api)
  30548. resp, requestErr := http.Get(api)
  30549. if requestErr != nil {
  30550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30551. return
  30552. }
  30553. body, ioErr := ioutil.ReadAll(resp.Body)
  30554. fmt.Println(body)
  30555. if ioErr != nil {
  30556. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30558. return
  30559. }
  30560. var respJSON map[string]interface{}
  30561. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30562. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30564. return
  30565. }
  30566. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30567. userJSONBytes, _ := json.Marshal(respJSON)
  30568. var res ResultEight
  30569. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30570. utils.ErrorLog("解析失败:%v", err)
  30571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30572. return
  30573. }
  30574. }
  30575. func (c *HisApiController) Check390() {
  30576. adminUser := c.GetAdminUserInfo()
  30577. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30578. var user_name string
  30579. user_name = "高慧裕"
  30580. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  30581. "insutype=" + "390" +
  30582. "&clr_type=" + "" +
  30583. "&setl_optins=" + "441202" +
  30584. "&stmt_begndate=" + "2022-03-01" +
  30585. "&stm_enddate=" + "2022-03-31" +
  30586. "&medfee_sumamt=" + "1068448.89" +
  30587. "&fund_pay_sumamt=" + "1014677.62" +
  30588. "&acct_pay=" + "0" +
  30589. "&fixmedins_setl_cnt=" + "1950" +
  30590. "&fixmedins_code=" + miConfig.Code +
  30591. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30592. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30593. "&secret_key=" + miConfig.SecretKey +
  30594. "&org_name=" + miConfig.OrgName +
  30595. "&doctor=" + user_name
  30596. fmt.Println(api)
  30597. resp, requestErr := http.Get(api)
  30598. if requestErr != nil {
  30599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30600. return
  30601. }
  30602. body, ioErr := ioutil.ReadAll(resp.Body)
  30603. fmt.Println(body)
  30604. if ioErr != nil {
  30605. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30607. return
  30608. }
  30609. var respJSON map[string]interface{}
  30610. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30611. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30613. return
  30614. }
  30615. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30616. userJSONBytes, _ := json.Marshal(respJSON)
  30617. var res ResultEight
  30618. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30619. utils.ErrorLog("解析失败:%v", err)
  30620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30621. return
  30622. }
  30623. }
  30624. // 对账明细
  30625. func (c *HisApiController) GetCheckDetailAccount() {
  30626. start_time := c.GetString("start_time")
  30627. end_time := c.GetString("end_time")
  30628. admin_user_id, _ := c.GetInt64("admin_user_id")
  30629. adminUser := c.GetAdminUserInfo()
  30630. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30631. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30632. timeLayout := "2006-01-02"
  30633. loc, _ := time.LoadLocation("Local")
  30634. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  30635. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  30636. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  30637. rand.Seed(time.Now().UnixNano())
  30638. num := rand.Intn(30000)
  30639. Mkdir(miConfig.OrgName)
  30640. file := strconv.FormatInt(int64(num), 10)
  30641. file_name := file + ".txt"
  30642. zip_name := file + ".zip"
  30643. zip_path := miConfig.OrgName + "/" + zip_name
  30644. file_path := miConfig.OrgName + "/" + file_name
  30645. decimal.DivisionPrecision = 2
  30646. var medfee_sumamt float64
  30647. var psn_cash_pay float64
  30648. var fund_pay_sumamt float64
  30649. fixmedins_setl_cnt := int64(len(orders))
  30650. for _, item := range orders {
  30651. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30652. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  30653. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  30654. }
  30655. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  30656. defer f.Close()
  30657. if err != nil {
  30658. fmt.Println(err.Error())
  30659. } else {
  30660. for _, item := range orders {
  30661. var refd_setl_flag string
  30662. if item.OrderStatus == 2 {
  30663. refd_setl_flag = "0"
  30664. var str string
  30665. str = item.SetlId + " " +
  30666. item.MdtrtId + " " +
  30667. item.PsnNo + " " +
  30668. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  30669. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  30670. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  30671. _, err = f.Write([]byte(str))
  30672. }
  30673. if item.OrderStatus == 3 {
  30674. var str string
  30675. str = item.SetlId + " " +
  30676. item.MdtrtId + " " +
  30677. item.PsnNo + " " +
  30678. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  30679. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  30680. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  30681. _, err = f.Write([]byte(str))
  30682. var str2 string
  30683. str2 = item.SetlId + " " +
  30684. item.MdtrtId + " " +
  30685. item.PsnNo + " " +
  30686. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  30687. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  30688. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  30689. _, err = f.Write([]byte(str2))
  30690. }
  30691. }
  30692. }
  30693. Zip(file_path, zip_path)
  30694. fmt.Println(ReadFile(zip_path))
  30695. fmt.Println(string(ReadFile(zip_path)))
  30696. if config.IsOpen == 1 {
  30697. var user_name string
  30698. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30699. if role.ID == 0 {
  30700. user_name = "管理员"
  30701. } else {
  30702. user_name = role.UserName
  30703. }
  30704. baseParams := models.BaseParams{
  30705. SecretKey: miConfig.SecretKey,
  30706. FixmedinsCode: miConfig.Code,
  30707. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  30708. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  30709. OrgName: miConfig.OrgName,
  30710. Doctor: user_name,
  30711. }
  30712. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  30713. var dat map[string]interface{}
  30714. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30715. fmt.Println(dat)
  30716. } else {
  30717. fmt.Println(err)
  30718. }
  30719. userJSONBytes, _ := json.Marshal(dat)
  30720. var res ResultNine
  30721. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30722. utils.ErrorLog("解析失败:%v", err)
  30723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30724. return
  30725. }
  30726. if res.Infcode == 0 {
  30727. fileNo := res.Output.FileQuryNo
  30728. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  30729. "file_qury_no=" + fileNo +
  30730. "&setl_optins=" + "定点医保中心" +
  30731. "&stmt_begndate=" + start_time +
  30732. "&stm_enddate=" + end_time +
  30733. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  30734. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  30735. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  30736. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  30737. "&fixmedins_code=" + miConfig.Code +
  30738. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  30739. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  30740. "&secret_key=" + miConfig.SecretKey +
  30741. "&org_name=" + miConfig.OrgName +
  30742. "&doctor=" + user_name
  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. if ioErr != nil {
  30750. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30752. return
  30753. }
  30754. var respJSON map[string]interface{}
  30755. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30756. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30758. return
  30759. }
  30760. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30761. userJSONBytes, _ := json.Marshal(respJSON)
  30762. var res ResultTen
  30763. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30764. utils.ErrorLog("解析失败:%v", err)
  30765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30766. return
  30767. }
  30768. if res.Infcode == 0 {
  30769. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  30770. micc := &models.MedicalInsuranceCostCompare{
  30771. StartTime: startime.Unix(),
  30772. EndTime: endtime.Unix(),
  30773. Insutype: "0",
  30774. CheckType: 2,
  30775. Num: fixmedins_setl_cnt,
  30776. Mtime: time.Now().Unix(),
  30777. Status: 1,
  30778. UserOrgId: adminUser.CurrentOrgId,
  30779. CostTotal: medfee_sumamt,
  30780. FuncTotal: fund_pay_sumamt,
  30781. PsnPay: psn_cash_pay,
  30782. Creator: admin_user_id,
  30783. Ctime: time.Now().Unix(),
  30784. }
  30785. service.CreateMedicalInsuranceCostCompareRecord(micc)
  30786. c.ServeSuccessJSON(map[string]interface{}{
  30787. "msg": "明细对账成功",
  30788. })
  30789. }
  30790. } else {
  30791. }
  30792. }
  30793. }
  30794. type CustomOrderInfo struct {
  30795. Name string
  30796. Spec string
  30797. Unit string
  30798. Count float64
  30799. Price float64
  30800. Total float64
  30801. }
  30802. func (c *HisApiController) GetBatchSettleAccounts() {
  30803. admin_user_id, _ := c.GetInt64("admin_user_id")
  30804. order_ids := c.GetString("order_ids")
  30805. order_ids_arr := strings.Split(order_ids, ",")
  30806. data3 := []map[string]interface{}{}
  30807. for _, item := range order_ids_arr {
  30808. id, _ := strconv.ParseInt(item, 10, 64)
  30809. order_id := id
  30810. adminUser := c.GetAdminUserInfo()
  30811. order, _ := service.GetHisOrderByID(order_id)
  30812. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  30813. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  30814. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  30815. orderInfos = append(orderInfos, orderInfos_two...)
  30816. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  30817. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  30818. var diagnosis_ids []string
  30819. if his.ID > 0 {
  30820. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  30821. } else {
  30822. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  30823. }
  30824. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  30825. var dia_config []*models.HisXtDiagnoseConfig
  30826. var name string
  30827. for _, item := range diagnosis_ids {
  30828. id, _ := strconv.ParseInt(item, 10, 64)
  30829. diagnosisConfig, _ := service.FindDiagnoseById(id)
  30830. dia_config = append(dia_config, &diagnosisConfig)
  30831. if len(name) == 0 {
  30832. name = diagnosisConfig.ClassName
  30833. }
  30834. //} else {
  30835. // name = name + "," + diagnosisConfig.ClassName
  30836. //}
  30837. }
  30838. var bedCostTotal float64 = 0 //床位总费
  30839. var bedCostSelfTotal float64 = 0 //床位自费
  30840. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  30841. var bedSelfTotal float64 = 0 //床位部分项目自费
  30842. var bedInscpTotal float64 = 0 //床位部分项目自费
  30843. var operationCostTotal float64 = 0 //手术费
  30844. var operationCostSelfTotal float64 = 0 //手术费
  30845. var operationCostPartSelfTotal float64 = 0 //手术费
  30846. var operationSelfTotal float64 = 0 //床位部分项目自费
  30847. var operationInscpTotal float64 = 0 //床位部分项目自费
  30848. var otherCostTotal float64 = 0 //其他费用
  30849. var otherCostSelfTotal float64 = 0 //其他费用
  30850. var otherCostPartSelfTotal float64 = 0 //其他费用
  30851. var otherSelfTotal float64 = 0 //床位部分项目自费
  30852. var otherInscpTotal float64 = 0 //床位部分项目自费
  30853. var materialCostTotal float64 = 0 //材料费
  30854. var materialCostSelfTotal float64 = 0 //材料费
  30855. var materialCostPartSelfTotal float64 = 0 //材料费
  30856. var materialSelfTotal float64 = 0 //床位部分项目自费
  30857. var materialInscpTotal float64 = 0 //床位部分项目自费
  30858. var westernMedicineCostTotal float64 = 0 //西药费
  30859. var westernMedicineCostSelfTotal float64 = 0 //西药费
  30860. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  30861. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  30862. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  30863. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  30864. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  30865. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  30866. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  30867. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  30868. var checkCostTotal float64 = 0 //检查费
  30869. var checkCostSelfTotal float64 = 0 //检查费
  30870. var checkCostPartSelfTotal float64 = 0 //检查费
  30871. var checkSelfTotal float64 = 0 //床位部分项目自费
  30872. var checkInscpTotal float64 = 0 //床位部分项目自费
  30873. var laboratoryCostTotal float64 = 0 //化验费
  30874. var laboratoryCostSelfTotal float64 = 0 //化验费
  30875. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  30876. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  30877. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  30878. var treatCostTotal float64 = 0 //治疗费用
  30879. var treatCostSelfTotal float64 = 0 //治疗费用
  30880. var treatCostPartSelfTotal float64 = 0 //治疗费用
  30881. var treatSelfTotal float64 = 0 //床位部分项目自费
  30882. var treatInscpTotal float64 = 0 //床位部分项目自费
  30883. decimal.DivisionPrecision = 2
  30884. for _, item := range orderInfos {
  30885. if item.MedChrgitmType == "01" { //床位费
  30886. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30887. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30888. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30889. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30890. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30891. }
  30892. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  30893. if item.MedChrgitmType == "03" { //检查费
  30894. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30895. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30896. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30897. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30898. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30899. }
  30900. } else {
  30901. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  30902. fmt.Println("------------")
  30903. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30904. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30905. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30906. }
  30907. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  30908. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30909. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30910. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30911. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30912. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30913. }
  30914. }
  30915. if item.MedChrgitmType == "04" { //化验费
  30916. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30917. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30918. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30919. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30920. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30921. }
  30922. if item.MedChrgitmType == "05" { //治疗费
  30923. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30924. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30925. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30926. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30927. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30928. }
  30929. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  30930. fmt.Println("------------")
  30931. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30932. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30933. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30934. }
  30935. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  30936. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30937. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30938. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30939. }
  30940. //if item.MedChrgitmType == "06" { //手术费
  30941. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30942. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30943. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30944. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30945. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30946. //
  30947. //}
  30948. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  30949. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30950. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30951. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30952. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30953. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30954. }
  30955. if item.MedChrgitmType == "09" { //西药费
  30956. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30957. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30958. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30959. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30960. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30961. }
  30962. if item.MedChrgitmType == "11" { //中成费
  30963. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30964. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30965. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30966. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30967. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30968. }
  30969. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  30970. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  30971. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  30972. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  30973. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  30974. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  30975. }
  30976. }
  30977. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30978. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30979. var user_name string
  30980. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30981. if role.ID == 0 {
  30982. user_name = "管理员"
  30983. } else {
  30984. user_name = role.UserName
  30985. }
  30986. baseParams := models.BaseParams{
  30987. SecretKey: miConfig.SecretKey,
  30988. FixmedinsCode: miConfig.Code,
  30989. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  30990. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  30991. OrgName: miConfig.OrgName,
  30992. Doctor: user_name,
  30993. RequestUrl: miConfig.Url,
  30994. AccessKey: miConfig.AccessKey,
  30995. }
  30996. businessParams := models.BusinessParams{
  30997. PsnNo: order.PsnNo,
  30998. MdtrtId: order.MdtrtId,
  30999. SetlId: order.SetlId,
  31000. }
  31001. var res ResultEleven
  31002. var resEleven10265 ResultEleven10265
  31003. if config.IsOpen == 1 {
  31004. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  31005. result := service.Gdyb5203(baseParams, businessParams)
  31006. service.Gdyb5204(baseParams, businessParams)
  31007. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  31008. var dat map[string]interface{}
  31009. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31010. fmt.Println(dat)
  31011. } else {
  31012. fmt.Println(err)
  31013. }
  31014. userJSONBytes, _ := json.Marshal(dat)
  31015. if miConfig.Code == "H15049901371" {
  31016. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  31017. utils.ErrorLog("解析失败:%v", err)
  31018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31019. return
  31020. }
  31021. res.InfRefmsgid = resEleven10265.InfRefmsgid
  31022. res.Output = resEleven10265.Output
  31023. res.ErrMsg = resEleven10265.ErrMsg
  31024. res.Cainfo = resEleven10265.Cainfo
  31025. res.WarnMsg = resEleven10265.WarnMsg
  31026. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  31027. res.Infcode = infocode
  31028. } else {
  31029. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31030. utils.ErrorLog("解析失败:%v", err)
  31031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31032. return
  31033. }
  31034. }
  31035. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31036. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  31037. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  31038. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  31039. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  31040. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31041. var doctor_name string
  31042. if roles.ID == 0 {
  31043. doctor_name = "管理员"
  31044. } else {
  31045. doctor_name = roles.UserName
  31046. }
  31047. yiliao_leibie := ""
  31048. switch order.MedType {
  31049. case "11":
  31050. yiliao_leibie = "普通门诊"
  31051. break
  31052. case "12":
  31053. yiliao_leibie = "门诊挂号"
  31054. break
  31055. case "13":
  31056. yiliao_leibie = "急诊"
  31057. break
  31058. case "14":
  31059. yiliao_leibie = "门诊特殊病"
  31060. break
  31061. case "15":
  31062. yiliao_leibie = "门诊统筹"
  31063. break
  31064. case "16":
  31065. yiliao_leibie = "门诊慢性病"
  31066. break
  31067. case "21":
  31068. yiliao_leibie = "普通住院"
  31069. break
  31070. }
  31071. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  31072. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  31073. if res.Infcode == 0 {
  31074. data2 := map[string]interface{}{
  31075. "diagnosis": name,
  31076. "order_infos": orderInfos,
  31077. "number": order.MdtrtId,
  31078. "date": order.SettleAccountsDate,
  31079. "charge_admin": charge_admin,
  31080. "printor_admin": printor_admin,
  31081. "info": res.Output.Setlinfo,
  31082. "order": order,
  31083. "bedCostTotal": bedCostTotal,
  31084. "bedCostSelfTotal": bedCostSelfTotal,
  31085. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  31086. "bedSelfTotal": bedSelfTotal,
  31087. "bedInscpTotal": bedInscpTotal,
  31088. "operationCostTotal": operationCostTotal,
  31089. "operationCostSelfTotal": operationCostSelfTotal,
  31090. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  31091. "operationSelfTotal": operationSelfTotal,
  31092. "operationInscpTotal": operationInscpTotal,
  31093. "otherCostTotal": otherCostTotal,
  31094. "otherCostSelfTotal": otherCostSelfTotal,
  31095. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  31096. "otherSelfTotal": otherSelfTotal,
  31097. "otherInscpTotal": otherInscpTotal,
  31098. "materialCostTotal": materialCostTotal,
  31099. "materialCostSelfTotal": materialCostSelfTotal,
  31100. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  31101. "materialSelfTotal": materialSelfTotal,
  31102. "materialInscpTotal": materialInscpTotal,
  31103. "westernMedicineCostTotal": westernMedicineCostTotal,
  31104. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  31105. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  31106. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  31107. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  31108. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  31109. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  31110. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  31111. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  31112. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  31113. "checkCostTotal": checkCostTotal,
  31114. "checkCostSelfTotal": checkCostSelfTotal,
  31115. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  31116. "checkSelfTotal": checkSelfTotal,
  31117. "checkInscpTotal": checkInscpTotal,
  31118. "laboratoryCostTotal": laboratoryCostTotal,
  31119. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  31120. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  31121. "laboratorySelfTotal": laboratorySelfTotal,
  31122. "laboratoryInscpTotal": laboratoryInscpTotal,
  31123. "treatCostTotal": treatCostTotal,
  31124. "treatCostSelfTotal": treatCostSelfTotal,
  31125. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  31126. "treatSelfTotal": treatSelfTotal,
  31127. "treatInscpTotal": treatInscpTotal,
  31128. "doctor_info": doctor_info,
  31129. "doctor_code": adminRole_two.DoctorCode,
  31130. "doctor_name": doctor_name,
  31131. "health_card_no": order.PsnNo,
  31132. "department": departments.Name,
  31133. "yiliao_leibie": yiliao_leibie,
  31134. "after_money": order.AccountPrice,
  31135. "patient": patient,
  31136. "org_name": miConfig.OrgName,
  31137. "org_code": miConfig.Code,
  31138. "order_number": order.Number,
  31139. "his_hospital": his_hospital,
  31140. "his": his,
  31141. "dia_config": dia_config,
  31142. "psn_cash_pay": order.PsnCashPay,
  31143. //"check_order_info": cus_slice,
  31144. }
  31145. data3 = append(data3, data2)
  31146. }
  31147. }
  31148. }
  31149. c.ServeSuccessJSON(map[string]interface{}{
  31150. "infos": data3,
  31151. })
  31152. }
  31153. func (c *HisApiController) GetSettleAccounts() {
  31154. //id, _ := c.GetInt64("id")
  31155. //record_time := c.GetString("record_time")
  31156. order_id, _ := c.GetInt64("order_id")
  31157. admin_user_id, _ := c.GetInt64("admin_user_id")
  31158. //timeLayout := "2006-01-02"
  31159. //loc, _ := time.LoadLocation("Local")
  31160. //
  31161. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  31162. //if err != nil {
  31163. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  31164. // return
  31165. //}Hbyb5203
  31166. //recordDateTime := theTime.Unix()
  31167. adminUser := c.GetAdminUserInfo()
  31168. order, _ := service.GetHisOrderByID(order_id)
  31169. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  31170. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  31171. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  31172. orderInfos = append(orderInfos, orderInfos_two...)
  31173. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  31174. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  31175. var diagnosis_ids []string
  31176. if his.ID > 0 {
  31177. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  31178. } else {
  31179. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  31180. }
  31181. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  31182. var dia_config []*models.HisXtDiagnoseConfig
  31183. var name string
  31184. for _, item := range diagnosis_ids {
  31185. id, _ := strconv.ParseInt(item, 10, 64)
  31186. diagnosisConfig, _ := service.FindDiagnoseById(id)
  31187. dia_config = append(dia_config, &diagnosisConfig)
  31188. if len(name) == 0 {
  31189. name = diagnosisConfig.ClassName
  31190. } else {
  31191. name = name + "," + diagnosisConfig.ClassName
  31192. }
  31193. }
  31194. if patient.UserOrgId == 10215 {
  31195. name = "慢性肾功能不全(血透治疗)"
  31196. }
  31197. var bedCostTotal float64 = 0 //床位总费
  31198. var bedCostSelfTotal float64 = 0 //床位自费
  31199. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  31200. var bedSelfTotal float64 = 0 //床位部分项目自费
  31201. var bedInscpTotal float64 = 0 //床位部分项目自费
  31202. var operationCostTotal float64 = 0 //手术费
  31203. var operationCostSelfTotal float64 = 0 //手术费
  31204. var operationCostPartSelfTotal float64 = 0 //手术费
  31205. var operationSelfTotal float64 = 0 //床位部分项目自费
  31206. var operationInscpTotal float64 = 0 //床位部分项目自费
  31207. var otherCostTotal float64 = 0 //其他费用
  31208. var otherCostSelfTotal float64 = 0 //其他费用
  31209. var otherCostPartSelfTotal float64 = 0 //其他费用
  31210. var otherSelfTotal float64 = 0 //床位部分项目自费
  31211. var otherInscpTotal float64 = 0 //床位部分项目自费
  31212. var materialCostTotal float64 = 0 //材料费
  31213. var materialCostSelfTotal float64 = 0 //材料费
  31214. var materialCostPartSelfTotal float64 = 0 //材料费
  31215. var materialSelfTotal float64 = 0 //床位部分项目自费
  31216. var materialInscpTotal float64 = 0 //床位部分项目自费
  31217. var westernMedicineCostTotal float64 = 0 //西药费
  31218. var westernMedicineCostSelfTotal float64 = 0 //西药费
  31219. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  31220. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  31221. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  31222. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  31223. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  31224. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  31225. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  31226. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  31227. var checkCostTotal float64 = 0 //检查费
  31228. var checkCostSelfTotal float64 = 0 //检查费
  31229. var checkCostPartSelfTotal float64 = 0 //检查费
  31230. var checkSelfTotal float64 = 0 //床位部分项目自费
  31231. var checkInscpTotal float64 = 0 //床位部分项目自费
  31232. var laboratoryCostTotal float64 = 0 //化验费
  31233. var laboratoryCostSelfTotal float64 = 0 //化验费
  31234. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  31235. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  31236. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  31237. var treatCostTotal float64 = 0 //治疗费用
  31238. var treatCostSelfTotal float64 = 0 //治疗费用
  31239. var treatCostPartSelfTotal float64 = 0 //治疗费用
  31240. var treatSelfTotal float64 = 0 //床位部分项目自费
  31241. var treatInscpTotal float64 = 0 //床位部分项目自费
  31242. var zcCostTotal float64 = 0 //治疗费用
  31243. var zcCostSelfTotal float64 = 0 //治疗费用
  31244. var zcCostPartSelfTotal float64 = 0 //治疗费用
  31245. var zcSelfTotal float64 = 0 //床位部分项目自费
  31246. var zcInscpTotal float64 = 0 //床位部分项目自费
  31247. var huliCostTotal float64 = 0 //治疗费用
  31248. var huliCostSelfTotal float64 = 0 //治疗费用
  31249. var huliCostPartSelfTotal float64 = 0 //治疗费用
  31250. var huliSelfTotal float64 = 0 //床位部分项目自费
  31251. var huliInscpTotal float64 = 0 //床位部分项目自费
  31252. decimal.DivisionPrecision = 2
  31253. for _, item := range orderInfos {
  31254. if item.MedChrgitmType == "01" { //床位费
  31255. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31256. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31257. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31258. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31259. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31260. }
  31261. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  31262. if item.MedChrgitmType == "03" { //检查费
  31263. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31264. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31265. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31266. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31267. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31268. }
  31269. } else {
  31270. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  31271. fmt.Println("------------")
  31272. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31273. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31274. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31275. }
  31276. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  31277. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31278. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31279. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31280. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31281. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31282. }
  31283. }
  31284. if item.MedChrgitmType == "04" { //化验费
  31285. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31286. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31287. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31288. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31289. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31290. }
  31291. if item.MedChrgitmType == "05" { //治疗费
  31292. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31293. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31294. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31295. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31296. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31297. }
  31298. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  31299. fmt.Println("------------")
  31300. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31301. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31302. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31303. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31304. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31305. }
  31306. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  31307. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31308. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31309. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31310. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31311. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31312. }
  31313. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  31314. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31315. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31316. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31317. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31318. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31319. }
  31320. if item.MedChrgitmType == "09" { //西药费
  31321. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31322. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31323. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31324. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31325. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31326. }
  31327. if item.MedChrgitmType == "11" { //中成费
  31328. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31329. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31330. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31331. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31332. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31333. }
  31334. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  31335. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31336. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31337. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31338. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31339. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31340. }
  31341. if item.MedChrgitmType == "02" { //其他费
  31342. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31343. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31344. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31345. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31346. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31347. }
  31348. if item.MedChrgitmType == "07" { //其他费
  31349. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  31350. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  31351. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  31352. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  31353. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  31354. }
  31355. }
  31356. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31357. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31358. var user_name string
  31359. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31360. if role.ID == 0 {
  31361. user_name = "管理员"
  31362. } else {
  31363. user_name = role.UserName
  31364. }
  31365. baseParams := models.BaseParams{
  31366. SecretKey: miConfig.SecretKey,
  31367. FixmedinsCode: miConfig.Code,
  31368. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  31369. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  31370. OrgName: miConfig.OrgName,
  31371. Doctor: user_name,
  31372. RequestUrl: miConfig.Url,
  31373. AccessKey: miConfig.AccessKey,
  31374. }
  31375. businessParams := models.BusinessParams{
  31376. PsnNo: order.PsnNo,
  31377. MdtrtId: order.MdtrtId,
  31378. SetlId: order.SetlId,
  31379. }
  31380. var res ResultEleven
  31381. var resah ResultElevenah
  31382. var resEleven10265 ResultEleven10265
  31383. if config.IsOpen == 1 {
  31384. if miConfig.MdtrtareaAdmvs == "421300" {
  31385. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31386. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31387. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31388. resp, requestErr := http.Get(api)
  31389. if requestErr != nil {
  31390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31391. return
  31392. }
  31393. body, ioErr := ioutil.ReadAll(resp.Body)
  31394. if ioErr != nil {
  31395. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31397. return
  31398. }
  31399. var respJSON map[string]interface{}
  31400. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31401. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31403. return
  31404. }
  31405. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31406. result, _ := json.Marshal(respJSON)
  31407. fmt.Println("log")
  31408. fmt.Println(string(result))
  31409. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31410. utils.ErrorLog("解析失败:%v", err)
  31411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31412. return
  31413. }
  31414. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31415. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31416. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31417. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31418. resp, requestErr := http.Get(api)
  31419. if requestErr != nil {
  31420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31421. return
  31422. }
  31423. body, ioErr := ioutil.ReadAll(resp.Body)
  31424. if ioErr != nil {
  31425. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31427. return
  31428. }
  31429. var respJSON map[string]interface{}
  31430. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31431. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31433. return
  31434. }
  31435. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31436. result, _ := json.Marshal(respJSON)
  31437. fmt.Println("log")
  31438. fmt.Println(string(result))
  31439. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31440. utils.ErrorLog("解析失败:%v", err)
  31441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31442. return
  31443. }
  31444. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31445. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31446. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31447. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31448. resp, requestErr := http.Get(api)
  31449. if requestErr != nil {
  31450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31451. return
  31452. }
  31453. body, ioErr := ioutil.ReadAll(resp.Body)
  31454. if ioErr != nil {
  31455. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31457. return
  31458. }
  31459. var respJSON map[string]interface{}
  31460. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31461. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31463. return
  31464. }
  31465. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31466. result, _ := json.Marshal(respJSON)
  31467. fmt.Println("log")
  31468. fmt.Println(string(result))
  31469. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31470. utils.ErrorLog("解析失败:%v", err)
  31471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31472. return
  31473. }
  31474. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31475. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31476. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31477. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  31478. resp, requestErr := http.Get(api)
  31479. if requestErr != nil {
  31480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31481. return
  31482. }
  31483. body, ioErr := ioutil.ReadAll(resp.Body)
  31484. if ioErr != nil {
  31485. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31487. return
  31488. }
  31489. var respJSON map[string]interface{}
  31490. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31491. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31493. return
  31494. }
  31495. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31496. result, _ := json.Marshal(respJSON)
  31497. fmt.Println("log")
  31498. fmt.Println(string(result))
  31499. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31500. utils.ErrorLog("解析失败:%v", err)
  31501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31502. return
  31503. }
  31504. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  31505. var api string
  31506. if miConfig.MdtrtareaAdmvs == "320921" {
  31507. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31508. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31509. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31510. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31511. } else {
  31512. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31513. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31514. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31515. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31516. }
  31517. resp, requestErr := http.Get(api)
  31518. if requestErr != nil {
  31519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31520. return
  31521. }
  31522. body, ioErr := ioutil.ReadAll(resp.Body)
  31523. if ioErr != nil {
  31524. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31526. return
  31527. }
  31528. var respJSON map[string]interface{}
  31529. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31530. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31532. return
  31533. }
  31534. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31535. result, _ := json.Marshal(respJSON)
  31536. fmt.Println("log")
  31537. fmt.Println(string(result))
  31538. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  31539. utils.ErrorLog("解析失败:%v", err)
  31540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31541. return
  31542. }
  31543. res.InfRefmsgid = resEleven10265.InfRefmsgid
  31544. res.Output = resEleven10265.Output
  31545. res.ErrMsg = resEleven10265.ErrMsg
  31546. res.Cainfo = resEleven10265.Cainfo
  31547. res.WarnMsg = resEleven10265.WarnMsg
  31548. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  31549. res.Infcode = infocode
  31550. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31551. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  31552. saveLog(result, requestLog, "5203", "结算单")
  31553. var dat map[string]interface{}
  31554. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31555. fmt.Println(dat)
  31556. } else {
  31557. fmt.Println(err)
  31558. }
  31559. userJSONBytes, _ := json.Marshal(dat)
  31560. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31561. utils.ErrorLog("解析失败:%v", err)
  31562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31563. return
  31564. }
  31565. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31566. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  31567. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  31568. fmt.Println(result3)
  31569. fmt.Println(requestLog3)
  31570. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  31571. fmt.Println(result2)
  31572. fmt.Println(requestLog2)
  31573. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  31574. saveLog(result, requestLog, "5203", "结算单")
  31575. var dat map[string]interface{}
  31576. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31577. fmt.Println(dat)
  31578. } else {
  31579. fmt.Println(err)
  31580. }
  31581. userJSONBytes, _ := json.Marshal(dat)
  31582. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31583. utils.ErrorLog("解析失败:%v", err)
  31584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31585. return
  31586. }
  31587. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31588. var api string
  31589. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31590. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31591. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  31592. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31593. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31594. resp, requestErr := http.Get(api)
  31595. if requestErr != nil {
  31596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31597. return
  31598. }
  31599. body, ioErr := ioutil.ReadAll(resp.Body)
  31600. if ioErr != nil {
  31601. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31603. return
  31604. }
  31605. var respJSON map[string]interface{}
  31606. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31607. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31609. return
  31610. }
  31611. status := respJSON["data"].(map[string]interface{})["status"].(string)
  31612. if status == "0" {
  31613. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  31614. c.ServeSuccessJSON(map[string]interface{}{
  31615. "failed_code": -10,
  31616. "msg": err_msg,
  31617. })
  31618. return
  31619. }
  31620. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31621. result, _ := json.Marshal(respJSON)
  31622. fmt.Println("log")
  31623. fmt.Println(string(result))
  31624. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  31625. utils.ErrorLog("解析失败:%v", err)
  31626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31627. return
  31628. }
  31629. res.InfRefmsgid = resah.InfRefmsgid
  31630. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31631. // 创建对应的Time类型
  31632. t := time.UnixMilli(timestamp)
  31633. // 格式化成指定的日期字符串
  31634. str := t.Format("2006-01-02 15:04:05")
  31635. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  31636. // 创建对应的Time类型
  31637. t3 := time.UnixMilli(timestamp2)
  31638. // 格式化成指定的日期字符串
  31639. str2 := t3.Format("2006-01-02 15:04:05")
  31640. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  31641. // 创建对应的Time类型
  31642. t4 := time.UnixMilli(timestamp3)
  31643. // 格式化成指定的日期字符串
  31644. str3 := t4.Format("2006-01-02 15:04:05")
  31645. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  31646. // 创建对应的Time类型
  31647. t5 := time.UnixMilli(timestamp4)
  31648. // 格式化成指定的日期字符串
  31649. str5 := t5.Format("2006-01-02 15:04:05")
  31650. res.Output.Setlinfo.Brdy = str2
  31651. res.Output.Setlinfo.SetlTime = str
  31652. res.Output.Setlinfo.Begndate = str3
  31653. res.Output.Setlinfo.Enddate = str5
  31654. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  31655. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  31656. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  31657. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  31658. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  31659. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  31660. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  31661. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  31662. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  31663. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  31664. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  31665. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  31666. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  31667. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  31668. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  31669. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  31670. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  31671. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  31672. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  31673. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  31674. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  31675. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  31676. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  31677. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  31678. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  31679. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31680. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  31681. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  31682. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  31683. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  31684. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  31685. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  31686. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  31687. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  31688. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  31689. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  31690. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  31691. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  31692. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  31693. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  31694. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  31695. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  31696. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  31697. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  31698. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  31699. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  31700. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  31701. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  31702. //res.Output.Setldetail = resah.Output.Setldetail
  31703. res.ErrMsg = resah.ErrMsg
  31704. res.Cainfo = resah.Cainfo
  31705. res.WarnMsg = resah.WarnMsg
  31706. } else if miConfig.MdtrtareaAdmvs == "430800" {
  31707. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  31708. saveLog(result, requestLog, "5203", "结算单")
  31709. var dat map[string]interface{}
  31710. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31711. fmt.Println(dat)
  31712. } else {
  31713. fmt.Println(err)
  31714. }
  31715. userJSONBytes, _ := json.Marshal(dat)
  31716. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31717. utils.ErrorLog("解析失败:%v", err)
  31718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31719. return
  31720. }
  31721. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31722. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31723. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31724. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31725. resp, requestErr := http.Get(api)
  31726. if requestErr != nil {
  31727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31728. return
  31729. }
  31730. body, ioErr := ioutil.ReadAll(resp.Body)
  31731. if ioErr != nil {
  31732. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31734. return
  31735. }
  31736. var respJSON map[string]interface{}
  31737. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31738. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31740. return
  31741. }
  31742. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31743. result, _ := json.Marshal(respJSON)
  31744. fmt.Println("log")
  31745. fmt.Println(string(result))
  31746. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  31747. utils.ErrorLog("解析失败:%v", err)
  31748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31749. return
  31750. }
  31751. res.InfRefmsgid = resEleven10265.InfRefmsgid
  31752. res.Output = resEleven10265.Output
  31753. res.ErrMsg = resEleven10265.ErrMsg
  31754. res.Cainfo = resEleven10265.Cainfo
  31755. res.WarnMsg = resEleven10265.WarnMsg
  31756. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  31757. res.Infcode = infocode
  31758. } else if miConfig.MdtrtareaAdmvs == "441799" {
  31759. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  31760. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  31761. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  31762. resp, requestErr := http.Get(api)
  31763. if requestErr != nil {
  31764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31765. return
  31766. }
  31767. body, ioErr := ioutil.ReadAll(resp.Body)
  31768. if ioErr != nil {
  31769. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31771. return
  31772. }
  31773. var respJSON map[string]interface{}
  31774. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31775. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31777. return
  31778. }
  31779. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31780. result, _ := json.Marshal(respJSON)
  31781. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31782. utils.ErrorLog("解析失败:%v", err)
  31783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31784. return
  31785. }
  31786. } else if miConfig.MdtrtareaAdmvs == "450721" {
  31787. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  31788. //return
  31789. } else {
  31790. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  31791. if len(his.InsuplcAdmdvs) == 0 {
  31792. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  31793. } else {
  31794. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  31795. }
  31796. result := service.Gdyb5203(baseParams, businessParams)
  31797. //service.Gdyb5204(baseParams, businessParams)
  31798. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  31799. var dat map[string]interface{}
  31800. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31801. fmt.Println(dat)
  31802. } else {
  31803. fmt.Println(err)
  31804. }
  31805. userJSONBytes, _ := json.Marshal(dat)
  31806. if miConfig.Code == "H15049901371" {
  31807. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  31808. utils.ErrorLog("解析失败:%v", err)
  31809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31810. return
  31811. }
  31812. res.InfRefmsgid = resEleven10265.InfRefmsgid
  31813. res.Output = resEleven10265.Output
  31814. res.ErrMsg = resEleven10265.ErrMsg
  31815. res.Cainfo = resEleven10265.Cainfo
  31816. res.WarnMsg = resEleven10265.WarnMsg
  31817. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  31818. res.Infcode = infocode
  31819. } else {
  31820. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31821. utils.ErrorLog("解析失败:%v", err)
  31822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31823. return
  31824. }
  31825. }
  31826. }
  31827. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31828. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  31829. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  31830. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  31831. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  31832. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31833. var doctor_name string
  31834. if roles.ID == 0 {
  31835. doctor_name = "管理员"
  31836. } else {
  31837. doctor_name = roles.UserName
  31838. }
  31839. yiliao_leibie := ""
  31840. switch order.MedType {
  31841. case "11":
  31842. yiliao_leibie = "普通门诊"
  31843. break
  31844. case "12":
  31845. yiliao_leibie = "门诊挂号"
  31846. break
  31847. case "13":
  31848. yiliao_leibie = "急诊"
  31849. break
  31850. case "14":
  31851. yiliao_leibie = "门诊特殊病"
  31852. break
  31853. case "15":
  31854. yiliao_leibie = "门诊统筹"
  31855. break
  31856. case "16":
  31857. yiliao_leibie = "门诊慢性病"
  31858. break
  31859. case "21":
  31860. yiliao_leibie = "普通住院"
  31861. break
  31862. }
  31863. //var rf []CustomFundPay
  31864. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  31865. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  31866. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  31867. if res.Infcode == 0 {
  31868. 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 {
  31869. c.ServeSuccessJSON(map[string]interface{}{
  31870. "diagnosis": name,
  31871. "order_infos": orderInfos,
  31872. "number": order.MdtrtId,
  31873. "date": order.SettleAccountsDate,
  31874. "charge_admin": charge_admin,
  31875. "printor_admin": printor_admin,
  31876. "info": res.Output.Setlinfo,
  31877. "order": order,
  31878. "bedCostTotal": bedCostTotal,
  31879. "bedCostSelfTotal": bedCostSelfTotal,
  31880. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  31881. "bedSelfTotal": bedSelfTotal,
  31882. "bedInscpTotal": bedInscpTotal,
  31883. "operationCostTotal": operationCostTotal,
  31884. "operationCostSelfTotal": operationCostSelfTotal,
  31885. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  31886. "operationSelfTotal": operationSelfTotal,
  31887. "operationInscpTotal": operationInscpTotal,
  31888. "otherCostTotal": otherCostTotal,
  31889. "otherCostSelfTotal": otherCostSelfTotal,
  31890. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  31891. "otherSelfTotal": otherSelfTotal,
  31892. "otherInscpTotal": otherInscpTotal,
  31893. "materialCostTotal": materialCostTotal,
  31894. "materialCostSelfTotal": materialCostSelfTotal,
  31895. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  31896. "materialSelfTotal": materialSelfTotal,
  31897. "materialInscpTotal": materialInscpTotal,
  31898. "westernMedicineCostTotal": westernMedicineCostTotal,
  31899. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  31900. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  31901. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  31902. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  31903. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  31904. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  31905. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  31906. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  31907. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  31908. "checkCostTotal": checkCostTotal,
  31909. "checkCostSelfTotal": checkCostSelfTotal,
  31910. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  31911. "checkSelfTotal": checkSelfTotal,
  31912. "checkInscpTotal": checkInscpTotal,
  31913. "laboratoryCostTotal": laboratoryCostTotal,
  31914. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  31915. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  31916. "laboratorySelfTotal": laboratorySelfTotal,
  31917. "laboratoryInscpTotal": laboratoryInscpTotal,
  31918. "treatCostTotal": treatCostTotal,
  31919. "treatCostSelfTotal": treatCostSelfTotal,
  31920. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  31921. "treatSelfTotal": treatSelfTotal,
  31922. "treatInscpTotal": treatInscpTotal,
  31923. "doctor_info": doctor_info,
  31924. "doctor_code": adminRole_two.DoctorCode,
  31925. "doctor_name": doctor_name,
  31926. "health_card_no": order.PsnNo,
  31927. "department": departments.Name,
  31928. "yiliao_leibie": yiliao_leibie,
  31929. "after_money": order.AccountPrice,
  31930. "patient": patient,
  31931. "org_name": miConfig.OrgName,
  31932. "org_code": miConfig.Code,
  31933. "order_number": order.Number,
  31934. "his_hospital": his_hospital,
  31935. "his": his,
  31936. "dia_config": dia_config,
  31937. "psn_cash_pay": order.PsnCashPay,
  31938. "zcCostTotal": zcCostTotal,
  31939. "zcCostSelfTotal": zcCostSelfTotal,
  31940. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  31941. "zcSelfTotal": zcSelfTotal,
  31942. "zcInscpTotal": zcInscpTotal,
  31943. "huliCostTotal": huliCostTotal,
  31944. "huliCostSelfTotal": huliCostSelfTotal,
  31945. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  31946. "huliSelfTotal": huliSelfTotal,
  31947. "huliInscpTotal": huliInscpTotal,
  31948. //"funds": rf,
  31949. //"check_order_info": cus_slice,
  31950. })
  31951. } else {
  31952. c.ServeSuccessJSON(map[string]interface{}{
  31953. "diagnosis": name,
  31954. "order_infos": orderInfos,
  31955. "number": order.MdtrtId,
  31956. "date": order.SettleAccountsDate,
  31957. "charge_admin": charge_admin,
  31958. "printor_admin": printor_admin,
  31959. "info": order,
  31960. "order": order,
  31961. "bedCostTotal": bedCostTotal,
  31962. "bedCostSelfTotal": bedCostSelfTotal,
  31963. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  31964. "bedSelfTotal": bedSelfTotal,
  31965. "bedInscpTotal": bedInscpTotal,
  31966. "operationCostTotal": operationCostTotal,
  31967. "operationCostSelfTotal": operationCostSelfTotal,
  31968. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  31969. "operationSelfTotal": operationSelfTotal,
  31970. "operationInscpTotal": operationInscpTotal,
  31971. "otherCostTotal": otherCostTotal,
  31972. "otherCostSelfTotal": otherCostSelfTotal,
  31973. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  31974. "otherSelfTotal": otherSelfTotal,
  31975. "otherInscpTotal": otherInscpTotal,
  31976. "materialCostTotal": materialCostTotal,
  31977. "materialCostSelfTotal": materialCostSelfTotal,
  31978. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  31979. "materialSelfTotal": materialSelfTotal,
  31980. "materialInscpTotal": materialInscpTotal,
  31981. "westernMedicineCostTotal": westernMedicineCostTotal,
  31982. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  31983. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  31984. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  31985. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  31986. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  31987. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  31988. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  31989. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  31990. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  31991. "checkCostTotal": checkCostTotal,
  31992. "checkCostSelfTotal": checkCostSelfTotal,
  31993. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  31994. "checkSelfTotal": checkSelfTotal,
  31995. "checkInscpTotal": checkInscpTotal,
  31996. "laboratoryCostTotal": laboratoryCostTotal,
  31997. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  31998. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  31999. "laboratorySelfTotal": laboratorySelfTotal,
  32000. "laboratoryInscpTotal": laboratoryInscpTotal,
  32001. "treatCostTotal": treatCostTotal,
  32002. "treatCostSelfTotal": treatCostSelfTotal,
  32003. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  32004. "treatSelfTotal": treatSelfTotal,
  32005. "treatInscpTotal": treatInscpTotal,
  32006. "doctor_info": doctor_info,
  32007. "doctor_code": adminRole_two.DoctorCode,
  32008. "doctor_name": doctor_name,
  32009. "health_card_no": order.PsnNo,
  32010. "department": departments.Name,
  32011. "yiliao_leibie": yiliao_leibie,
  32012. "after_money": order.AccountPrice,
  32013. "patient": patient,
  32014. "org_name": miConfig.OrgName,
  32015. "org_code": miConfig.Code,
  32016. "order_number": order.Number,
  32017. "his_hospital": his_hospital,
  32018. "his": his,
  32019. "dia_config": dia_config,
  32020. "psn_cash_pay": order.PsnCashPay,
  32021. "zcCostTotal": zcCostTotal,
  32022. "zcCostSelfTotal": zcCostSelfTotal,
  32023. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  32024. "zcSelfTotal": zcSelfTotal,
  32025. "zcInscpTotal": zcInscpTotal,
  32026. "huliCostTotal": huliCostTotal,
  32027. "huliCostSelfTotal": huliCostSelfTotal,
  32028. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  32029. "huliSelfTotal": huliSelfTotal,
  32030. "huliInscpTotal": huliInscpTotal,
  32031. //"funds": rf,
  32032. //"check_order_info": cus_slice,
  32033. })
  32034. }
  32035. }
  32036. }
  32037. }
  32038. //func (c *HisApiController) CheckTreatment() {
  32039. // patient_id, _ := c.GetInt64("patient_id")
  32040. // id_card_no := c.GetString("id_card_no")
  32041. // insutype := c.GetString("insutype")
  32042. // med_type := c.GetString("med_type")
  32043. // admin_user_id, _ := c.GetInt64("admin_user_id")
  32044. //
  32045. // adminUser := c.GetAdminUserInfo()
  32046. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  32047. //
  32048. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32049. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32050. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32051. //
  32052. // if miConfig.MdtrtareaAdmvs == "421300" {
  32053. // var res ResultTwo
  32054. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  32055. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32056. // "&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)
  32057. // resp, requestErr := http.Get(api)
  32058. // if requestErr != nil {
  32059. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32060. // return
  32061. // }
  32062. //
  32063. // body, ioErr := ioutil.ReadAll(resp.Body)
  32064. // if ioErr != nil {
  32065. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32066. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32067. // return
  32068. // }
  32069. // var respJSON map[string]interface{}
  32070. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32071. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32072. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32073. // return
  32074. // }
  32075. //
  32076. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32077. // result, _ := json.Marshal(respJSON)
  32078. //
  32079. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  32080. // utils.ErrorLog("解析失败:%v", err)
  32081. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32082. // return
  32083. // }
  32084. //
  32085. // if res.Infcode == 0 {
  32086. //
  32087. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  32088. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32089. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  32090. // resp, requestErr := http.Get(api)
  32091. // if requestErr != nil {
  32092. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32093. // return
  32094. // }
  32095. //
  32096. // body, ioErr := ioutil.ReadAll(resp.Body)
  32097. // if ioErr != nil {
  32098. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32099. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32100. // return
  32101. // }
  32102. // var respJSON map[string]interface{}
  32103. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32104. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32105. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32106. // return
  32107. // }
  32108. // var res Result2001
  32109. //
  32110. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32111. // result2, _ := json.Marshal(respJSON)
  32112. //
  32113. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  32114. // utils.ErrorLog("解析失败:%v", err)
  32115. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32116. // return
  32117. // }
  32118. //
  32119. // if res.Infcode == 0 {
  32120. // c.ServeSuccessJSON(map[string]interface{}{
  32121. // "msg": res.Output.Trtinfo,
  32122. // })
  32123. // }
  32124. //
  32125. // } else {
  32126. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  32127. // return
  32128. // }
  32129. //
  32130. // } else {
  32131. //
  32132. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  32133. // var dat map[string]interface{}
  32134. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32135. // fmt.Println(dat)
  32136. // } else {
  32137. // fmt.Println(err)
  32138. // }
  32139. // userJSONBytes, _ := json.Marshal(dat)
  32140. // var res ResultTwo
  32141. // var res10265 ResultTwo10265
  32142. // if miConfig.Code == "H15049901371" {
  32143. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  32144. // utils.ErrorLog("解析失败:%v", err)
  32145. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32146. // return
  32147. // }
  32148. // res.ErrMsg = res10265.ErrMsg
  32149. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  32150. // res.Infcode = infocode
  32151. // res.Output = res10265.Output
  32152. // res.InfRefmsgid = res10265.InfRefmsgid
  32153. // } else {
  32154. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32155. // utils.ErrorLog("解析失败:%v", err)
  32156. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32157. // return
  32158. // }
  32159. // }
  32160. //
  32161. // var user_name string
  32162. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  32163. // if role.ID == 0 {
  32164. // user_name = "xxx"
  32165. // } else {
  32166. // user_name = role.UserName
  32167. // }
  32168. //
  32169. // baseParams := models.BaseParams{
  32170. // SecretKey: miConfig.SecretKey,
  32171. // FixmedinsCode: miConfig.Code,
  32172. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  32173. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  32174. // OrgName: miConfig.OrgName,
  32175. // Doctor: user_name,
  32176. // }
  32177. //
  32178. // if config.IsOpen == 1 {
  32179. // if miConfig.Code == "H15049901371" {
  32180. // if med_type == "14" {
  32181. // if insutype == "390" {
  32182. // med_type = "9933"
  32183. // } else if insutype == "310" {
  32184. // med_type = "990502"
  32185. // }
  32186. // } else if med_type == "11" {
  32187. // med_type = "11"
  32188. // }
  32189. // }
  32190. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  32191. // var dat map[string]interface{}
  32192. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32193. // fmt.Println(dat)
  32194. // } else {
  32195. // fmt.Println(err)
  32196. // }
  32197. // var res Result2001
  32198. // var res10265 Result2001Org10265
  32199. // if miConfig.Code == "H15049901371" {
  32200. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  32201. // utils.ErrorLog("解析失败:%v", err)
  32202. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32203. // return
  32204. // }
  32205. // res.ErrMsg = res10265.ErrMsg
  32206. // res.Output = res10265.Output
  32207. // res.InfRefmsgid = res10265.InfRefmsgid
  32208. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  32209. // res.Infcode = infocode
  32210. // } else {
  32211. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  32212. // utils.ErrorLog("解析失败:%v", err)
  32213. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32214. // return
  32215. // }
  32216. // }
  32217. // if res.Infcode == 0 {
  32218. // c.ServeSuccessJSON(map[string]interface{}{
  32219. // "msg": res.Output.Trtinfo,
  32220. // })
  32221. // }
  32222. // }
  32223. // }
  32224. //}
  32225. //func (c *HisApiController) PutRecord() {
  32226. // id, _ := c.GetInt64("id")
  32227. // record_time := c.GetString("record_time")
  32228. // timeLayout := "2006-01-02"
  32229. // loc, _ := time.LoadLocation("Local")
  32230. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32231. // if err != nil {
  32232. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32233. // return
  32234. // }
  32235. // recordDateTime := theTime.Unix()
  32236. //
  32237. // adminInfo := c.GetAdminUserInfo()
  32238. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  32239. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  32240. //
  32241. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  32242. //
  32243. // fmt.Println(miConfig.SecretKey)
  32244. //
  32245. // if patient == nil {
  32246. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  32247. // return
  32248. // }
  32249. // if len(patient.IdCardNo) == 0 {
  32250. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  32251. // return
  32252. // }
  32253. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  32254. // if config.IsOpen == 1 {
  32255. // 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
  32256. // resp, requestErr := http.Get(api)
  32257. // if requestErr != nil {
  32258. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32259. // return
  32260. // }
  32261. // defer resp.Body.Close()
  32262. // body, ioErr := ioutil.ReadAll(resp.Body)
  32263. // if ioErr != nil {
  32264. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32265. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32266. // return
  32267. // }
  32268. // var respJSON map[string]interface{}
  32269. //
  32270. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32271. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32272. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32273. // return
  32274. // }
  32275. //
  32276. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32277. // userJSONBytes, _ := json.Marshal(userJSON)
  32278. // var res ResultTwo
  32279. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32280. // utils.ErrorLog("解析失败:%v", err)
  32281. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32282. // return
  32283. // }
  32284. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  32285. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  32286. // infoStr := string(Iinfos)
  32287. // idetinfoStr := string(Idetinfos)
  32288. //
  32289. // if res.Infcode == 0 {
  32290. // his := models.VMHisPatient{
  32291. // Status: 1,
  32292. // Ctime: time.Now().Unix(),
  32293. // Mtime: time.Now().Unix(),
  32294. // PsnNo: res.Output.Baseinfo.PsnNo,
  32295. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  32296. // Certno: res.Output.Baseinfo.Certno,
  32297. // PsnName: res.Output.Baseinfo.PsnName,
  32298. // Gend: res.Output.Baseinfo.Gend,
  32299. // Naty: res.Output.Baseinfo.Naty,
  32300. // Brdy: res.Output.Baseinfo.Brdy,
  32301. // Age: res.Output.Baseinfo.Age,
  32302. // Iinfo: infoStr,
  32303. // Idetinfo: idetinfoStr,
  32304. // PatientId: patient.ID,
  32305. // RecordDate: theTime.Unix(),
  32306. // UserOrgId: adminInfo.CurrentOrgId,
  32307. // AdminUserId: adminInfo.AdminUser.Id,
  32308. // IsReturn: 1,
  32309. // }
  32310. //
  32311. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  32312. // //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")
  32313. // //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")
  32314. //
  32315. // //var dat map[string]interface{}
  32316. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32317. // // fmt.Println(dat)
  32318. // //} else {
  32319. // // fmt.Println(err)
  32320. // //}
  32321. //
  32322. // var dat2 map[string]interface{}
  32323. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  32324. // fmt.Println(dat2)
  32325. // } else {
  32326. // fmt.Println(err)
  32327. // }
  32328. //
  32329. // } else {
  32330. // adminUser := c.GetAdminUserInfo()
  32331. // errlog := &models.HisOrderError{
  32332. // UserOrgId: adminUser.CurrentOrgId,
  32333. // Ctime: time.Now().Unix(),
  32334. // Mtime: time.Now().Unix(),
  32335. // ErrMsg: res.ErrMsg,
  32336. // Status: 1,
  32337. // PatientId: id,
  32338. // RecordTime: recordDateTime,
  32339. // Stage: 1,
  32340. // }
  32341. // service.CreateErrMsgLog(errlog)
  32342. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  32343. // return
  32344. // }
  32345. // }
  32346. //
  32347. //}
  32348. //func (c *HisApiController) GetUploadDiag() {
  32349. // id, _ := c.GetInt64("id")
  32350. // record_time := c.GetString("record_time")
  32351. //
  32352. // diagnosis_id, _ := c.GetInt64("diagnosis")
  32353. // sick_type, _ := c.GetInt64("sick_type")
  32354. // reg_type, _ := c.GetInt64("reg_type")
  32355. //
  32356. // timeLayout := "2006-01-02"
  32357. // loc, _ := time.LoadLocation("Local")
  32358. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  32359. // if err != nil {
  32360. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32361. // return
  32362. // }
  32363. //
  32364. // var patientPrescription models.HisPrescriptionInfo
  32365. // recordDateTime := theTime.Unix()
  32366. // adminInfo := c.GetAdminUserInfo()
  32367. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  32368. //
  32369. // if patientPrescription.ID == 0 {
  32370. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  32371. // }
  32372. //
  32373. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  32374. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  32375. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  32376. // sickConfig, _ := service.FindSickById(sick_type)
  32377. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  32378. //
  32379. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  32380. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  32381. // "&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 +
  32382. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  32383. // resp2, requestErr2 := http.Get(api2)
  32384. // if requestErr2 != nil {
  32385. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32386. // return
  32387. // }
  32388. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  32389. // if ioErr2 != nil {
  32390. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  32391. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32392. // return
  32393. // }
  32394. // var respJSON2 map[string]interface{}
  32395. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  32396. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32397. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32398. // return
  32399. // }
  32400. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32401. // userJSONBytes2, _ := json.Marshal(respJSON2)
  32402. //
  32403. // var res2 ResultSix
  32404. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  32405. // utils.ErrorLog("解析失败:%v", err)
  32406. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32407. // return
  32408. // }
  32409. // if res2.Infcode != 0 {
  32410. // adminUser := c.GetAdminUserInfo()
  32411. // errlog := &models.HisOrderError{
  32412. // UserOrgId: adminUser.CurrentOrgId,
  32413. // Ctime: time.Now().Unix(),
  32414. // Mtime: time.Now().Unix(),
  32415. // ErrMsg: res2.ErrMsg,
  32416. // Status: 1,
  32417. // PatientId: id,
  32418. // RecordTime: recordDateTime,
  32419. // Stage: 3,
  32420. // }
  32421. // service.CreateErrMsgLog(errlog)
  32422. //
  32423. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  32424. // return
  32425. // }
  32426. //
  32427. // c.ServeSuccessJSON(map[string]interface{}{
  32428. // "msg": "上传成功",
  32429. // })
  32430. //
  32431. //}
  32432. type QueryResult struct {
  32433. ID int64
  32434. Name string
  32435. Code string
  32436. List_type_code string
  32437. }
  32438. func (c *HisApiController) GetCheckCode() {
  32439. ids_str := c.GetString("ids")
  32440. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  32441. ids_arr := strings.Split(ids_str, ",")
  32442. var queryResult []QueryResult
  32443. ids := make([]int64, 0)
  32444. for _, item := range ids_arr {
  32445. id, _ := strconv.ParseInt(item, 10, 64)
  32446. ids = append(ids, id)
  32447. }
  32448. if record_type == 1 {
  32449. drugs, _ := service.GetBatchDrugList(ids)
  32450. for _, item := range drugs {
  32451. result := QueryResult{
  32452. ID: item.ID,
  32453. Name: item.DrugName,
  32454. Code: item.MedicalInsuranceNumber,
  32455. List_type_code: "101",
  32456. }
  32457. queryResult = append(queryResult, result)
  32458. }
  32459. } else if record_type == 2 {
  32460. goods, _ := service.GetBatchGoodInformationList(ids)
  32461. fmt.Println(goods)
  32462. for _, item := range goods {
  32463. result := QueryResult{
  32464. ID: item.ID,
  32465. Name: item.GoodName,
  32466. Code: item.SocialSecurityDirectoryCode,
  32467. List_type_code: "301",
  32468. }
  32469. queryResult = append(queryResult, result)
  32470. }
  32471. } else if record_type == 3 {
  32472. projects, _ := service.GetBathchMyPorjecgList(ids)
  32473. for _, item := range projects {
  32474. result := QueryResult{
  32475. ID: item.ID,
  32476. Name: item.ProjectName,
  32477. Code: item.MedicalCode,
  32478. List_type_code: "201",
  32479. }
  32480. queryResult = append(queryResult, result)
  32481. }
  32482. }
  32483. admin_user_id, _ := c.GetInt64("admin_user_id")
  32484. adminUser := c.GetAdminUserInfo()
  32485. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32486. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32487. var user_name string
  32488. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32489. if role.ID == 0 {
  32490. user_name = "管理员"
  32491. } else {
  32492. user_name = role.UserName
  32493. }
  32494. baseParams := models.BaseParams{
  32495. SecretKey: miConfig.SecretKey,
  32496. FixmedinsCode: miConfig.Code,
  32497. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  32498. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  32499. OrgName: miConfig.OrgName,
  32500. Doctor: user_name,
  32501. }
  32502. var result string
  32503. if miConfig.MdtrtareaAdmvs == "430800" {
  32504. for _, item := range queryResult {
  32505. if record_type == 1 {
  32506. 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)
  32507. } else if record_type == 2 {
  32508. fmt.Println(item.Code)
  32509. 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)
  32510. } else if record_type == 3 {
  32511. 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)
  32512. }
  32513. var dat map[string]interface{}
  32514. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32515. fmt.Println(dat)
  32516. } else {
  32517. fmt.Println(err)
  32518. }
  32519. userJSONBytes, _ := json.Marshal(dat)
  32520. var res ResultSix
  32521. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32522. utils.ErrorLog("解析失败:%v", err)
  32523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32524. return
  32525. }
  32526. if res.Infcode == 0 {
  32527. if record_type == 1 {
  32528. service.UpdateBaseDrugById(item.ID)
  32529. } else if record_type == 2 {
  32530. service.UpdateGoodInformaitonByDetail(item.ID)
  32531. } else if record_type == 3 {
  32532. service.UpdateProjectById(item.ID)
  32533. }
  32534. c.ServeSuccessJSON(map[string]interface{}{
  32535. "failed_code": 0,
  32536. "msg": "目录对照成功",
  32537. })
  32538. } else {
  32539. c.ServeSuccessJSON(map[string]interface{}{
  32540. "failed_code": -10,
  32541. "msg": res.ErrMsg,
  32542. })
  32543. }
  32544. }
  32545. } else {
  32546. for _, item := range queryResult {
  32547. var result string
  32548. if record_type == 1 {
  32549. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  32550. } else if record_type == 2 {
  32551. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  32552. } else if record_type == 3 {
  32553. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  32554. }
  32555. var dat map[string]interface{}
  32556. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32557. fmt.Println(dat)
  32558. } else {
  32559. fmt.Println(err)
  32560. }
  32561. userJSONBytes, _ := json.Marshal(dat)
  32562. var res ResultSix
  32563. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32564. utils.ErrorLog("解析失败:%v", err)
  32565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32566. return
  32567. }
  32568. if res.Infcode == 0 {
  32569. if record_type == 1 {
  32570. service.UpdateBaseDrugById(item.ID)
  32571. } else if record_type == 2 {
  32572. service.UpdateGoodInformaitonByDetail(item.ID)
  32573. } else if record_type == 3 {
  32574. service.UpdateProjectById(item.ID)
  32575. }
  32576. c.ServeSuccessJSON(map[string]interface{}{
  32577. "failed_code": 0,
  32578. "msg": "目录对照成功",
  32579. })
  32580. } else {
  32581. c.ServeSuccessJSON(map[string]interface{}{
  32582. "failed_code": -10,
  32583. "msg": res.ErrMsg,
  32584. })
  32585. }
  32586. }
  32587. }
  32588. }
  32589. func (c *HisApiController) UnCheckCode() {
  32590. ids_str := c.GetString("ids")
  32591. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  32592. admin_user_id, _ := c.GetInt64("admin_user_id")
  32593. ids_arr := strings.Split(ids_str, ",")
  32594. var queryResult []QueryResult
  32595. ids := make([]int64, 0)
  32596. for _, item := range ids_arr {
  32597. id, _ := strconv.ParseInt(item, 10, 64)
  32598. ids = append(ids, id)
  32599. }
  32600. if record_type == 1 {
  32601. drugs, _ := service.GetBatchDrugList(ids)
  32602. for _, item := range drugs {
  32603. result := QueryResult{
  32604. ID: item.ID,
  32605. Name: item.DrugName,
  32606. Code: item.MedicalInsuranceNumber,
  32607. List_type_code: "101",
  32608. }
  32609. queryResult = append(queryResult, result)
  32610. }
  32611. } else if record_type == 2 {
  32612. goods, _ := service.GetBatchGoodInformationList(ids)
  32613. for _, item := range goods {
  32614. result := QueryResult{
  32615. ID: item.ID,
  32616. Name: item.GoodName,
  32617. Code: item.SocialSecurityDirectoryCode,
  32618. List_type_code: "301",
  32619. }
  32620. queryResult = append(queryResult, result)
  32621. }
  32622. } else if record_type == 3 {
  32623. projects, _ := service.GetBathchMyPorjecgList(ids)
  32624. for _, item := range projects {
  32625. result := QueryResult{
  32626. ID: item.ID,
  32627. Name: item.ProjectName,
  32628. Code: item.MedicalCode,
  32629. List_type_code: "201",
  32630. }
  32631. queryResult = append(queryResult, result)
  32632. }
  32633. }
  32634. adminUser := c.GetAdminUserInfo()
  32635. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32636. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32637. var user_name string
  32638. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32639. if role.ID == 0 {
  32640. user_name = "xxx"
  32641. } else {
  32642. user_name = role.UserName
  32643. }
  32644. baseParams := &models.BaseParams{
  32645. SecretKey: miConfig.SecretKey,
  32646. FixmedinsCode: miConfig.Code,
  32647. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  32648. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  32649. OrgName: miConfig.OrgName,
  32650. Doctor: user_name,
  32651. }
  32652. if config.IsOpen == 1 {
  32653. if miConfig.MdtrtareaAdmvs == "430800" {
  32654. for _, item := range queryResult {
  32655. var result string
  32656. if record_type == 1 {
  32657. 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)
  32658. } else if record_type == 2 {
  32659. fmt.Println(item.Code)
  32660. 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)
  32661. } else if record_type == 3 {
  32662. 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)
  32663. }
  32664. var dat map[string]interface{}
  32665. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32666. fmt.Println(dat)
  32667. } else {
  32668. fmt.Println(err)
  32669. }
  32670. userJSONBytes, _ := json.Marshal(dat)
  32671. var res ResultSix
  32672. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32673. utils.ErrorLog("解析失败:%v", err)
  32674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32675. return
  32676. }
  32677. if res.Infcode == 0 {
  32678. if record_type == 1 {
  32679. service.UpdateBaseDrugById(item.ID)
  32680. } else if record_type == 2 {
  32681. service.UpdateGoodInformaitonByDetail(item.ID)
  32682. } else if record_type == 3 {
  32683. service.UpdateProjectById(item.ID)
  32684. }
  32685. c.ServeSuccessJSON(map[string]interface{}{
  32686. "failed_code": 0,
  32687. "msg": "目录对照成功",
  32688. })
  32689. } else {
  32690. c.ServeSuccessJSON(map[string]interface{}{
  32691. "failed_code": -10,
  32692. "msg": res.ErrMsg,
  32693. })
  32694. }
  32695. }
  32696. } else {
  32697. for _, item := range queryResult {
  32698. var result string
  32699. if record_type == 1 {
  32700. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  32701. } else if record_type == 2 {
  32702. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  32703. } else if record_type == 3 {
  32704. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  32705. }
  32706. var dat2 map[string]interface{}
  32707. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  32708. fmt.Println(dat2)
  32709. } else {
  32710. fmt.Println(err)
  32711. }
  32712. userJSONBytes, _ := json.Marshal(dat2)
  32713. var res ResultSix
  32714. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32715. utils.ErrorLog("解析失败:%v", err)
  32716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32717. return
  32718. }
  32719. if res.Infcode == 0 {
  32720. if record_type == 1 {
  32721. service.UpdateDrugByIdDetail(item.ID)
  32722. } else if record_type == 2 {
  32723. service.UpdateGoodInfoById(item.ID)
  32724. } else if record_type == 3 {
  32725. service.UpdateMyProjectById(item.ID)
  32726. }
  32727. c.ServeSuccessJSON(map[string]interface{}{
  32728. "failed_code": 0,
  32729. "msg": "撤销目录对照成功",
  32730. })
  32731. } else {
  32732. c.ServeSuccessJSON(map[string]interface{}{
  32733. "failed_code": -10,
  32734. "msg": res.ErrMsg,
  32735. })
  32736. }
  32737. }
  32738. }
  32739. }
  32740. }
  32741. func (c *HisApiController) GetPatientInfo() {
  32742. id_card_no := c.GetString("id_card_no")
  32743. admin_user_id, _ := c.GetInt64("admin_user_id")
  32744. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  32745. if patient.ID == 0 {
  32746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  32747. return
  32748. }
  32749. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  32750. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  32751. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  32752. var res ResultTwo
  32753. var res10265 ResultTwo10265
  32754. if config.IsOpen == 1 {
  32755. if miConfig.MdtrtareaAdmvs == "150499" {
  32756. //请求内网数据
  32757. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  32758. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  32759. "&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
  32760. resp, requestErr := http.Get(api)
  32761. if requestErr != nil {
  32762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32763. return
  32764. }
  32765. body, ioErr := ioutil.ReadAll(resp.Body)
  32766. if ioErr != nil {
  32767. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32769. return
  32770. }
  32771. var respJSON map[string]interface{}
  32772. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32773. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32775. return
  32776. }
  32777. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32778. result_byte, _ := json.Marshal(respJSON)
  32779. result := string(result_byte)
  32780. var dat map[string]interface{}
  32781. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32782. fmt.Println(dat)
  32783. } else {
  32784. fmt.Println(err)
  32785. }
  32786. userJSONBytes, _ := json.Marshal(dat)
  32787. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  32788. utils.ErrorLog("解析失败:%v", err)
  32789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32790. return
  32791. }
  32792. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  32793. res.Infcode = Infcode
  32794. res.ErrMsg = res10265.ErrMsg
  32795. res.Output = res10265.Output
  32796. res.InfRefmsgid = res10265.InfRefmsgid
  32797. res.RespondTime = res10265.RespondTime
  32798. res.WarnInfo = res10265.WarnInfo
  32799. } else {
  32800. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  32801. var dat map[string]interface{}
  32802. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32803. fmt.Println(dat)
  32804. } else {
  32805. fmt.Println(err)
  32806. }
  32807. userJSONBytes, _ := json.Marshal(dat)
  32808. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32809. utils.ErrorLog("解析失败:%v", err)
  32810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32811. return
  32812. }
  32813. }
  32814. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32815. // utils.ErrorLog("解析失败:%v", err)
  32816. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32817. // return
  32818. //}
  32819. for index, item := range res.Output.Iinfo {
  32820. if item.PsnInsuStas == "2" {
  32821. fmt.Println("--------")
  32822. res.Output.Iinfo[index].Insutype = "300"
  32823. res.Output.Iinfo[index].PsnInsuStas = "1"
  32824. }
  32825. }
  32826. fmt.Println(res.Output.Iinfo)
  32827. if res.Infcode != 0 {
  32828. c.ServeSuccessJSON(map[string]interface{}{
  32829. "failed_code": -10,
  32830. "msg": res.ErrMsg,
  32831. })
  32832. } else {
  32833. c.ServeSuccessJSON(map[string]interface{}{
  32834. "failed_code": 0,
  32835. "info": res,
  32836. })
  32837. }
  32838. }
  32839. }
  32840. func (c *HisApiController) PsnPutOnRecord() {
  32841. record_type, _ := c.GetInt64("type")
  32842. patient_id, _ := c.GetInt64("patient_id")
  32843. admin_user_id, _ := c.GetInt64("admin_user_id")
  32844. start_time := c.GetString("start_time")
  32845. end_time := c.GetString("end_time")
  32846. adminUser := c.GetAdminUserInfo()
  32847. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32848. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32849. var patients []*models.Patients
  32850. if record_type == 1 { //全部备案
  32851. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  32852. patients = append(patients, patient...)
  32853. } else { //单个备案
  32854. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  32855. patients = append(patients, patient)
  32856. }
  32857. var user_name string
  32858. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32859. if role.ID == 0 {
  32860. user_name = "xxx"
  32861. } else {
  32862. user_name = role.UserName
  32863. }
  32864. if config.IsOpen == 1 {
  32865. for _, item := range patients {
  32866. 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
  32867. resp, requestErr := http.Get(api)
  32868. if requestErr != nil {
  32869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32870. return
  32871. }
  32872. defer resp.Body.Close()
  32873. body, ioErr := ioutil.ReadAll(resp.Body)
  32874. if ioErr != nil {
  32875. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32877. return
  32878. }
  32879. var respJSON map[string]interface{}
  32880. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32883. return
  32884. }
  32885. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32886. userJSONBytes, _ := json.Marshal(userJSON)
  32887. var res ResultTwo
  32888. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32889. utils.ErrorLog("解析失败:%v", err)
  32890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32891. return
  32892. }
  32893. if res.Infcode == 0 {
  32894. 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)
  32895. var dat map[string]interface{}
  32896. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32897. fmt.Println(dat)
  32898. } else {
  32899. fmt.Println(err)
  32900. }
  32901. userJSONBytes, _ := json.Marshal(dat)
  32902. var res2 ResultThirteen
  32903. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  32904. utils.ErrorLog("解析失败:%v", err)
  32905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32906. return
  32907. }
  32908. if res2.Infcode == 0 {
  32909. psnResult := &models.GdybPsnRecord{
  32910. UserOrgId: adminUser.CurrentOrgId,
  32911. PatientId: item.ID,
  32912. PsnNo: res.Output.Baseinfo.PsnNo,
  32913. Ctime: time.Now().Unix(),
  32914. Mtime: time.Now().Unix(),
  32915. Status: 1,
  32916. IsCancel: 1,
  32917. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  32918. }
  32919. service.CreatePsnRecord(psnResult)
  32920. } else {
  32921. c.ServeSuccessJSON(map[string]interface{}{
  32922. "failed_code": -10,
  32923. "msg": res2.ErrMsg,
  32924. })
  32925. return
  32926. }
  32927. }
  32928. }
  32929. }
  32930. }
  32931. func (c *HisApiController) PsnUnPutOnRecord() {
  32932. id, _ := c.GetInt64("id")
  32933. //record_type, _ := c.GetInt64("type")
  32934. admin_user_id, _ := c.GetInt64("admin_user_id")
  32935. adminUser := c.GetAdminUserInfo()
  32936. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32937. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32938. var user_name string
  32939. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32940. if role.ID == 0 {
  32941. user_name = "xxx"
  32942. } else {
  32943. user_name = role.UserName
  32944. }
  32945. psn_record, _ := service.GetPsnRecordById(id)
  32946. if psn_record.ID == 0 {
  32947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  32948. return
  32949. }
  32950. if config.IsOpen == 1 {
  32951. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  32952. var dat map[string]interface{}
  32953. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32954. fmt.Println(dat)
  32955. } else {
  32956. fmt.Println(err)
  32957. }
  32958. userJSONBytes, _ := json.Marshal(dat)
  32959. var res ResultFourteen
  32960. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32961. utils.ErrorLog("解析失败:%v", err)
  32962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32963. return
  32964. }
  32965. if res.Infcode == 0 {
  32966. psn_record.IsCancel = 2
  32967. service.CreatePsnRecord(&psn_record)
  32968. } else {
  32969. c.ServeSuccessJSON(map[string]interface{}{
  32970. "failed_code": -10,
  32971. "msg": res.ErrMsg,
  32972. })
  32973. return
  32974. }
  32975. }
  32976. }
  32977. func (c *HisApiController) PsnPutNCDSOnRecord() {
  32978. patient_id, _ := c.GetInt64("patient_id")
  32979. insutype_two := c.GetString("insutype")
  32980. psn_no := c.GetString("psn_no")
  32981. doctor_id, _ := c.GetInt64("doctor_id")
  32982. sick_id, _ := c.GetInt64("sick_id")
  32983. department_id, _ := c.GetInt64("department_id")
  32984. start_time := c.GetString("start_time")
  32985. end_time := c.GetString("end_time")
  32986. check_time := c.GetString("check_time")
  32987. hospital_code := c.GetString("hospital_code")
  32988. hospital_name := c.GetString("hospital_name")
  32989. adminUser := c.GetAdminUserInfo()
  32990. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  32991. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32992. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32993. sick, _ := service.FindSickById(sick_id)
  32994. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  32995. if len(hospital_code) == 0 {
  32996. hospital_code = miConfig.Code
  32997. }
  32998. if len(hospital_name) == 0 {
  32999. hospital_name = miConfig.OrgName
  33000. }
  33001. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  33002. var res ResultTwo
  33003. var res10265 ResultTwo10265
  33004. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33005. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  33006. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  33007. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  33008. "&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
  33009. resp, requestErr := http.Get(api)
  33010. if requestErr != nil {
  33011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33012. return
  33013. }
  33014. body, ioErr := ioutil.ReadAll(resp.Body)
  33015. if ioErr != nil {
  33016. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33018. return
  33019. }
  33020. var respJSON map[string]interface{}
  33021. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33022. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33024. return
  33025. }
  33026. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33027. result, _ := json.Marshal(respJSON)
  33028. fmt.Println("log")
  33029. fmt.Println(string(result))
  33030. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  33031. utils.ErrorLog("解析失败:%v", err)
  33032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33033. return
  33034. }
  33035. res.ErrMsg = res10265.ErrMsg
  33036. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  33037. res.Infcode = infocode
  33038. res.Output = res10265.Output
  33039. res.InfRefmsgid = res10265.InfRefmsgid
  33040. } else {
  33041. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  33042. if miConfig.Code == "H15049901371" {
  33043. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  33044. utils.ErrorLog("解析失败:%v", err)
  33045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33046. return
  33047. }
  33048. res.ErrMsg = res10265.ErrMsg
  33049. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  33050. res.Infcode = infocode
  33051. res.Output = res10265.Output
  33052. res.InfRefmsgid = res10265.InfRefmsgid
  33053. } else {
  33054. if err := json.Unmarshal([]byte(result), &res); err != nil {
  33055. utils.ErrorLog("解析失败:%v", err)
  33056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33057. return
  33058. }
  33059. }
  33060. }
  33061. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  33062. infoStr := string(Iinfos)
  33063. var rf []*ResultFive
  33064. json.Unmarshal([]byte(infoStr), &rf)
  33065. var insuplc_admdvs string
  33066. var insutype string
  33067. var is390 int = 0
  33068. var is310 int = 0
  33069. var insutypes []*ResultFive
  33070. for _, item := range rf {
  33071. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  33072. insutypes = append(insutypes, item)
  33073. }
  33074. }
  33075. if len(insutypes) == 1 {
  33076. insutype = insutypes[0].Insutype
  33077. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  33078. } else {
  33079. for _, i := range insutypes {
  33080. if i.Insutype == "390" {
  33081. is390 = 1
  33082. }
  33083. if i.Insutype == "310" {
  33084. is310 = 1
  33085. }
  33086. }
  33087. }
  33088. if is390 == 1 {
  33089. insutype = "390"
  33090. }
  33091. if is310 == 1 {
  33092. insutype = "310"
  33093. }
  33094. if len(insutypes) == 2 {
  33095. insutype = insutype_two
  33096. }
  33097. if len(insutypes) == 0 {
  33098. insutype = "310"
  33099. }
  33100. insutype = insutype_two
  33101. fmt.Println(insutype)
  33102. for _, item := range rf {
  33103. fmt.Println(item.Insutype)
  33104. fmt.Println(insutype)
  33105. if item.Insutype == insutype {
  33106. fmt.Println(item.Insutype)
  33107. fmt.Println(insutype)
  33108. insuplc_admdvs = item.InsuplcAdmdvs
  33109. }
  33110. }
  33111. fmt.Println(insuplc_admdvs)
  33112. var res2 ResultThirteen
  33113. var res10265_2 ResultThirteen10265
  33114. if config.IsOpen == 1 {
  33115. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  33116. } else {
  33117. if miConfig.MdtrtareaAdmvs == "150499" {
  33118. //
  33119. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  33120. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  33121. // "&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
  33122. //resp, requestErr := http.Get(api)
  33123. //if requestErr != nil {
  33124. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33125. // return
  33126. //}
  33127. //
  33128. //body, ioErr := ioutil.ReadAll(resp.Body)
  33129. //if ioErr != nil {
  33130. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  33131. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33132. // return
  33133. //}
  33134. //var respJSON map[string]interface{}
  33135. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  33136. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33137. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33138. // return
  33139. //}
  33140. //
  33141. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33142. //result, _ := json.Marshal(respJSON)
  33143. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  33144. // utils.ErrorLog("解析失败:%v", err)
  33145. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33146. // return
  33147. //}
  33148. //infocode = resThree.Infcode
  33149. //result, _ := json.Marshal(respJSON)
  33150. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  33151. // utils.ErrorLog("解析失败:%v", err)
  33152. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33153. // return
  33154. //}
  33155. //
  33156. //resThree.ErrMsg = resThree10265.ErrMsg
  33157. //
  33158. //resThree.Output = resThree10265.Output
  33159. //
  33160. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  33161. //
  33162. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  33163. //
  33164. } else {
  33165. 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)
  33166. var dat map[string]interface{}
  33167. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33168. fmt.Println(dat)
  33169. } else {
  33170. fmt.Println(err)
  33171. }
  33172. userJSONBytes, _ := json.Marshal(dat)
  33173. if miConfig.Code == "H15049901371" {
  33174. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  33175. utils.ErrorLog("解析失败:%v", err)
  33176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33177. return
  33178. }
  33179. res2.ErrMsg = res10265_2.ErrMsg
  33180. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  33181. res2.Infcode = infocode
  33182. res2.Output = res10265_2.Output
  33183. res2.InfRefmsgid = res10265_2.InfRefmsgid
  33184. } else {
  33185. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33186. utils.ErrorLog("解析失败:%v", err)
  33187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33188. return
  33189. }
  33190. }
  33191. }
  33192. }
  33193. if res2.Infcode == 0 {
  33194. psnResult := &models.GdybPsnNcdsRecord{
  33195. UserOrgId: adminUser.CurrentOrgId,
  33196. PatientId: patient.ID,
  33197. PsnNo: psn_no,
  33198. DoctorId: doctor.AdminUserId,
  33199. DepartmentId: department_id,
  33200. SickType: sick_id,
  33201. Insutype: insutype,
  33202. Ctime: time.Now().Unix(),
  33203. Mtime: time.Now().Unix(),
  33204. Status: 1,
  33205. IsCancel: 1,
  33206. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  33207. }
  33208. service.CreatePsnNCDSRecord(psnResult)
  33209. c.ServeSuccessJSON(map[string]interface{}{
  33210. "failed_code": 0,
  33211. "msg": "备案成功",
  33212. "result": psnResult,
  33213. })
  33214. } else {
  33215. c.ServeSuccessJSON(map[string]interface{}{
  33216. "failed_code": -10,
  33217. "msg": res2.ErrMsg,
  33218. })
  33219. return
  33220. }
  33221. }
  33222. }
  33223. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  33224. id, _ := c.GetInt64("id")
  33225. admin_user_id, _ := c.GetInt64("admin_user_id")
  33226. adminUser := c.GetAdminUserInfo()
  33227. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33228. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33229. //config, _ := service.Ge(adminUser.CurrentOrgId)
  33230. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  33231. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33232. //var user_name string
  33233. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33234. //if role.ID == 0 {
  33235. // user_name = "xxx"
  33236. //} else {
  33237. // user_name = role.UserName
  33238. //}
  33239. psn_record, _ := service.GetPsnNCDSRecordById(id)
  33240. if psn_record.ID == 0 {
  33241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  33242. return
  33243. }
  33244. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  33245. var res ResultTwo
  33246. var res10265 ResultTwo10265
  33247. if miConfig.Code == "H15049901371" {
  33248. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  33249. utils.ErrorLog("解析失败:%v", err)
  33250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33251. return
  33252. }
  33253. res.ErrMsg = res10265.ErrMsg
  33254. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  33255. res.Infcode = infocode
  33256. res.Output = res10265.Output
  33257. res.InfRefmsgid = res10265.InfRefmsgid
  33258. } else {
  33259. if err := json.Unmarshal([]byte(result), &res); err != nil {
  33260. utils.ErrorLog("解析失败:%v", err)
  33261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33262. return
  33263. }
  33264. }
  33265. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  33266. infoStr := string(Iinfos)
  33267. var rf []*ResultFive
  33268. json.Unmarshal([]byte(infoStr), &rf)
  33269. var insuplc_admdvs string
  33270. var insutype string
  33271. var is390 int = 0
  33272. var is310 int = 0
  33273. var insutypes []*ResultFive
  33274. for _, item := range rf {
  33275. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  33276. insutypes = append(insutypes, item)
  33277. }
  33278. }
  33279. if len(insutypes) == 1 {
  33280. insutype = insutypes[0].Insutype
  33281. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  33282. } else {
  33283. for _, i := range insutypes {
  33284. if i.Insutype == "390" {
  33285. is390 = 1
  33286. }
  33287. if i.Insutype == "310" {
  33288. is310 = 1
  33289. }
  33290. }
  33291. }
  33292. if is390 == 1 {
  33293. insutype = "390"
  33294. }
  33295. if is310 == 1 {
  33296. insutype = "310"
  33297. }
  33298. if len(insutypes) == 0 {
  33299. insutype = "310"
  33300. }
  33301. insutype = psn_record.Insutype
  33302. for _, item := range rf {
  33303. if item.Insutype == insutype {
  33304. insuplc_admdvs = item.InsuplcAdmdvs
  33305. }
  33306. }
  33307. if config.IsOpen == 1 {
  33308. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  33309. var dat map[string]interface{}
  33310. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33311. fmt.Println(dat)
  33312. } else {
  33313. fmt.Println(err)
  33314. }
  33315. userJSONBytes, _ := json.Marshal(dat)
  33316. var res ResultFourteen
  33317. var res10265 ResultFourteen10265
  33318. if miConfig.Code == "H15049901371" {
  33319. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  33320. utils.ErrorLog("解析失败:%v", err)
  33321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33322. return
  33323. }
  33324. res.ErrMsg = res10265.ErrMsg
  33325. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  33326. res.Infcode = infocode
  33327. res.Output = res10265.Output
  33328. res.InfRefmsgid = res10265.InfRefmsgid
  33329. } else {
  33330. if err := json.Unmarshal([]byte(result), &res); err != nil {
  33331. utils.ErrorLog("解析失败:%v", err)
  33332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33333. return
  33334. }
  33335. }
  33336. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33337. // utils.ErrorLog("解析失败:%v", err)
  33338. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33339. // return
  33340. //}
  33341. if res.Infcode == 0 {
  33342. psn_record.IsCancel = 2
  33343. service.CreatePsnNCDSRecord(&psn_record)
  33344. c.ServeSuccessJSON(map[string]interface{}{
  33345. "failed_code": 0,
  33346. "msg": "撤销备案成功",
  33347. })
  33348. } else {
  33349. c.ServeSuccessJSON(map[string]interface{}{
  33350. "failed_code": -10,
  33351. "msg": res.ErrMsg,
  33352. })
  33353. return
  33354. }
  33355. }
  33356. }
  33357. func (c *HisApiController) TestTest() {
  33358. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  33359. fmt.Println(patient.Iinfo)
  33360. }
  33361. type CustomData struct {
  33362. MsgId string
  33363. PsnNo string
  33364. Info string
  33365. }
  33366. func (c *HisApiController) ReversalData() {
  33367. var customData []*CustomData
  33368. custom := &CustomData{
  33369. MsgId: "H44022900158202103301714472004",
  33370. PsnNo: "44020000001101329945",
  33371. Info: "2207",
  33372. }
  33373. customData = append(customData, custom)
  33374. custom1 := &CustomData{
  33375. MsgId: "H4402290015820210330172057803",
  33376. PsnNo: "44020000001101161813",
  33377. Info: "2207",
  33378. }
  33379. customData = append(customData, custom1)
  33380. custom2 := &CustomData{
  33381. MsgId: "H44022900158202103301705198813",
  33382. PsnNo: "44190000133097375417",
  33383. Info: "2207",
  33384. }
  33385. customData = append(customData, custom2)
  33386. custom3 := &CustomData{
  33387. MsgId: "H44022900158202103301715524756",
  33388. PsnNo: "44020000001100187221",
  33389. Info: "2207",
  33390. }
  33391. customData = append(customData, custom3)
  33392. custom4 := &CustomData{
  33393. MsgId: "H44022900158202103301730376224",
  33394. PsnNo: "44020000001101959155",
  33395. Info: "2207",
  33396. }
  33397. customData = append(customData, custom4)
  33398. custom5 := &CustomData{
  33399. MsgId: "H44022900158202103301748008725",
  33400. PsnNo: "44020000001104246641",
  33401. Info: "2207",
  33402. }
  33403. customData = append(customData, custom5)
  33404. custom6 := &CustomData{
  33405. MsgId: "H44022900158202103301718096755",
  33406. PsnNo: "44020000001102211860",
  33407. Info: "2207",
  33408. }
  33409. customData = append(customData, custom6)
  33410. custom7 := &CustomData{
  33411. MsgId: "H44022900158202103301736551640",
  33412. PsnNo: "44020000001102687718",
  33413. Info: "2207",
  33414. }
  33415. customData = append(customData, custom7)
  33416. custom8 := &CustomData{
  33417. MsgId: "H44022900158202103301743097676",
  33418. PsnNo: "44020000001102127785",
  33419. Info: "2207",
  33420. }
  33421. customData = append(customData, custom8)
  33422. custom9 := &CustomData{
  33423. MsgId: "H44022900158202103301712304203",
  33424. PsnNo: "44020000001101518097",
  33425. Info: "2207",
  33426. }
  33427. customData = append(customData, custom9)
  33428. custom10 := &CustomData{
  33429. MsgId: "H44022900158202103301738448785",
  33430. PsnNo: "44020000001100500813",
  33431. Info: "2207",
  33432. }
  33433. customData = append(customData, custom10)
  33434. custom11 := &CustomData{
  33435. MsgId: "H44022900158202103301732455843",
  33436. PsnNo: "44020000001102690557",
  33437. Info: "2207",
  33438. }
  33439. customData = append(customData, custom11)
  33440. custom12 := &CustomData{
  33441. MsgId: "H44022900158202103301745421708",
  33442. PsnNo: "44020000001102211928",
  33443. Info: "2207",
  33444. }
  33445. customData = append(customData, custom12)
  33446. custom1212 := &CustomData{
  33447. MsgId: "H440229001582021033017351627",
  33448. PsnNo: "44020000001102481733",
  33449. Info: "2207",
  33450. }
  33451. customData = append(customData, custom1212)
  33452. custom13 := &CustomData{
  33453. MsgId: "H44022900158202103301740327951",
  33454. PsnNo: "44020000001103174866",
  33455. Info: "2207",
  33456. }
  33457. customData = append(customData, custom13)
  33458. custom14 := &CustomData{
  33459. MsgId: "H4402290015820210330174922668",
  33460. PsnNo: "44020000001102927272",
  33461. Info: "2207",
  33462. }
  33463. customData = append(customData, custom14)
  33464. custom15 := &CustomData{
  33465. MsgId: "H44022900158202103301752362273",
  33466. PsnNo: "44020000001102942890",
  33467. Info: "2207",
  33468. }
  33469. customData = append(customData, custom15)
  33470. custom16 := &CustomData{
  33471. MsgId: "H44022900158202103301751082917",
  33472. PsnNo: "44020000001101662162",
  33473. Info: "2207",
  33474. }
  33475. customData = append(customData, custom16)
  33476. custom17 := &CustomData{
  33477. MsgId: "H44022900158202103301754147728",
  33478. PsnNo: "44020000000229014511",
  33479. Info: "2207",
  33480. }
  33481. customData = append(customData, custom17)
  33482. adminUser := c.GetAdminUserInfo()
  33483. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33484. for _, item := range customData {
  33485. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  33486. fmt.Println(result)
  33487. }
  33488. }
  33489. func (c *HisApiController) GetAllopatry() {
  33490. year := c.GetString("year")
  33491. month := c.GetString("month")
  33492. admin_user_id, _ := c.GetInt64("admin_user_id")
  33493. adminUser := c.GetAdminUserInfo()
  33494. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33495. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33496. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  33497. var dat map[string]interface{}
  33498. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33499. fmt.Println(dat)
  33500. } else {
  33501. fmt.Println(err)
  33502. }
  33503. userJSONBytes, _ := json.Marshal(dat)
  33504. var res models.Result9001
  33505. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33506. utils.ErrorLog("解析失败:%v", err)
  33507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33508. return
  33509. }
  33510. fmt.Println(res.Output.Signinoutb)
  33511. fmt.Println(res.Output.Signinoutb.SignNo)
  33512. fmt.Println(string(userJSONBytes))
  33513. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  33514. var dat3 map[string]interface{}
  33515. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  33516. fmt.Println(dat3)
  33517. } else {
  33518. fmt.Println(err)
  33519. }
  33520. userJSONBytes3, _ := json.Marshal(dat3)
  33521. var res3 models.Result3260
  33522. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  33523. utils.ErrorLog("解析失败:%v", err)
  33524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33525. return
  33526. }
  33527. var curpage int
  33528. var pagesize int = 100
  33529. var start int = 1
  33530. //var stop int
  33531. //pagecount := 10
  33532. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  33533. var res22 []models.Result3260
  33534. for curpage = 1; curpage <= pagecount; curpage++ {
  33535. if curpage == 1 {
  33536. start = 0
  33537. } else {
  33538. start = (curpage-1)*pagesize + 1
  33539. }
  33540. fmt.Println(start)
  33541. //stop = curpage * pagesize
  33542. //if stop > int(res3.Output.Totalrow) {
  33543. // stop =int(res3.Output.Totalrow)
  33544. //}
  33545. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  33546. var dat2 map[string]interface{}
  33547. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  33548. fmt.Println(dat)
  33549. } else {
  33550. fmt.Println(err)
  33551. }
  33552. userJSONBytes2, _ := json.Marshal(dat2)
  33553. var res2 models.Result3260
  33554. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  33555. utils.ErrorLog("解析失败:%v", err)
  33556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33557. return
  33558. }
  33559. if res2.Infcode == 0 {
  33560. res22 = append(res22, res2)
  33561. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  33562. //var dat2 map[string]interface{}
  33563. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  33564. // fmt.Println(dat)
  33565. //} else {
  33566. // fmt.Println(err)
  33567. //}
  33568. //c.ServeSuccessJSON(map[string]interface{}{
  33569. // "list": res2.Output.Data,
  33570. //})
  33571. //continue
  33572. }
  33573. }
  33574. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  33575. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  33576. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  33577. //var dat2 map[string]interface{}
  33578. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  33579. // fmt.Println(dat)
  33580. //} else {
  33581. // fmt.Println(err)
  33582. //}
  33583. //userJSONBytes2, _ := json.Marshal(dat2)
  33584. //var res2 models.Result3260
  33585. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  33586. // utils.ErrorLog("解析失败:%v", err)
  33587. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33588. // return
  33589. //}
  33590. //if res2.Infcode == 0 {
  33591. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  33592. // var dat2 map[string]interface{}
  33593. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  33594. // fmt.Println(dat)
  33595. // } else {
  33596. // fmt.Println(err)
  33597. // }
  33598. // c.ServeSuccessJSON(map[string]interface{}{
  33599. // "list": res2.Output.Data,
  33600. // })
  33601. //}
  33602. }
  33603. func (c *HisApiController) ComfirmAllopatry() {
  33604. year := c.GetString("year")
  33605. month := c.GetString("month")
  33606. admin_user_id, _ := c.GetInt64("admin_user_id")
  33607. adminUser := c.GetAdminUserInfo()
  33608. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33609. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33610. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  33611. var dat map[string]interface{}
  33612. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33613. fmt.Println(dat)
  33614. } else {
  33615. fmt.Println(err)
  33616. }
  33617. userJSONBytes, _ := json.Marshal(dat)
  33618. var res models.Result9001
  33619. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33620. utils.ErrorLog("解析失败:%v", err)
  33621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33622. return
  33623. }
  33624. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  33625. var dat2 map[string]interface{}
  33626. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  33627. fmt.Println(dat)
  33628. } else {
  33629. fmt.Println(err)
  33630. }
  33631. userJSONBytes2, _ := json.Marshal(dat2)
  33632. var res2 models.Result3260
  33633. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  33634. utils.ErrorLog("解析失败:%v", err)
  33635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33636. return
  33637. }
  33638. //if res2.Infcode == 0 {
  33639. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  33640. // var dat map[string]interface{}
  33641. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33642. // fmt.Println(dat)
  33643. // } else {
  33644. // fmt.Println(err)
  33645. // }
  33646. // userJSONBytes, _ := json.Marshal(dat)
  33647. // var res3 models.Result3261
  33648. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  33649. // utils.ErrorLog("解析失败:%v", err)
  33650. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33651. // return
  33652. // }
  33653. //
  33654. // if res3.Infcode == 0 {
  33655. // record := &models.HisYidiClearRecord{
  33656. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  33657. // Ctime: time.Now().Unix(),
  33658. // Mtime: time.Now().Unix(),
  33659. // Status: 1,
  33660. // MsgId: msgId,
  33661. // }
  33662. // service.SaveClearRecord(record)
  33663. // c.ServeSuccessJSON(map[string]interface{}{
  33664. // "msg": "提取成功",
  33665. // })
  33666. // }
  33667. //}
  33668. }
  33669. func (c *HisApiController) RefundAllopatry() {
  33670. year := c.GetString("year")
  33671. month := c.GetString("month")
  33672. //id, _ := c.GetInt64("id")
  33673. admin_user_id, _ := c.GetInt64("admin_user_id")
  33674. adminUser := c.GetAdminUserInfo()
  33675. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33676. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33677. //record, _ := service.GetClearRecordById(id)
  33678. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  33679. var dat map[string]interface{}
  33680. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33681. fmt.Println(dat)
  33682. } else {
  33683. fmt.Println(err)
  33684. }
  33685. userJSONBytes, _ := json.Marshal(dat)
  33686. var res models.Result9001
  33687. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33688. utils.ErrorLog("解析失败:%v", err)
  33689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33690. return
  33691. }
  33692. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  33693. var dat2 map[string]interface{}
  33694. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  33695. fmt.Println(dat)
  33696. } else {
  33697. fmt.Println(err)
  33698. }
  33699. userJSONBytes2, _ := json.Marshal(dat2)
  33700. var empty ResultFourteen
  33701. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  33702. utils.ErrorLog("解析失败:%v", err)
  33703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33704. return
  33705. }
  33706. if empty.Infcode == 0 {
  33707. c.ServeSuccessJSON(map[string]interface{}{
  33708. "msg": "撤销成功",
  33709. })
  33710. return
  33711. }
  33712. }
  33713. func (c *HisApiController) ReversalOtherData() {
  33714. var customData []*CustomData
  33715. custom := &CustomData{
  33716. MsgId: "H44022900158202103301714472004",
  33717. PsnNo: "44020000001101329945",
  33718. Info: "2208",
  33719. }
  33720. customData = append(customData, custom)
  33721. custom1 := &CustomData{
  33722. MsgId: "H4402290015820210330172057803",
  33723. PsnNo: "44020000001101161813",
  33724. Info: "2208",
  33725. }
  33726. customData = append(customData, custom1)
  33727. custom2 := &CustomData{
  33728. MsgId: "H44022900158202103301705198813",
  33729. PsnNo: "44190000133097375417",
  33730. Info: "2208",
  33731. }
  33732. customData = append(customData, custom2)
  33733. custom3 := &CustomData{
  33734. MsgId: "H44022900158202103301715524756",
  33735. PsnNo: "44020000001100187221",
  33736. Info: "2208",
  33737. }
  33738. customData = append(customData, custom3)
  33739. custom4 := &CustomData{
  33740. MsgId: "H44022900158202103301730376224",
  33741. PsnNo: "44020000001101959155",
  33742. Info: "2208",
  33743. }
  33744. customData = append(customData, custom4)
  33745. custom5 := &CustomData{
  33746. MsgId: "H44022900158202103301748008725",
  33747. PsnNo: "44020000001104246641",
  33748. Info: "2208",
  33749. }
  33750. customData = append(customData, custom5)
  33751. custom6 := &CustomData{
  33752. MsgId: "H44022900158202103301718096755",
  33753. PsnNo: "44020000001102211860",
  33754. Info: "2208",
  33755. }
  33756. customData = append(customData, custom6)
  33757. custom7 := &CustomData{
  33758. MsgId: "H44022900158202103301736551640",
  33759. PsnNo: "44020000001102687718",
  33760. Info: "2208",
  33761. }
  33762. customData = append(customData, custom7)
  33763. custom8 := &CustomData{
  33764. MsgId: "H44022900158202103301743097676",
  33765. PsnNo: "44020000001102127785",
  33766. Info: "2208",
  33767. }
  33768. customData = append(customData, custom8)
  33769. custom9 := &CustomData{
  33770. MsgId: "H44022900158202103301712304203",
  33771. PsnNo: "44020000001101518097",
  33772. Info: "2208",
  33773. }
  33774. customData = append(customData, custom9)
  33775. custom10 := &CustomData{
  33776. MsgId: "H44022900158202103301738448785",
  33777. PsnNo: "44020000001100500813",
  33778. Info: "2208",
  33779. }
  33780. customData = append(customData, custom10)
  33781. custom11 := &CustomData{
  33782. MsgId: "H44022900158202103301732455843",
  33783. PsnNo: "44020000001102690557",
  33784. Info: "2208",
  33785. }
  33786. customData = append(customData, custom11)
  33787. custom12 := &CustomData{
  33788. MsgId: "H44022900158202103301745421708",
  33789. PsnNo: "44020000001102211928",
  33790. Info: "2208",
  33791. }
  33792. customData = append(customData, custom12)
  33793. custom1212 := &CustomData{
  33794. MsgId: "H440229001582021033017351627",
  33795. PsnNo: "44020000001102481733",
  33796. Info: "2208",
  33797. }
  33798. customData = append(customData, custom1212)
  33799. custom13 := &CustomData{
  33800. MsgId: "H44022900158202103301740327951",
  33801. PsnNo: "44020000001103174866",
  33802. Info: "2208",
  33803. }
  33804. customData = append(customData, custom13)
  33805. custom14 := &CustomData{
  33806. MsgId: "H4402290015820210330174922668",
  33807. PsnNo: "44020000001102927272",
  33808. Info: "2208",
  33809. }
  33810. customData = append(customData, custom14)
  33811. custom15 := &CustomData{
  33812. MsgId: "H44022900158202103301752362273",
  33813. PsnNo: "44020000001102942890",
  33814. Info: "2208",
  33815. }
  33816. customData = append(customData, custom15)
  33817. custom16 := &CustomData{
  33818. MsgId: "H44022900158202103301751082917",
  33819. PsnNo: "44020000001101662162",
  33820. Info: "2208",
  33821. }
  33822. customData = append(customData, custom16)
  33823. custom17 := &CustomData{
  33824. MsgId: "H44022900158202103301754147728",
  33825. PsnNo: "44020000000229014511",
  33826. Info: "2208",
  33827. }
  33828. customData = append(customData, custom17)
  33829. adminUser := c.GetAdminUserInfo()
  33830. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33831. for _, item := range customData {
  33832. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  33833. fmt.Println(result)
  33834. }
  33835. }
  33836. func PathExists(path string) (bool, error) {
  33837. _, err := os.Stat(path)
  33838. if err == nil {
  33839. return true, nil
  33840. }
  33841. if os.IsNotExist(err) {
  33842. return false, nil
  33843. }
  33844. return false, err
  33845. }
  33846. // 创建文件夹
  33847. func Mkdir(dir string) {
  33848. // 创建文件夹
  33849. exist, err := PathExists(dir)
  33850. if err != nil {
  33851. fmt.Println(err.Error())
  33852. } else {
  33853. if exist {
  33854. fmt.Println(dir + "文件夹已存在!")
  33855. } else {
  33856. // 文件夹名称,权限
  33857. err := os.Mkdir(dir, os.ModePerm)
  33858. if err != nil {
  33859. fmt.Println(dir+"文件夹创建失败:", err.Error())
  33860. } else {
  33861. fmt.Println(dir + "文件夹创建成功!")
  33862. }
  33863. }
  33864. }
  33865. }
  33866. // 压缩文件
  33867. func Zip(srcFile string, destZip string) error {
  33868. zipfile, err := os.Create(destZip)
  33869. if err != nil {
  33870. return err
  33871. }
  33872. defer zipfile.Close()
  33873. archive := zip.NewWriter(zipfile)
  33874. defer archive.Close()
  33875. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  33876. if err != nil {
  33877. return err
  33878. }
  33879. header, err := zip.FileInfoHeader(info)
  33880. if err != nil {
  33881. return err
  33882. }
  33883. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  33884. // header.Name = path
  33885. if info.IsDir() {
  33886. header.Name += "/"
  33887. } else {
  33888. header.Method = zip.Deflate
  33889. }
  33890. writer, err := archive.CreateHeader(header)
  33891. if err != nil {
  33892. return err
  33893. }
  33894. if !info.IsDir() {
  33895. file, err := os.Open(path)
  33896. if err != nil {
  33897. return err
  33898. }
  33899. defer file.Close()
  33900. _, err = io.Copy(writer, file)
  33901. }
  33902. return err
  33903. })
  33904. return err
  33905. }
  33906. func ReadFile(filePath string) []byte {
  33907. f, err := os.Open(filePath)
  33908. if err != nil {
  33909. fmt.Println("read file fail", err)
  33910. return nil
  33911. }
  33912. defer f.Close()
  33913. fd, err := ioutil.ReadAll(f)
  33914. if err != nil {
  33915. fmt.Println("read to fd fail", err)
  33916. return nil
  33917. }
  33918. return fd
  33919. }
  33920. func saveLogq(result string, request string, infno string, desc string) {
  33921. dir := "日志"
  33922. utils.Mkdir(dir)
  33923. month := time.Unix(1557042972, 0).Format("1")
  33924. year := time.Now().Format("2006")
  33925. month = time.Now().Format("01")
  33926. day := time.Now().Format("02")
  33927. hour := time.Now().Format("15")
  33928. min := time.Now().Format("04")
  33929. sec := time.Now().Format("05")
  33930. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  33931. file := year + month + day + "_log"
  33932. file_name := file + ".txt"
  33933. file_path := "日志" + "/" + file_name
  33934. exist, _ := utils.PathExists(file_path)
  33935. if exist { //存在
  33936. fmt.Println("存在")
  33937. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  33938. if err != nil {
  33939. fmt.Println("read fail")
  33940. }
  33941. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  33942. n, _ := f.Seek(0, 2)
  33943. _, err = f.WriteAt([]byte(content), n)
  33944. } else { //不存在
  33945. fmt.Println("文件不存在,创建文件")
  33946. f, err := os.Create("日志" + "/" + file_name)
  33947. defer f.Close()
  33948. if err != nil {
  33949. } else {
  33950. _, err = f.Write([]byte("记录日志"))
  33951. }
  33952. }
  33953. }
  33954. func saveLog(result string, request string, infno string, desc string) {
  33955. org_id, _ := beego.AppConfig.Int64("org_id")
  33956. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  33957. dir := miConfig.OrgName + "日志"
  33958. utils.Mkdir(dir)
  33959. month := time.Unix(1557042972, 0).Format("1")
  33960. year := time.Now().Format("2006")
  33961. month = time.Now().Format("01")
  33962. day := time.Now().Format("02")
  33963. hour := time.Now().Format("15")
  33964. min := time.Now().Format("04")
  33965. sec := time.Now().Format("05")
  33966. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  33967. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  33968. file_name := file + ".txt"
  33969. file_path := miConfig.OrgName + "日志" + "/" + file_name
  33970. exist, _ := utils.PathExists(file_path)
  33971. if exist { //存在
  33972. fmt.Println("存在")
  33973. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  33974. if err != nil {
  33975. fmt.Println("read fail")
  33976. }
  33977. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  33978. n, _ := f.Seek(0, 2)
  33979. _, err = f.WriteAt([]byte(content), n)
  33980. } else { //不存在
  33981. fmt.Println("文件不存在,创建文件")
  33982. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  33983. defer f.Close()
  33984. if err != nil {
  33985. } else {
  33986. _, err = f.Write([]byte("记录日志"))
  33987. }
  33988. }
  33989. }
  33990. type Charset string
  33991. const (
  33992. UTF8 = Charset("UTF-8")
  33993. GB18030 = Charset("GB18030")
  33994. )
  33995. func ConvertToString(src string, srcCode string, tagCode string) string {
  33996. srcCoder := mahonia.NewDecoder(srcCode)
  33997. srcResult := srcCoder.ConvertString(src)
  33998. tagCoder := mahonia.NewDecoder(tagCode)
  33999. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  34000. result := string(cdata)
  34001. return result
  34002. }
  34003. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  34004. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  34005. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  34006. var token string
  34007. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34008. var api string
  34009. if miConfig.MdtrtareaAdmvs == "320921" {
  34010. 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 +
  34011. "&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
  34012. fmt.Println(api)
  34013. } else {
  34014. 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 +
  34015. "&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
  34016. }
  34017. resp, requestErr := http.Get(api)
  34018. if requestErr != nil {
  34019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34020. return ""
  34021. }
  34022. body, ioErr := ioutil.ReadAll(resp.Body)
  34023. if ioErr != nil {
  34024. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34026. return ""
  34027. }
  34028. var respJSON map[string]interface{}
  34029. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34030. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34032. return ""
  34033. }
  34034. var status string
  34035. status = respJSON["data"].(map[string]interface{})["status"].(string)
  34036. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  34037. var res ResultTwo //1101结果
  34038. var res10265 ResultTwo10265 //1101结果
  34039. if status == "0" { //读卡成功
  34040. var card_info string //卡信息
  34041. var busi_card_info string
  34042. token = respJSON["data"].(map[string]interface{})["token"].(string)
  34043. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  34044. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  34045. fmt.Println(card_info)
  34046. fmt.Println(busi_card_info)
  34047. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  34048. result, _ := json.Marshal(respJSON)
  34049. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  34050. utils.ErrorLog("解析失败:%v", err)
  34051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34052. return ""
  34053. }
  34054. res.ErrMsg = res10265.ErrMsg
  34055. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  34056. res.Infcode = infocode
  34057. res.Output = res10265.Output
  34058. res.InfRefmsgid = res10265.InfRefmsgid
  34059. if res.Infcode == 0 {
  34060. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  34061. if err == gorm.ErrRecordNotFound {
  34062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  34063. return ""
  34064. } else if err != nil {
  34065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  34066. return ""
  34067. } else {
  34068. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  34069. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  34070. infoStr := string(Iinfos)
  34071. idetinfoStr := string(Idetinfos)
  34072. psn := &models.HisPsn{
  34073. PsnNo: res.Output.Baseinfo.PsnNo,
  34074. PatientId: patient.ID,
  34075. Certno: res.Output.Baseinfo.Certno,
  34076. Gend: res.Output.Baseinfo.Gend,
  34077. Naty: res.Output.Baseinfo.Naty,
  34078. PsnCertType: res.Output.Baseinfo.PsnCertType,
  34079. PsnName: res.Output.Baseinfo.PsnName,
  34080. Idetinfo: idetinfoStr,
  34081. Insuinfo: infoStr,
  34082. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  34083. CardInfo: card_info,
  34084. VerifyNumber: token,
  34085. }
  34086. service.CreateHisPsn(psn)
  34087. return token
  34088. }
  34089. }
  34090. } else {
  34091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  34092. return ""
  34093. }
  34094. } else { //读卡失败
  34095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  34096. return ""
  34097. }
  34098. return token
  34099. }
  34100. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  34101. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  34102. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  34103. var token string
  34104. var api string
  34105. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  34106. "&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
  34107. fmt.Println(api)
  34108. resp, requestErr := http.Get(api)
  34109. if requestErr != nil {
  34110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34111. return ""
  34112. }
  34113. body, ioErr := ioutil.ReadAll(resp.Body)
  34114. if ioErr != nil {
  34115. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34117. return ""
  34118. }
  34119. var respJSON map[string]interface{}
  34120. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34121. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34123. return ""
  34124. }
  34125. var status string
  34126. status = respJSON["data"].(map[string]interface{})["status"].(string)
  34127. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  34128. var res ResultTwo //1101结果
  34129. if status == "1" { //读卡成功
  34130. var card_info string //卡信息
  34131. var busi_card_info string
  34132. token = respJSON["data"].(map[string]interface{})["token"].(string)
  34133. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  34134. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  34135. fmt.Println(card_info)
  34136. fmt.Println(busi_card_info)
  34137. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  34138. result, _ := json.Marshal(respJSON)
  34139. if err := json.Unmarshal([]byte(result), &res); err != nil {
  34140. utils.ErrorLog("解析失败:%v", err)
  34141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34142. return ""
  34143. }
  34144. if res.Infcode == 0 {
  34145. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  34146. if err == gorm.ErrRecordNotFound {
  34147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  34148. return ""
  34149. } else if err != nil {
  34150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  34151. return ""
  34152. } else {
  34153. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  34154. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  34155. infoStr := string(Iinfos)
  34156. idetinfoStr := string(Idetinfos)
  34157. psn := &models.HisPsn{
  34158. PsnNo: res.Output.Baseinfo.PsnNo,
  34159. PatientId: patient.ID,
  34160. Certno: res.Output.Baseinfo.Certno,
  34161. Gend: res.Output.Baseinfo.Gend,
  34162. Naty: res.Output.Baseinfo.Naty,
  34163. PsnCertType: res.Output.Baseinfo.PsnCertType,
  34164. PsnName: res.Output.Baseinfo.PsnName,
  34165. Idetinfo: idetinfoStr,
  34166. Insuinfo: infoStr,
  34167. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  34168. CardInfo: card_info,
  34169. VerifyNumber: token,
  34170. }
  34171. service.CreateHisPsn(psn)
  34172. return token
  34173. }
  34174. }
  34175. } else {
  34176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  34177. return ""
  34178. }
  34179. return token
  34180. }
  34181. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  34182. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  34183. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  34184. var token string
  34185. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  34186. var api string
  34187. if miConfig.MdtrtareaAdmvs == "320921" {
  34188. 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 +
  34189. "&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
  34190. fmt.Println(api)
  34191. } else {
  34192. 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 +
  34193. "&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
  34194. }
  34195. resp, requestErr := http.Get(api)
  34196. if requestErr != nil {
  34197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34198. return ""
  34199. }
  34200. body, ioErr := ioutil.ReadAll(resp.Body)
  34201. if ioErr != nil {
  34202. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34204. return ""
  34205. }
  34206. var respJSON map[string]interface{}
  34207. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  34208. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34210. return ""
  34211. }
  34212. var status string
  34213. status = respJSON["data"].(map[string]interface{})["status"].(string)
  34214. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  34215. var res ResultTwo //1101结果
  34216. var res10265 ResultTwo10265 //1101结果
  34217. if status == "0" { //读卡成功
  34218. var card_info string //卡信息
  34219. var busi_card_info string
  34220. token = respJSON["data"].(map[string]interface{})["token"].(string)
  34221. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  34222. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  34223. fmt.Println(card_info)
  34224. fmt.Println(busi_card_info)
  34225. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  34226. result, _ := json.Marshal(respJSON)
  34227. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  34228. utils.ErrorLog("解析失败:%v", err)
  34229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34230. return ""
  34231. }
  34232. res.ErrMsg = res10265.ErrMsg
  34233. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  34234. res.Infcode = infocode
  34235. res.Output = res10265.Output
  34236. res.InfRefmsgid = res10265.InfRefmsgid
  34237. if res.Infcode == 0 {
  34238. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  34239. if err == gorm.ErrRecordNotFound {
  34240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  34241. return ""
  34242. } else if err != nil {
  34243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  34244. return ""
  34245. } else {
  34246. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  34247. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  34248. infoStr := string(Iinfos)
  34249. idetinfoStr := string(Idetinfos)
  34250. psn := &models.HisPsn{
  34251. PsnNo: res.Output.Baseinfo.PsnNo,
  34252. PatientId: patient.ID,
  34253. Certno: res.Output.Baseinfo.Certno,
  34254. Gend: res.Output.Baseinfo.Gend,
  34255. Naty: res.Output.Baseinfo.Naty,
  34256. PsnCertType: res.Output.Baseinfo.PsnCertType,
  34257. PsnName: res.Output.Baseinfo.PsnName,
  34258. Idetinfo: idetinfoStr,
  34259. Insuinfo: infoStr,
  34260. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  34261. CardInfo: card_info,
  34262. VerifyNumber: token,
  34263. }
  34264. service.CreateHisPsn(psn)
  34265. return token
  34266. }
  34267. }
  34268. } else {
  34269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  34270. return ""
  34271. }
  34272. } else { //读卡失败
  34273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  34274. return ""
  34275. }
  34276. return token
  34277. }
  34278. func DeleteExtraSpaceTwo(s string) string {
  34279. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  34280. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  34281. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  34282. reg, _ := regexp.Compile(regstr) //编译正则表达式
  34283. s2 := make([]byte, len(s1)) //定义字符数组切片
  34284. copy(s2, s1) //将字符串复制到切片
  34285. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  34286. for len(spc_index) > 0 { //找到适配项
  34287. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  34288. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  34289. }
  34290. return string(s2)
  34291. }
  34292. func Remove0000(s string) string {
  34293. str := make([]rune, 0, len(s))
  34294. for _, v := range []rune(s) {
  34295. if v == 0 {
  34296. continue
  34297. }
  34298. str = append(str, v)
  34299. }
  34300. return string(str)
  34301. }
  34302. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  34303. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  34304. readCard := DllDef.MustFindProc("EcQuery")
  34305. pCardInfo := make([]byte, 8192)
  34306. pBusiCardInfo := make([]byte, 8192)
  34307. data := make(map[string]interface{})
  34308. //pData := make(map[string]interface{})
  34309. inputData := make(map[string]interface{})
  34310. inputData["orgId"] = code
  34311. inputData["businessType"] = "01101"
  34312. inputData["operatorId"] = operator_id
  34313. inputData["operatorName"] = operator_name
  34314. inputData["officeId"] = "001"
  34315. inputData["officeName"] = "血透室"
  34316. //
  34317. data["data"] = inputData
  34318. data["transType"] = "ec.query"
  34319. data["orgId"] = code
  34320. bytesData, _ := json.Marshal(data)
  34321. pCardInfo = bytesData
  34322. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  34323. fmt.Println(ret2)
  34324. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  34325. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  34326. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  34327. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  34328. if ret2 != 0 {
  34329. return "", ""
  34330. }
  34331. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  34332. }
  34333. func DeleteExtraSpace(s string) string {
  34334. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  34335. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  34336. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  34337. reg, _ := regexp.Compile(regstr) //编译正则表达式
  34338. s2 := make([]byte, len(s1)) //定义字符数组切片
  34339. copy(s2, s1) //将字符串复制到切片
  34340. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  34341. for len(spc_index) > 0 { //找到适配项
  34342. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  34343. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  34344. }
  34345. return string(s2)
  34346. }
  34347. // 对账
  34348. func (c *HisApiController) Post3202() {
  34349. start_time := c.GetString("start_time")
  34350. end_time := c.GetString("end_time")
  34351. //insutype := c.GetString("insutype")
  34352. clr_type := c.GetString("clr_type")
  34353. clr_org := c.GetString("clr_optins")
  34354. admin_user_id, _ := c.GetInt64("admin_user_id")
  34355. adminUser := c.GetAdminUserInfo()
  34356. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34357. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34358. if len(clr_org) == 0 {
  34359. clr_org = miConfig.MdtrtareaAdmvs
  34360. }
  34361. timeLayout := "2006-01-02"
  34362. loc, _ := time.LoadLocation("Local")
  34363. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  34364. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  34365. var orders []*models.HisOrder
  34366. if clr_org == "421300" {
  34367. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34368. } else if clr_org == "420902" {
  34369. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34370. } else {
  34371. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34372. }
  34373. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  34374. //fixmedins_setl_cnt := int64(len(orders))
  34375. var medfee_sumamt float64
  34376. var acct_pay float64
  34377. var fund_pay_sumamt float64
  34378. for _, item := range orders {
  34379. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34380. acct_pay = acct_pay + item.AcctPay
  34381. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34382. }
  34383. //var medfee_sumamt_two float64
  34384. //var acct_pay_two float64
  34385. //var fund_pay_sumamt_two float64
  34386. //for _, item := range orders_two {
  34387. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  34388. // acct_pay_two = acct_pay_two + item.AcctPay
  34389. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  34390. //}
  34391. //var user_name string
  34392. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34393. //if role.ID == 0 {
  34394. // user_name = "xxx"
  34395. //} else {
  34396. // user_name = role.UserName
  34397. //}
  34398. var res ResultSix
  34399. if config.IsOpen == 1 {
  34400. var bps []*models.BusinessParamsTwo
  34401. var bp models.BusinessParamsTwo
  34402. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  34403. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  34404. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  34405. bp.MedfeeSumamt = medfee_sumamt_str
  34406. bp.AcctPay = acct_pay_str
  34407. bp.FundPaySumamt = fund_pay_sumamt_str
  34408. bp.Insutype = ""
  34409. bp.StmtBegndate = start_time
  34410. bp.ClrType = clr_type
  34411. bp.SetlOptins = clr_org
  34412. bp.StmtEnddate = end_time
  34413. bps = append(bps, &bp)
  34414. data := make(map[string]interface{})
  34415. data["bps"] = bps
  34416. data["org_name"] = miConfig.OrgName
  34417. data["doctor"] = role.UserName
  34418. data["fixmedins_code"] = miConfig.Code
  34419. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34420. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34421. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  34422. if miConfig.MdtrtareaAdmvs == "421300" {
  34423. client := &http.Client{}
  34424. bytesData, _ := json.Marshal(data)
  34425. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  34426. resp, _ := client.Do(req)
  34427. defer resp.Body.Close()
  34428. body, ioErr := ioutil.ReadAll(resp.Body)
  34429. if ioErr != nil {
  34430. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34432. return
  34433. }
  34434. var respJSON map[string]interface{}
  34435. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34436. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34438. return
  34439. }
  34440. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34441. userJSONBytes, _ := json.Marshal(respJSON)
  34442. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34443. utils.ErrorLog("解析失败:%v", err)
  34444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34445. return
  34446. }
  34447. }
  34448. if miConfig.MdtrtareaAdmvs == "420200" {
  34449. client := &http.Client{}
  34450. bytesData, _ := json.Marshal(data)
  34451. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  34452. resp, _ := client.Do(req)
  34453. defer resp.Body.Close()
  34454. body, ioErr := ioutil.ReadAll(resp.Body)
  34455. if ioErr != nil {
  34456. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34458. return
  34459. }
  34460. var respJSON map[string]interface{}
  34461. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34462. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34464. return
  34465. }
  34466. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34467. userJSONBytes, _ := json.Marshal(respJSON)
  34468. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34469. utils.ErrorLog("解析失败:%v", err)
  34470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34471. return
  34472. }
  34473. }
  34474. if miConfig.MdtrtareaAdmvs == "421182" {
  34475. client := &http.Client{}
  34476. bytesData, _ := json.Marshal(data)
  34477. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  34478. resp, _ := client.Do(req)
  34479. defer resp.Body.Close()
  34480. body, ioErr := ioutil.ReadAll(resp.Body)
  34481. if ioErr != nil {
  34482. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34484. return
  34485. }
  34486. var respJSON map[string]interface{}
  34487. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34488. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34490. return
  34491. }
  34492. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34493. userJSONBytes, _ := json.Marshal(respJSON)
  34494. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34495. utils.ErrorLog("解析失败:%v", err)
  34496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34497. return
  34498. }
  34499. }
  34500. if miConfig.MdtrtareaAdmvs == "420902" {
  34501. client := &http.Client{}
  34502. bytesData, _ := json.Marshal(data)
  34503. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  34504. resp, _ := client.Do(req)
  34505. defer resp.Body.Close()
  34506. body, ioErr := ioutil.ReadAll(resp.Body)
  34507. if ioErr != nil {
  34508. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34510. return
  34511. }
  34512. var respJSON map[string]interface{}
  34513. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34514. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34516. return
  34517. }
  34518. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34519. userJSONBytes, _ := json.Marshal(respJSON)
  34520. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34521. utils.ErrorLog("解析失败:%v", err)
  34522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34523. return
  34524. }
  34525. }
  34526. if res.Infcode == 0 {
  34527. c.ServeSuccessJSON(map[string]interface{}{
  34528. "msg": "发起成功",
  34529. })
  34530. } else {
  34531. c.ServeSuccessJSON(map[string]interface{}{
  34532. "failed_code": -10,
  34533. "msg": res.ErrMsg,
  34534. })
  34535. }
  34536. }
  34537. }
  34538. func (c *HisApiController) Post3204a() {
  34539. start_time := c.GetString("start_time")
  34540. end_time := c.GetString("end_time")
  34541. //insutype := c.GetString("insutype")
  34542. clr_type := c.GetString("clr_type")
  34543. clr_org := c.GetString("clr_optins")
  34544. admin_user_id, _ := c.GetInt64("admin_user_id")
  34545. adminUser := c.GetAdminUserInfo()
  34546. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34547. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34548. if len(clr_org) == 0 {
  34549. clr_org = miConfig.MdtrtareaAdmvs
  34550. }
  34551. timeLayout := "2006-01-02"
  34552. loc, _ := time.LoadLocation("Local")
  34553. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  34554. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  34555. var orders []*models.HisOrder
  34556. if clr_org == "421300" {
  34557. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34558. } else if clr_org == "420902" {
  34559. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34560. } else {
  34561. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34562. }
  34563. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  34564. //fixmedins_setl_cnt := int64(len(orders))
  34565. var medfee_sumamt float64
  34566. var acct_pay float64
  34567. var fund_pay_sumamt float64
  34568. for _, item := range orders {
  34569. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34570. acct_pay = acct_pay + item.AcctPay
  34571. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34572. }
  34573. //var medfee_sumamt_two float64
  34574. //var acct_pay_two float64
  34575. //var fund_pay_sumamt_two float64
  34576. //for _, item := range orders_two {
  34577. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  34578. // acct_pay_two = acct_pay_two + item.AcctPay
  34579. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  34580. //}
  34581. //var user_name string
  34582. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34583. //if role.ID == 0 {
  34584. // user_name = "xxx"
  34585. //} else {
  34586. // user_name = role.UserName
  34587. //}
  34588. var res ResultSix
  34589. if config.IsOpen == 1 {
  34590. var bps []*models.BusinessParamsTwo
  34591. var bp models.BusinessParamsTwo
  34592. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  34593. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  34594. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  34595. bp.MedfeeSumamt = medfee_sumamt_str
  34596. bp.AcctPay = acct_pay_str
  34597. bp.FundPaySumamt = fund_pay_sumamt_str
  34598. bp.Insutype = ""
  34599. bp.StmtBegndate = start_time
  34600. bp.ClrType = clr_type
  34601. bp.SetlOptins = clr_org
  34602. bp.StmtEnddate = end_time
  34603. bps = append(bps, &bp)
  34604. data := make(map[string]interface{})
  34605. data["bps"] = bps
  34606. data["org_name"] = miConfig.OrgName
  34607. data["doctor"] = role.UserName
  34608. data["fixmedins_code"] = miConfig.Code
  34609. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34610. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34611. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  34612. if miConfig.MdtrtareaAdmvs == "421300" {
  34613. client := &http.Client{}
  34614. bytesData, _ := json.Marshal(data)
  34615. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  34616. resp, _ := client.Do(req)
  34617. defer resp.Body.Close()
  34618. body, ioErr := ioutil.ReadAll(resp.Body)
  34619. if ioErr != nil {
  34620. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34622. return
  34623. }
  34624. var respJSON map[string]interface{}
  34625. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34626. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34628. return
  34629. }
  34630. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34631. userJSONBytes, _ := json.Marshal(respJSON)
  34632. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34633. utils.ErrorLog("解析失败:%v", err)
  34634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34635. return
  34636. }
  34637. }
  34638. if miConfig.MdtrtareaAdmvs == "420200" {
  34639. client := &http.Client{}
  34640. bytesData, _ := json.Marshal(data)
  34641. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  34642. resp, _ := client.Do(req)
  34643. defer resp.Body.Close()
  34644. body, ioErr := ioutil.ReadAll(resp.Body)
  34645. if ioErr != nil {
  34646. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34648. return
  34649. }
  34650. var respJSON map[string]interface{}
  34651. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34652. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34654. return
  34655. }
  34656. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34657. userJSONBytes, _ := json.Marshal(respJSON)
  34658. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34659. utils.ErrorLog("解析失败:%v", err)
  34660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34661. return
  34662. }
  34663. }
  34664. if miConfig.MdtrtareaAdmvs == "421182" {
  34665. client := &http.Client{}
  34666. bytesData, _ := json.Marshal(data)
  34667. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  34668. resp, _ := client.Do(req)
  34669. defer resp.Body.Close()
  34670. body, ioErr := ioutil.ReadAll(resp.Body)
  34671. if ioErr != nil {
  34672. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34674. return
  34675. }
  34676. var respJSON map[string]interface{}
  34677. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34678. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34680. return
  34681. }
  34682. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34683. userJSONBytes, _ := json.Marshal(respJSON)
  34684. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34685. utils.ErrorLog("解析失败:%v", err)
  34686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34687. return
  34688. }
  34689. }
  34690. if miConfig.MdtrtareaAdmvs == "420902" {
  34691. client := &http.Client{}
  34692. bytesData, _ := json.Marshal(data)
  34693. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  34694. resp, _ := client.Do(req)
  34695. defer resp.Body.Close()
  34696. body, ioErr := ioutil.ReadAll(resp.Body)
  34697. if ioErr != nil {
  34698. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34700. return
  34701. }
  34702. var respJSON map[string]interface{}
  34703. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34704. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34706. return
  34707. }
  34708. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34709. userJSONBytes, _ := json.Marshal(respJSON)
  34710. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34711. utils.ErrorLog("解析失败:%v", err)
  34712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34713. return
  34714. }
  34715. }
  34716. if res.Infcode == 0 {
  34717. c.ServeSuccessJSON(map[string]interface{}{
  34718. "msg": "撤销成功",
  34719. })
  34720. } else {
  34721. c.ServeSuccessJSON(map[string]interface{}{
  34722. "failed_code": -10,
  34723. "msg": res.ErrMsg,
  34724. })
  34725. }
  34726. }
  34727. }
  34728. func (c *HisApiController) Post3204() {
  34729. admin_user_id, _ := c.GetInt64("admin_user_id")
  34730. id := c.GetString("id")
  34731. adminUser := c.GetAdminUserInfo()
  34732. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34733. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34734. //clr_org := miConfig.MdtrtareaAdmvs
  34735. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34736. var res ResultSix
  34737. if config.IsOpen == 1 {
  34738. data := make(map[string]interface{})
  34739. data["id"] = id
  34740. data["org_name"] = miConfig.OrgName
  34741. data["doctor"] = role.UserName
  34742. data["fixmedins_code"] = miConfig.Code
  34743. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34744. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  34745. client := &http.Client{}
  34746. bytesData, _ := json.Marshal(data)
  34747. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  34748. resp, _ := client.Do(req)
  34749. defer resp.Body.Close()
  34750. body, ioErr := ioutil.ReadAll(resp.Body)
  34751. if ioErr != nil {
  34752. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34754. return
  34755. }
  34756. var respJSON map[string]interface{}
  34757. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34758. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34760. return
  34761. }
  34762. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34763. userJSONBytes, _ := json.Marshal(respJSON)
  34764. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34765. utils.ErrorLog("解析失败:%v", err)
  34766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34767. return
  34768. }
  34769. if res.Infcode == 0 {
  34770. c.ServeSuccessJSON(map[string]interface{}{
  34771. "msg": "发起成功",
  34772. })
  34773. } else {
  34774. c.ServeSuccessJSON(map[string]interface{}{
  34775. "failed_code": -10,
  34776. "msg": res.ErrMsg,
  34777. })
  34778. }
  34779. }
  34780. }
  34781. func (c *HisApiController) Post8404() {
  34782. admin_user_id, _ := c.GetInt64("admin_user_id")
  34783. month := c.GetString("month")
  34784. adminUser := c.GetAdminUserInfo()
  34785. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34786. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34787. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34788. var res ResultSix
  34789. if config.IsOpen == 1 {
  34790. data := make(map[string]interface{})
  34791. data["month"] = month
  34792. data["org_name"] = miConfig.OrgName
  34793. data["doctor"] = role.UserName
  34794. data["fixmedins_code"] = miConfig.Code
  34795. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34796. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  34797. client := &http.Client{}
  34798. bytesData, _ := json.Marshal(data)
  34799. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  34800. resp, _ := client.Do(req)
  34801. defer resp.Body.Close()
  34802. body, ioErr := ioutil.ReadAll(resp.Body)
  34803. if ioErr != nil {
  34804. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34806. return
  34807. }
  34808. var respJSON map[string]interface{}
  34809. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34810. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34812. return
  34813. }
  34814. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34815. userJSONBytes, _ := json.Marshal(respJSON)
  34816. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34817. utils.ErrorLog("解析失败:%v", err)
  34818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34819. return
  34820. }
  34821. if res.Infcode == 0 {
  34822. c.ServeSuccessJSON(map[string]interface{}{
  34823. "msg": "查询成功",
  34824. })
  34825. } else {
  34826. c.ServeSuccessJSON(map[string]interface{}{
  34827. "failed_code": -10,
  34828. "msg": res.ErrMsg,
  34829. })
  34830. }
  34831. }
  34832. }
  34833. func (c *HisApiController) Post3202b() {
  34834. start_time := c.GetString("start_time")
  34835. end_time := c.GetString("end_time")
  34836. //insutype := c.GetString("insutype")
  34837. clr_type := c.GetString("clr_type")
  34838. clr_org := c.GetString("clr_optins")
  34839. admin_user_id, _ := c.GetInt64("admin_user_id")
  34840. adminUser := c.GetAdminUserInfo()
  34841. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34842. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34843. if len(clr_org) == 0 {
  34844. clr_org = miConfig.MdtrtareaAdmvs
  34845. }
  34846. timeLayout := "2006-01-02"
  34847. loc, _ := time.LoadLocation("Local")
  34848. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  34849. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  34850. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  34851. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  34852. //fixmedins_setl_cnt := int64(len(orders))
  34853. var medfee_sumamt float64
  34854. var acct_pay float64
  34855. var fund_pay_sumamt float64
  34856. for _, item := range orders {
  34857. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  34858. acct_pay = acct_pay + item.AcctPay
  34859. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  34860. }
  34861. //var medfee_sumamt_two float64
  34862. //var acct_pay_two float64
  34863. //var fund_pay_sumamt_two float64
  34864. //for _, item := range orders_two {
  34865. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  34866. // acct_pay_two = acct_pay_two + item.AcctPay
  34867. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  34868. //}
  34869. //var user_name string
  34870. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34871. //if role.ID == 0 {
  34872. // user_name = "xxx"
  34873. //} else {
  34874. // user_name = role.UserName
  34875. //}
  34876. var res ResultSix
  34877. if config.IsOpen == 1 {
  34878. var bps []*models.BusinessParamsTwo
  34879. var bp models.BusinessParamsTwo
  34880. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  34881. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  34882. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  34883. bp.MedfeeSumamt = medfee_sumamt_str
  34884. bp.AcctPay = acct_pay_str
  34885. bp.FundPaySumamt = fund_pay_sumamt_str
  34886. bp.Insutype = "390"
  34887. bp.StmtBegndate = start_time
  34888. bp.ClrType = clr_type
  34889. bp.SetlOptins = clr_org
  34890. bp.StmtEnddate = end_time
  34891. bps = append(bps, &bp)
  34892. data := make(map[string]interface{})
  34893. data["bps"] = bps
  34894. data["org_name"] = miConfig.OrgName
  34895. data["doctor"] = role.UserName
  34896. data["fixmedins_code"] = miConfig.Code
  34897. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  34898. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  34899. if miConfig.MdtrtareaAdmvs == "421300" {
  34900. client := &http.Client{}
  34901. bytesData, _ := json.Marshal(data)
  34902. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  34903. resp, _ := client.Do(req)
  34904. defer resp.Body.Close()
  34905. body, ioErr := ioutil.ReadAll(resp.Body)
  34906. if ioErr != nil {
  34907. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34909. return
  34910. }
  34911. var respJSON map[string]interface{}
  34912. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34913. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34915. return
  34916. }
  34917. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34918. userJSONBytes, _ := json.Marshal(respJSON)
  34919. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34920. utils.ErrorLog("解析失败:%v", err)
  34921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34922. return
  34923. }
  34924. }
  34925. if miConfig.MdtrtareaAdmvs == "420200" {
  34926. client := &http.Client{}
  34927. bytesData, _ := json.Marshal(data)
  34928. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  34929. resp, _ := client.Do(req)
  34930. defer resp.Body.Close()
  34931. body, ioErr := ioutil.ReadAll(resp.Body)
  34932. if ioErr != nil {
  34933. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34935. return
  34936. }
  34937. var respJSON map[string]interface{}
  34938. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34939. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34941. return
  34942. }
  34943. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34944. userJSONBytes, _ := json.Marshal(respJSON)
  34945. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34946. utils.ErrorLog("解析失败:%v", err)
  34947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34948. return
  34949. }
  34950. }
  34951. if miConfig.MdtrtareaAdmvs == "421182" {
  34952. client := &http.Client{}
  34953. bytesData, _ := json.Marshal(data)
  34954. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  34955. resp, _ := client.Do(req)
  34956. defer resp.Body.Close()
  34957. body, ioErr := ioutil.ReadAll(resp.Body)
  34958. if ioErr != nil {
  34959. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  34960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34961. return
  34962. }
  34963. var respJSON map[string]interface{}
  34964. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  34965. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34967. return
  34968. }
  34969. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34970. userJSONBytes, _ := json.Marshal(respJSON)
  34971. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  34972. utils.ErrorLog("解析失败:%v", err)
  34973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34974. return
  34975. }
  34976. }
  34977. if res.Infcode == 0 {
  34978. c.ServeSuccessJSON(map[string]interface{}{
  34979. "msg": "发起成功",
  34980. })
  34981. } else {
  34982. c.ServeSuccessJSON(map[string]interface{}{
  34983. "failed_code": -10,
  34984. "msg": res.ErrMsg,
  34985. })
  34986. }
  34987. }
  34988. }
  34989. func (c *HisApiController) Post1608() {
  34990. start_time := c.GetString("start_time")
  34991. end_time := c.GetString("end_time")
  34992. admin_user_id, _ := c.GetInt64("admin_user_id")
  34993. adminUser := c.GetAdminUserInfo()
  34994. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34995. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34996. timeLayout := "2006-01-02"
  34997. loc, _ := time.LoadLocation("Local")
  34998. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  34999. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  35000. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  35001. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  35002. fixmedins_setl_cnt := int64(len(orders))
  35003. var medfee_sumamt float64
  35004. var func_smamt float64
  35005. for _, item := range orders {
  35006. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35007. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  35008. }
  35009. times := strings.Split(start_time, "-")
  35010. time_tows := strings.Split(end_time, "-")
  35011. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35012. var res ResultSix
  35013. if config.IsOpen == 1 {
  35014. //var bps []*models.BusinessParamsTwo
  35015. //var bp models.BusinessParamsTwo
  35016. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  35017. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  35018. data := make(map[string]interface{})
  35019. data["org_name"] = miConfig.OrgName
  35020. data["doctor"] = role.UserName
  35021. data["func_smamt"] = func_smamt_str
  35022. data["fixmedins_code"] = miConfig.Code
  35023. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35024. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35025. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  35026. data["medfee_sumamt"] = medfee_sumamt_str
  35027. data["start_time"] = times[0] + times[1] + times[2]
  35028. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  35029. if miConfig.MdtrtareaAdmvs == "421300" {
  35030. client := &http.Client{}
  35031. bytesData, _ := json.Marshal(data)
  35032. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  35033. resp, _ := client.Do(req)
  35034. defer resp.Body.Close()
  35035. body, ioErr := ioutil.ReadAll(resp.Body)
  35036. if ioErr != nil {
  35037. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35039. return
  35040. }
  35041. var respJSON map[string]interface{}
  35042. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35043. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35045. return
  35046. }
  35047. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35048. userJSONBytes, _ := json.Marshal(respJSON)
  35049. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35050. utils.ErrorLog("解析失败:%v", err)
  35051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35052. return
  35053. }
  35054. }
  35055. if miConfig.MdtrtareaAdmvs == "420200" {
  35056. client := &http.Client{}
  35057. bytesData, _ := json.Marshal(data)
  35058. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  35059. resp, _ := client.Do(req)
  35060. defer resp.Body.Close()
  35061. body, ioErr := ioutil.ReadAll(resp.Body)
  35062. if ioErr != nil {
  35063. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35065. return
  35066. }
  35067. var respJSON map[string]interface{}
  35068. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35069. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35071. return
  35072. }
  35073. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35074. userJSONBytes, _ := json.Marshal(respJSON)
  35075. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35076. utils.ErrorLog("解析失败:%v", err)
  35077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35078. return
  35079. }
  35080. }
  35081. if miConfig.MdtrtareaAdmvs == "421182" {
  35082. client := &http.Client{}
  35083. bytesData, _ := json.Marshal(data)
  35084. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  35085. resp, _ := client.Do(req)
  35086. defer resp.Body.Close()
  35087. body, ioErr := ioutil.ReadAll(resp.Body)
  35088. if ioErr != nil {
  35089. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35091. return
  35092. }
  35093. var respJSON map[string]interface{}
  35094. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35095. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35097. return
  35098. }
  35099. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35100. userJSONBytes, _ := json.Marshal(respJSON)
  35101. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35102. utils.ErrorLog("解析失败:%v", err)
  35103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35104. return
  35105. }
  35106. }
  35107. if res.Infcode == 0 {
  35108. c.ServeSuccessJSON(map[string]interface{}{
  35109. "msg": "发起成功",
  35110. })
  35111. } else {
  35112. c.ServeSuccessJSON(map[string]interface{}{
  35113. "failed_code": -10,
  35114. "msg": res.ErrMsg,
  35115. })
  35116. }
  35117. }
  35118. }
  35119. // 5.11.1.1【5262】结算信息按时间段查询
  35120. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  35121. admin_user_id, _ := c.GetInt64("admin_user_id")
  35122. adminUser := c.GetAdminUserInfo()
  35123. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35124. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35125. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35126. var res Result5262
  35127. if config.IsOpen == 1 {
  35128. if miConfig.MdtrtareaAdmvs == "421300" {
  35129. data := make(map[string]interface{})
  35130. data["bps"] = bp
  35131. data["org_name"] = miConfig.OrgName
  35132. data["doctor"] = role.UserName
  35133. data["fixmedins_code"] = miConfig.Code
  35134. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35135. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35136. data["page"] = strconv.FormatInt(page, 10)
  35137. data["limit"] = strconv.FormatInt(limit, 10)
  35138. fmt.Println(data)
  35139. client := &http.Client{}
  35140. bytesData, _ := json.Marshal(data)
  35141. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  35142. resp, _ := client.Do(req)
  35143. defer resp.Body.Close()
  35144. body, ioErr := ioutil.ReadAll(resp.Body)
  35145. if ioErr != nil {
  35146. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35148. return
  35149. }
  35150. var respJSON map[string]interface{}
  35151. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35152. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35154. return
  35155. }
  35156. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35157. userJSONBytes, _ := json.Marshal(respJSON)
  35158. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35159. utils.ErrorLog("解析失败:%v", err)
  35160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35161. return
  35162. }
  35163. }
  35164. if miConfig.MdtrtareaAdmvs == "420200" {
  35165. data := make(map[string]interface{})
  35166. data["bps"] = bp
  35167. data["org_name"] = miConfig.OrgName
  35168. data["doctor"] = role.UserName
  35169. data["fixmedins_code"] = miConfig.Code
  35170. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35171. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35172. data["page"] = strconv.FormatInt(page, 10)
  35173. data["limit"] = strconv.FormatInt(limit, 10)
  35174. fmt.Println(data)
  35175. client := &http.Client{}
  35176. bytesData, _ := json.Marshal(data)
  35177. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  35178. resp, _ := client.Do(req)
  35179. defer resp.Body.Close()
  35180. body, ioErr := ioutil.ReadAll(resp.Body)
  35181. if ioErr != nil {
  35182. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35184. return
  35185. }
  35186. var respJSON map[string]interface{}
  35187. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35188. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35190. return
  35191. }
  35192. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35193. userJSONBytes, _ := json.Marshal(respJSON)
  35194. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35195. utils.ErrorLog("解析失败:%v", err)
  35196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35197. return
  35198. }
  35199. }
  35200. if miConfig.MdtrtareaAdmvs == "421182" {
  35201. data := make(map[string]interface{})
  35202. data["bps"] = bp
  35203. data["org_name"] = miConfig.OrgName
  35204. data["doctor"] = role.UserName
  35205. data["fixmedins_code"] = miConfig.Code
  35206. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35207. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35208. data["page"] = strconv.FormatInt(page, 10)
  35209. data["limit"] = strconv.FormatInt(limit, 10)
  35210. fmt.Println(data)
  35211. client := &http.Client{}
  35212. bytesData, _ := json.Marshal(data)
  35213. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  35214. resp, _ := client.Do(req)
  35215. defer resp.Body.Close()
  35216. body, ioErr := ioutil.ReadAll(resp.Body)
  35217. if ioErr != nil {
  35218. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35220. return
  35221. }
  35222. var respJSON map[string]interface{}
  35223. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35224. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35226. return
  35227. }
  35228. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35229. userJSONBytes, _ := json.Marshal(respJSON)
  35230. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35231. utils.ErrorLog("解析失败:%v", err)
  35232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35233. return
  35234. }
  35235. }
  35236. if miConfig.MdtrtareaAdmvs == "420902" {
  35237. data := make(map[string]interface{})
  35238. data["bps"] = bp
  35239. data["org_name"] = miConfig.OrgName
  35240. data["doctor"] = role.UserName
  35241. data["fixmedins_code"] = miConfig.Code
  35242. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35243. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35244. data["page"] = strconv.FormatInt(page, 10)
  35245. data["limit"] = strconv.FormatInt(limit, 10)
  35246. fmt.Println(data)
  35247. client := &http.Client{}
  35248. bytesData, _ := json.Marshal(data)
  35249. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  35250. resp, _ := client.Do(req)
  35251. defer resp.Body.Close()
  35252. body, ioErr := ioutil.ReadAll(resp.Body)
  35253. if ioErr != nil {
  35254. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35256. return
  35257. }
  35258. var respJSON map[string]interface{}
  35259. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35260. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35262. return
  35263. }
  35264. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35265. userJSONBytes, _ := json.Marshal(respJSON)
  35266. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35267. utils.ErrorLog("解析失败:%v", err)
  35268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35269. return
  35270. }
  35271. }
  35272. if res.Infcode == 0 {
  35273. c.ServeSuccessJSON(map[string]interface{}{
  35274. "order": res.Output.Result,
  35275. "total": res.Output.PageInfo.RecordCounts,
  35276. })
  35277. } else {
  35278. c.ServeSuccessJSON(map[string]interface{}{
  35279. "failed_code": -10,
  35280. "msg": res.ErrMsg,
  35281. })
  35282. }
  35283. }
  35284. }
  35285. // 5.11.1.2【5267】异地结算信息时间段查询
  35286. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  35287. admin_user_id, _ := c.GetInt64("admin_user_id")
  35288. adminUser := c.GetAdminUserInfo()
  35289. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35290. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35291. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35292. var res Result5267
  35293. if config.IsOpen == 1 {
  35294. if miConfig.MdtrtareaAdmvs == "421300" {
  35295. data := make(map[string]interface{})
  35296. data["bps"] = bp
  35297. data["org_name"] = miConfig.OrgName
  35298. data["doctor"] = role.UserName
  35299. data["fixmedins_code"] = miConfig.Code
  35300. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35301. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35302. data["page"] = page
  35303. data["limit"] = limit
  35304. fmt.Println(data)
  35305. client := &http.Client{}
  35306. bytesData, _ := json.Marshal(data)
  35307. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  35308. resp, _ := client.Do(req)
  35309. defer resp.Body.Close()
  35310. body, ioErr := ioutil.ReadAll(resp.Body)
  35311. if ioErr != nil {
  35312. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35314. return
  35315. }
  35316. var respJSON map[string]interface{}
  35317. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35318. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35320. return
  35321. }
  35322. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35323. userJSONBytes, _ := json.Marshal(respJSON)
  35324. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35325. utils.ErrorLog("解析失败:%v", err)
  35326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35327. return
  35328. }
  35329. }
  35330. if miConfig.MdtrtareaAdmvs == "420200" {
  35331. data := make(map[string]interface{})
  35332. data["bps"] = bp
  35333. data["org_name"] = miConfig.OrgName
  35334. data["doctor"] = role.UserName
  35335. data["fixmedins_code"] = miConfig.Code
  35336. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35337. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35338. data["page"] = page
  35339. data["limit"] = limit
  35340. fmt.Println(data)
  35341. client := &http.Client{}
  35342. bytesData, _ := json.Marshal(data)
  35343. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  35344. resp, _ := client.Do(req)
  35345. defer resp.Body.Close()
  35346. body, ioErr := ioutil.ReadAll(resp.Body)
  35347. if ioErr != nil {
  35348. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35350. return
  35351. }
  35352. var respJSON map[string]interface{}
  35353. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35354. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35356. return
  35357. }
  35358. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35359. userJSONBytes, _ := json.Marshal(respJSON)
  35360. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35361. utils.ErrorLog("解析失败:%v", err)
  35362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35363. return
  35364. }
  35365. }
  35366. if miConfig.MdtrtareaAdmvs == "421182" {
  35367. data := make(map[string]interface{})
  35368. data["bps"] = bp
  35369. data["org_name"] = miConfig.OrgName
  35370. data["doctor"] = role.UserName
  35371. data["fixmedins_code"] = miConfig.Code
  35372. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  35373. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  35374. data["page"] = page
  35375. data["limit"] = limit
  35376. fmt.Println(data)
  35377. client := &http.Client{}
  35378. bytesData, _ := json.Marshal(data)
  35379. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  35380. resp, _ := client.Do(req)
  35381. defer resp.Body.Close()
  35382. body, ioErr := ioutil.ReadAll(resp.Body)
  35383. if ioErr != nil {
  35384. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35386. return
  35387. }
  35388. var respJSON map[string]interface{}
  35389. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35390. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35392. return
  35393. }
  35394. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35395. userJSONBytes, _ := json.Marshal(respJSON)
  35396. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35397. utils.ErrorLog("解析失败:%v", err)
  35398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35399. return
  35400. }
  35401. }
  35402. if res.Infcode == 0 {
  35403. c.ServeSuccessJSON(map[string]interface{}{
  35404. "order": res.Output.Result,
  35405. "total": res.Output.PageInfo.RecordCounts,
  35406. })
  35407. } else {
  35408. c.ServeSuccessJSON(map[string]interface{}{
  35409. "failed_code": -10,
  35410. "msg": res.ErrMsg,
  35411. })
  35412. }
  35413. }
  35414. }
  35415. func (c *HisApiController) Post3501() {
  35416. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35417. data := make(map[string]interface{})
  35418. var struct3501s []models.Struct3501
  35419. var struct3501 models.Struct3501
  35420. struct3501.OrgName = miConfig.OrgName
  35421. struct3501.AccessKey = miConfig.AccessKey
  35422. struct3501.RequestUrl = miConfig.Url
  35423. struct3501.SecretKey = miConfig.SecretKey
  35424. struct3501.ManuDate = "2022-08-17"
  35425. struct3501.FixmedinsBchno = ""
  35426. struct3501.ManuLotnum = ""
  35427. struct3501.RxFlag = "0"
  35428. struct3501.ExpyEnd = "2022-08-17"
  35429. struct3501.Invdate = "2022-08-17"
  35430. struct3501.InvCnt = "20.25"
  35431. struct3501.Memo = ""
  35432. struct3501.MedListCodg = "XB01ABD056B002020200517"
  35433. struct3501.FixmedinsHilistId = miConfig.Code
  35434. struct3501.FixmedinsHilistName = miConfig.OrgName
  35435. struct3501s = append(struct3501s, struct3501)
  35436. data["struct_3501s"] = struct3501s
  35437. client := &http.Client{}
  35438. bytesData, _ := json.Marshal(data)
  35439. var req *http.Request
  35440. if miConfig.MdtrtareaAdmvs == "320921" {
  35441. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35442. } else {
  35443. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35444. }
  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. var res ResultSix
  35460. var resSix10265 ResultSix10265 //1101结果
  35461. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  35462. result, _ := json.Marshal(respJSON)
  35463. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  35464. utils.ErrorLog("解析失败:%v", err)
  35465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35466. return
  35467. }
  35468. res.InfRefmsgid = resSix10265.InfRefmsgid
  35469. res.Output = resSix10265.Output
  35470. res.ErrMsg = resSix10265.ErrMsg
  35471. res.Cainfo = resSix10265.Cainfo
  35472. res.WarnMsg = resSix10265.WarnMsg
  35473. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35474. res.Infcode = infocode
  35475. if infocode == 0 {
  35476. c.ServeSuccessJSON(map[string]interface{}{
  35477. "msg": "上传成功",
  35478. })
  35479. return
  35480. } else {
  35481. c.ServeSuccessJSON(map[string]interface{}{
  35482. "failed_code": -10,
  35483. "msg": res.ErrMsg,
  35484. })
  35485. return
  35486. }
  35487. }
  35488. func (c *HisApiController) Post3502() {
  35489. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35490. data := make(map[string]interface{})
  35491. var struct3502s []models.Struct3502
  35492. var struct3502 models.Struct3502
  35493. struct3502.OrgName = miConfig.OrgName
  35494. struct3502.AccessKey = miConfig.AccessKey
  35495. struct3502.RequestUrl = miConfig.Url
  35496. struct3502.SecretKey = miConfig.SecretKey
  35497. struct3502.ManuDate = "2022-08-15"
  35498. struct3502.FixmedinsBchno = ""
  35499. struct3502.ManuLotnum = ""
  35500. struct3502.RxFlag = "0"
  35501. struct3502.ExpyEnd = "2022-08-15"
  35502. struct3502.Invdate = "2022-08-15"
  35503. struct3502.InvCnt = "20.25"
  35504. struct3502.Memo = ""
  35505. struct3502.MedListCodg = "XB01ABD056B002020200517"
  35506. struct3502.FixmedinsHilistId = miConfig.Code
  35507. struct3502.FixmedinsHilistName = miConfig.OrgName
  35508. struct3502s = append(struct3502s, struct3502)
  35509. data["struct_3502s"] = struct3502s
  35510. client := &http.Client{}
  35511. bytesData, _ := json.Marshal(data)
  35512. var req *http.Request
  35513. if miConfig.MdtrtareaAdmvs == "320921" {
  35514. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35515. } else {
  35516. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35517. }
  35518. resp, _ := client.Do(req)
  35519. defer resp.Body.Close()
  35520. body, ioErr := ioutil.ReadAll(resp.Body)
  35521. if ioErr != nil {
  35522. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35524. return
  35525. }
  35526. var respJSON map[string]interface{}
  35527. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35528. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35530. return
  35531. }
  35532. var res ResultSix
  35533. var resSix10265 ResultSix10265 //1101结果
  35534. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  35535. result, _ := json.Marshal(respJSON)
  35536. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  35537. utils.ErrorLog("解析失败:%v", err)
  35538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35539. return
  35540. }
  35541. res.InfRefmsgid = resSix10265.InfRefmsgid
  35542. res.Output = resSix10265.Output
  35543. res.ErrMsg = resSix10265.ErrMsg
  35544. res.Cainfo = resSix10265.Cainfo
  35545. res.WarnMsg = resSix10265.WarnMsg
  35546. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35547. res.Infcode = infocode
  35548. if infocode == 0 {
  35549. c.ServeSuccessJSON(map[string]interface{}{
  35550. "msg": "上传成功",
  35551. })
  35552. return
  35553. } else {
  35554. c.ServeSuccessJSON(map[string]interface{}{
  35555. "failed_code": -10,
  35556. "msg": res.ErrMsg,
  35557. })
  35558. return
  35559. }
  35560. }
  35561. func (c *HisApiController) Post3503() {
  35562. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35563. data := make(map[string]interface{})
  35564. var struct3501s []models.Struct3501
  35565. var struct3501 models.Struct3501
  35566. struct3501.OrgName = miConfig.OrgName
  35567. struct3501.AccessKey = miConfig.AccessKey
  35568. struct3501.RequestUrl = miConfig.Url
  35569. struct3501.SecretKey = miConfig.SecretKey
  35570. struct3501.ManuDate = "2022-08-15"
  35571. struct3501.FixmedinsBchno = ""
  35572. struct3501.ManuLotnum = ""
  35573. struct3501.RxFlag = "0"
  35574. struct3501.ExpyEnd = "2022-08-15"
  35575. struct3501.Invdate = "2022-08-15"
  35576. struct3501.InvCnt = "20.25"
  35577. struct3501.Memo = ""
  35578. struct3501.MedListCodg = "XB01ABD056B002020200517"
  35579. struct3501.FixmedinsHilistId = miConfig.Code
  35580. struct3501.FixmedinsHilistName = miConfig.OrgName
  35581. struct3501s = append(struct3501s, struct3501)
  35582. data["struct_3501s"] = struct3501s
  35583. client := &http.Client{}
  35584. bytesData, _ := json.Marshal(data)
  35585. var req *http.Request
  35586. if miConfig.MdtrtareaAdmvs == "320921" {
  35587. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35588. } else {
  35589. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35590. }
  35591. resp, _ := client.Do(req)
  35592. defer resp.Body.Close()
  35593. body, ioErr := ioutil.ReadAll(resp.Body)
  35594. if ioErr != nil {
  35595. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35597. return
  35598. }
  35599. var respJSON map[string]interface{}
  35600. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35601. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35603. return
  35604. }
  35605. var res ResultSix
  35606. var resSix10265 ResultSix10265 //1101结果
  35607. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  35608. result, _ := json.Marshal(respJSON)
  35609. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  35610. utils.ErrorLog("解析失败:%v", err)
  35611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35612. return
  35613. }
  35614. res.InfRefmsgid = resSix10265.InfRefmsgid
  35615. res.Output = resSix10265.Output
  35616. res.ErrMsg = resSix10265.ErrMsg
  35617. res.Cainfo = resSix10265.Cainfo
  35618. res.WarnMsg = resSix10265.WarnMsg
  35619. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35620. res.Infcode = infocode
  35621. if infocode == 0 {
  35622. c.ServeSuccessJSON(map[string]interface{}{
  35623. "msg": "上传成功",
  35624. })
  35625. return
  35626. } else {
  35627. c.ServeSuccessJSON(map[string]interface{}{
  35628. "failed_code": -10,
  35629. "msg": res.ErrMsg,
  35630. })
  35631. return
  35632. }
  35633. }
  35634. func (c *HisApiController) Post3504() {
  35635. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35636. data := make(map[string]interface{})
  35637. var struct3501s []models.Struct3501
  35638. var struct3501 models.Struct3501
  35639. struct3501.OrgName = miConfig.OrgName
  35640. struct3501.AccessKey = miConfig.AccessKey
  35641. struct3501.RequestUrl = miConfig.Url
  35642. struct3501.SecretKey = miConfig.SecretKey
  35643. struct3501.ManuDate = "2022-08-15"
  35644. struct3501.FixmedinsBchno = ""
  35645. struct3501.ManuLotnum = ""
  35646. struct3501.RxFlag = "0"
  35647. struct3501.ExpyEnd = "2022-08-15"
  35648. struct3501.Invdate = "2022-08-15"
  35649. struct3501.InvCnt = "20.25"
  35650. struct3501.Memo = ""
  35651. struct3501.MedListCodg = "XB01ABD056B002020200517"
  35652. struct3501.FixmedinsHilistId = miConfig.Code
  35653. struct3501.FixmedinsHilistName = miConfig.OrgName
  35654. struct3501s = append(struct3501s, struct3501)
  35655. data["struct_3501s"] = struct3501s
  35656. client := &http.Client{}
  35657. bytesData, _ := json.Marshal(data)
  35658. var req *http.Request
  35659. if miConfig.MdtrtareaAdmvs == "320921" {
  35660. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35661. } else {
  35662. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35663. }
  35664. resp, _ := client.Do(req)
  35665. defer resp.Body.Close()
  35666. body, ioErr := ioutil.ReadAll(resp.Body)
  35667. if ioErr != nil {
  35668. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35670. return
  35671. }
  35672. var respJSON map[string]interface{}
  35673. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35674. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35676. return
  35677. }
  35678. var res ResultSix
  35679. var resSix10265 ResultSix10265 //1101结果
  35680. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  35681. result, _ := json.Marshal(respJSON)
  35682. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  35683. utils.ErrorLog("解析失败:%v", err)
  35684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35685. return
  35686. }
  35687. res.InfRefmsgid = resSix10265.InfRefmsgid
  35688. res.Output = resSix10265.Output
  35689. res.ErrMsg = resSix10265.ErrMsg
  35690. res.Cainfo = resSix10265.Cainfo
  35691. res.WarnMsg = resSix10265.WarnMsg
  35692. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35693. res.Infcode = infocode
  35694. if infocode == 0 {
  35695. c.ServeSuccessJSON(map[string]interface{}{
  35696. "msg": "上传成功",
  35697. })
  35698. return
  35699. } else {
  35700. c.ServeSuccessJSON(map[string]interface{}{
  35701. "failed_code": -10,
  35702. "msg": res.ErrMsg,
  35703. })
  35704. return
  35705. }
  35706. }
  35707. func (c *HisApiController) Post3505() {
  35708. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35709. data := make(map[string]interface{})
  35710. var struct3501s []models.Struct3501
  35711. var struct3501 models.Struct3501
  35712. struct3501.OrgName = miConfig.OrgName
  35713. struct3501.AccessKey = miConfig.AccessKey
  35714. struct3501.RequestUrl = miConfig.Url
  35715. struct3501.SecretKey = miConfig.SecretKey
  35716. struct3501.ManuDate = "2022-08-15"
  35717. struct3501.FixmedinsBchno = ""
  35718. struct3501.ManuLotnum = ""
  35719. struct3501.RxFlag = "0"
  35720. struct3501.ExpyEnd = "2022-08-15"
  35721. struct3501.Invdate = "2022-08-15"
  35722. struct3501.InvCnt = "20.25"
  35723. struct3501.Memo = ""
  35724. struct3501.MedListCodg = "XB01ABD056B002020200517"
  35725. struct3501.FixmedinsHilistId = miConfig.Code
  35726. struct3501.FixmedinsHilistName = miConfig.OrgName
  35727. struct3501s = append(struct3501s, struct3501)
  35728. data["struct_3501s"] = struct3501s
  35729. client := &http.Client{}
  35730. bytesData, _ := json.Marshal(data)
  35731. var req *http.Request
  35732. if miConfig.MdtrtareaAdmvs == "320921" {
  35733. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35734. } else {
  35735. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35736. }
  35737. resp, _ := client.Do(req)
  35738. defer resp.Body.Close()
  35739. body, ioErr := ioutil.ReadAll(resp.Body)
  35740. if ioErr != nil {
  35741. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35743. return
  35744. }
  35745. var respJSON map[string]interface{}
  35746. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35747. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35749. return
  35750. }
  35751. var res ResultSix
  35752. var resSix10265 ResultSix10265 //1101结果
  35753. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  35754. result, _ := json.Marshal(respJSON)
  35755. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  35756. utils.ErrorLog("解析失败:%v", err)
  35757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35758. return
  35759. }
  35760. res.InfRefmsgid = resSix10265.InfRefmsgid
  35761. res.Output = resSix10265.Output
  35762. res.ErrMsg = resSix10265.ErrMsg
  35763. res.Cainfo = resSix10265.Cainfo
  35764. res.WarnMsg = resSix10265.WarnMsg
  35765. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35766. res.Infcode = infocode
  35767. if infocode == 0 {
  35768. c.ServeSuccessJSON(map[string]interface{}{
  35769. "msg": "上传成功",
  35770. })
  35771. return
  35772. } else {
  35773. c.ServeSuccessJSON(map[string]interface{}{
  35774. "failed_code": -10,
  35775. "msg": res.ErrMsg,
  35776. })
  35777. return
  35778. }
  35779. }
  35780. func (c *HisApiController) Post3506() {
  35781. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35782. data := make(map[string]interface{})
  35783. var struct3501s []models.Struct3501
  35784. var struct3501 models.Struct3501
  35785. struct3501.OrgName = miConfig.OrgName
  35786. struct3501.AccessKey = miConfig.AccessKey
  35787. struct3501.RequestUrl = miConfig.Url
  35788. struct3501.SecretKey = miConfig.SecretKey
  35789. struct3501.ManuDate = "2022-08-15"
  35790. struct3501.FixmedinsBchno = ""
  35791. struct3501.ManuLotnum = ""
  35792. struct3501.RxFlag = "0"
  35793. struct3501.ExpyEnd = "2022-08-15"
  35794. struct3501.Invdate = "2022-08-15"
  35795. struct3501.InvCnt = "20.25"
  35796. struct3501.Memo = ""
  35797. struct3501.MedListCodg = "XB01ABD056B002020200517"
  35798. struct3501.FixmedinsHilistId = miConfig.Code
  35799. struct3501.FixmedinsHilistName = miConfig.OrgName
  35800. struct3501s = append(struct3501s, struct3501)
  35801. data["struct_3501s"] = struct3501s
  35802. client := &http.Client{}
  35803. bytesData, _ := json.Marshal(data)
  35804. var req *http.Request
  35805. if miConfig.MdtrtareaAdmvs == "320921" {
  35806. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35807. } else {
  35808. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35809. }
  35810. resp, _ := client.Do(req)
  35811. defer resp.Body.Close()
  35812. body, ioErr := ioutil.ReadAll(resp.Body)
  35813. if ioErr != nil {
  35814. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35816. return
  35817. }
  35818. var respJSON map[string]interface{}
  35819. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35822. return
  35823. }
  35824. var res ResultSix
  35825. var resSix10265 ResultSix10265 //1101结果
  35826. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  35827. result, _ := json.Marshal(respJSON)
  35828. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  35829. utils.ErrorLog("解析失败:%v", err)
  35830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35831. return
  35832. }
  35833. res.InfRefmsgid = resSix10265.InfRefmsgid
  35834. res.Output = resSix10265.Output
  35835. res.ErrMsg = resSix10265.ErrMsg
  35836. res.Cainfo = resSix10265.Cainfo
  35837. res.WarnMsg = resSix10265.WarnMsg
  35838. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35839. res.Infcode = infocode
  35840. if infocode == 0 {
  35841. c.ServeSuccessJSON(map[string]interface{}{
  35842. "msg": "上传成功",
  35843. })
  35844. return
  35845. } else {
  35846. c.ServeSuccessJSON(map[string]interface{}{
  35847. "failed_code": -10,
  35848. "msg": res.ErrMsg,
  35849. })
  35850. return
  35851. }
  35852. }
  35853. func (c *HisApiController) Post3507() {
  35854. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  35855. data := make(map[string]interface{})
  35856. var struct3501s []models.Struct3501
  35857. var struct3501 models.Struct3501
  35858. struct3501.OrgName = miConfig.OrgName
  35859. struct3501.AccessKey = miConfig.AccessKey
  35860. struct3501.RequestUrl = miConfig.Url
  35861. struct3501.SecretKey = miConfig.SecretKey
  35862. struct3501.ManuDate = "2022-08-15"
  35863. struct3501.FixmedinsBchno = ""
  35864. struct3501.ManuLotnum = ""
  35865. struct3501.RxFlag = "0"
  35866. struct3501.ExpyEnd = "2022-08-15"
  35867. struct3501.Invdate = "2022-08-15"
  35868. struct3501.InvCnt = "20.25"
  35869. struct3501.Memo = ""
  35870. struct3501.MedListCodg = "XB01ABD056B002020200517"
  35871. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  35872. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  35873. struct3501s = append(struct3501s, struct3501)
  35874. data["struct_3501s"] = struct3501s
  35875. client := &http.Client{}
  35876. bytesData, _ := json.Marshal(data)
  35877. var req *http.Request
  35878. if miConfig.MdtrtareaAdmvs == "320921" {
  35879. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35880. } else {
  35881. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  35882. }
  35883. resp, _ := client.Do(req)
  35884. defer resp.Body.Close()
  35885. body, ioErr := ioutil.ReadAll(resp.Body)
  35886. if ioErr != nil {
  35887. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35889. return
  35890. }
  35891. var respJSON map[string]interface{}
  35892. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  35893. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35895. return
  35896. }
  35897. var res ResultSix
  35898. var resSix10265 ResultSix10265 //1101结果
  35899. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  35900. result, _ := json.Marshal(respJSON)
  35901. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  35902. utils.ErrorLog("解析失败:%v", err)
  35903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35904. return
  35905. }
  35906. res.InfRefmsgid = resSix10265.InfRefmsgid
  35907. res.Output = resSix10265.Output
  35908. res.ErrMsg = resSix10265.ErrMsg
  35909. res.Cainfo = resSix10265.Cainfo
  35910. res.WarnMsg = resSix10265.WarnMsg
  35911. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35912. res.Infcode = infocode
  35913. if infocode == 0 {
  35914. c.ServeSuccessJSON(map[string]interface{}{
  35915. "msg": "上传成功",
  35916. })
  35917. return
  35918. } else {
  35919. c.ServeSuccessJSON(map[string]interface{}{
  35920. "failed_code": -10,
  35921. "msg": res.ErrMsg,
  35922. })
  35923. return
  35924. }
  35925. }
  35926. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  35927. // WebSocket服务器地址
  35928. serverURL := "ws://127.0.0.1:8899"
  35929. // 解析WebSocket服务器地址
  35930. u, err := url.Parse(serverURL)
  35931. if err != nil {
  35932. }
  35933. // 建立WebSocket连接
  35934. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  35935. if err != nil {
  35936. }
  35937. defer conn.Close()
  35938. input2 := make(map[string]interface{})
  35939. input := make(map[string]interface{})
  35940. inputData := make(map[string]interface{})
  35941. inputData["orgId"] = code
  35942. inputData["businessType"] = "01101"
  35943. inputData["operatorId"] = operator_id
  35944. inputData["operatorName"] = operator_name
  35945. inputData["officeId"] = "001"
  35946. inputData["officeName"] = "血透室"
  35947. inputData["deviceType"] = ""
  35948. input["data"] = inputData
  35949. input["orgId"] = code
  35950. input["transType"] = "ec.query"
  35951. //if md == ""
  35952. if md[:4] == "4403" {
  35953. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  35954. } else if md[:4] == "4401" {
  35955. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  35956. } else {
  35957. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  35958. }
  35959. input2["indata"] = input
  35960. fmt.Println(input2)
  35961. bytesData, _ := json.Marshal(input2)
  35962. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  35963. if err != nil {
  35964. fmt.Println(err)
  35965. }
  35966. // 接收消息
  35967. _, receivedMessage, err := conn.ReadMessage()
  35968. if err != nil {
  35969. fmt.Println(err)
  35970. }
  35971. return "", string(receivedMessage)
  35972. }
  35973. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  35974. // WebSocket服务器地址
  35975. serverURL := "ws://127.0.0.1:8899"
  35976. // 解析WebSocket服务器地址
  35977. u, err := url.Parse(serverURL)
  35978. if err != nil {
  35979. }
  35980. // 建立WebSocket连接
  35981. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  35982. if err != nil {
  35983. }
  35984. defer conn.Close()
  35985. input2 := make(map[string]interface{})
  35986. input := make(map[string]interface{})
  35987. inputData := make(map[string]interface{})
  35988. inputData["orgId"] = code
  35989. inputData["businessType"] = "01101"
  35990. inputData["operatorId"] = operator_id
  35991. inputData["operatorName"] = operator_name
  35992. inputData["officeId"] = "001"
  35993. inputData["officeName"] = "血透室"
  35994. inputData["deviceType"] = ""
  35995. input["data"] = inputData
  35996. input["orgId"] = code
  35997. input["transType"] = "ec.query"
  35998. //if md == ""
  35999. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  36000. input2["indata"] = input
  36001. fmt.Println(input2)
  36002. bytesData, _ := json.Marshal(input2)
  36003. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  36004. if err != nil {
  36005. fmt.Println(err)
  36006. }
  36007. // 接收消息
  36008. _, receivedMessage, err := conn.ReadMessage()
  36009. if err != nil {
  36010. fmt.Println(err)
  36011. }
  36012. return "", string(receivedMessage)
  36013. }
  36014. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  36015. // WebSocket服务器地址
  36016. serverURL := "ws://127.0.0.1:8899"
  36017. // 解析WebSocket服务器地址
  36018. u, err := url.Parse(serverURL)
  36019. if err != nil {
  36020. }
  36021. // 建立WebSocket连接
  36022. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  36023. if err != nil {
  36024. }
  36025. defer conn.Close()
  36026. input2 := make(map[string]interface{})
  36027. input := make(map[string]interface{})
  36028. inputData := make(map[string]interface{})
  36029. inputData["orgId"] = code
  36030. inputData["businessType"] = "01301"
  36031. inputData["operatorId"] = operator_id
  36032. inputData["operatorName"] = operator_name
  36033. inputData["officeId"] = "001"
  36034. inputData["officeName"] = "血透室"
  36035. inputData["deviceType"] = ""
  36036. input["data"] = inputData
  36037. input["orgId"] = code
  36038. input["transType"] = "ec.query"
  36039. //if md == ""
  36040. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  36041. input2["indata"] = input
  36042. fmt.Println(input2)
  36043. bytesData, _ := json.Marshal(input2)
  36044. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  36045. if err != nil {
  36046. fmt.Println(err)
  36047. }
  36048. // 接收消息
  36049. _, receivedMessage, err := conn.ReadMessage()
  36050. if err != nil {
  36051. fmt.Println(err)
  36052. }
  36053. return "", string(receivedMessage)
  36054. }
  36055. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  36056. // WebSocket服务器地址
  36057. serverURL := "ws://127.0.0.1:8899"
  36058. // 解析WebSocket服务器地址
  36059. u, err := url.Parse(serverURL)
  36060. if err != nil {
  36061. }
  36062. // 建立WebSocket连接
  36063. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  36064. if err != nil {
  36065. }
  36066. defer conn.Close()
  36067. input2 := make(map[string]interface{})
  36068. input := make(map[string]interface{})
  36069. inputData := make(map[string]interface{})
  36070. inputData["orgId"] = code
  36071. inputData["businessType"] = "01103"
  36072. inputData["operatorId"] = operator_id
  36073. inputData["operatorName"] = operator_name
  36074. inputData["officeId"] = "001"
  36075. inputData["officeName"] = "血透室"
  36076. inputData["deviceType"] = ""
  36077. input["data"] = inputData
  36078. input["orgId"] = code
  36079. input["transType"] = "ec.query"
  36080. //if md ==
  36081. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  36082. input2["indata"] = input
  36083. fmt.Println(input2)
  36084. bytesData, _ := json.Marshal(input2)
  36085. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  36086. if err != nil {
  36087. fmt.Println(err)
  36088. }
  36089. // 接收消息
  36090. _, receivedMessage, err := conn.ReadMessage()
  36091. if err != nil {
  36092. fmt.Println(err)
  36093. }
  36094. return "", string(receivedMessage)
  36095. }
  36096. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  36097. // WebSocket服务器地址
  36098. serverURL := "ws://127.0.0.1:8899"
  36099. // 解析WebSocket服务器地址
  36100. u, err := url.Parse(serverURL)
  36101. if err != nil {
  36102. }
  36103. // 建立WebSocket连接
  36104. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  36105. if err != nil {
  36106. }
  36107. defer conn.Close()
  36108. input2 := make(map[string]interface{})
  36109. input := make(map[string]interface{})
  36110. inputData := make(map[string]interface{})
  36111. inputData["orgId"] = code
  36112. inputData["businessType"] = "01101"
  36113. inputData["operatorId"] = operator_id
  36114. inputData["operatorName"] = operator_name
  36115. inputData["officeId"] = "001"
  36116. inputData["officeName"] = "血透室"
  36117. inputData["deviceType"] = ""
  36118. input["data"] = inputData
  36119. input["orgId"] = code
  36120. input["transType"] = "ec.query"
  36121. //if md == ""
  36122. if md[:4] == "4403" {
  36123. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  36124. } else if md[:4] == "4401" {
  36125. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  36126. } else {
  36127. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  36128. }
  36129. input2["indata"] = input
  36130. fmt.Println(input2)
  36131. bytesData, _ := json.Marshal(input2)
  36132. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  36133. if err != nil {
  36134. fmt.Println(err)
  36135. }
  36136. // 接收消息
  36137. _, receivedMessage, err := conn.ReadMessage()
  36138. if err != nil {
  36139. fmt.Println(err)
  36140. }
  36141. return "", string(receivedMessage)
  36142. }
  36143. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  36144. // WebSocket服务器地址
  36145. serverURL := "ws://127.0.0.1:8899"
  36146. // 解析WebSocket服务器地址
  36147. u, err := url.Parse(serverURL)
  36148. if err != nil {
  36149. }
  36150. // 建立WebSocket连接
  36151. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  36152. if err != nil {
  36153. }
  36154. defer conn.Close()
  36155. input2 := make(map[string]interface{})
  36156. input := make(map[string]interface{})
  36157. inputData := make(map[string]interface{})
  36158. inputData["orgId"] = code
  36159. inputData["businessType"] = "01301"
  36160. inputData["operatorId"] = operator_id
  36161. inputData["operatorName"] = operator_name
  36162. inputData["officeId"] = "001"
  36163. inputData["officeName"] = "血透室"
  36164. inputData["deviceType"] = ""
  36165. input["data"] = inputData
  36166. input["orgId"] = code
  36167. input["transType"] = "ec.query"
  36168. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  36169. input2["indata"] = input
  36170. bytesData, _ := json.Marshal(input2)
  36171. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  36172. if err != nil {
  36173. fmt.Println(err)
  36174. }
  36175. // 接收消息
  36176. _, receivedMessage, err := conn.ReadMessage()
  36177. if err != nil {
  36178. fmt.Println(err)
  36179. }
  36180. return "", string(receivedMessage)
  36181. }
  36182. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  36183. newArr = make([]string, 0)
  36184. for i := 0; i < len(arr); i++ {
  36185. repeat := false
  36186. for j := i + 1; j < len(arr); j++ {
  36187. if arr[i] == arr[j] {
  36188. repeat = true
  36189. break
  36190. }
  36191. }
  36192. if !repeat {
  36193. newArr = append(newArr, arr[i])
  36194. }
  36195. }
  36196. return
  36197. }
  36198. func getBirthdateAndAge(idNumber string) (string, int, error) {
  36199. if len(idNumber) != 18 {
  36200. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  36201. }
  36202. // 提取出生日期
  36203. year, err := strconv.Atoi(idNumber[6:10])
  36204. if err != nil {
  36205. return "", 0, err
  36206. }
  36207. month, err := strconv.Atoi(idNumber[10:12])
  36208. if err != nil {
  36209. return "", 0, err
  36210. }
  36211. day, err := strconv.Atoi(idNumber[12:14])
  36212. if err != nil {
  36213. return "", 0, err
  36214. }
  36215. // 格式化生日字符串
  36216. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  36217. birthdateFormatted := birthdate.Format("2006-01-02")
  36218. // 计算年龄
  36219. today := time.Now()
  36220. age := today.Year() - birthdate.Year()
  36221. if today.YearDay() < birthdate.YearDay() {
  36222. age--
  36223. }
  36224. return birthdateFormatted, age, nil
  36225. }
  36226. // 从身份证号码中提取出生年月日
  36227. func getBirthDateFromIDCard(idCard string) (string, error) {
  36228. // 身份证号码长度应为18位
  36229. if len(idCard) != 18 {
  36230. return "", fmt.Errorf("身份证号码长度应为18位")
  36231. }
  36232. // 提取出生日期部分 (YYYYMMDD)
  36233. birthDateStr := idCard[6:14]
  36234. // 解析出生日期
  36235. birthDate, err := time.Parse("20060102", birthDateStr)
  36236. if err != nil {
  36237. return "", fmt.Errorf("解析出生日期失败: %v", err)
  36238. }
  36239. // 格式化出生日期为 YYYY-MM-DD
  36240. formattedDate := birthDate.Format("2006-01-02")
  36241. return formattedDate, nil
  36242. }